@tailor-platform/sdk 1.51.2 → 1.52.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.
- package/CHANGELOG.md +47 -0
- package/dist/{actor-Nag62ZDM.d.mts → actor-DwAh0Dij.d.mts} +3 -8
- package/dist/application-B_yEREFy.mjs +4 -0
- package/dist/{application-Z-fNwyZB.mjs → application-CECifcE9.mjs} +11 -11
- package/dist/{application-Z-fNwyZB.mjs.map → application-CECifcE9.mjs.map} +1 -1
- package/dist/{authconnection-BUko4V6H.mjs → authconnection-D8SJGMpj.mjs} +2 -2
- package/dist/{authconnection-BUko4V6H.mjs.map → authconnection-D8SJGMpj.mjs.map} +1 -1
- package/dist/{authconnection-BDFTabLQ.d.mts → authconnection-TsdLYaLs.d.mts} +1 -1
- package/dist/{brand-Ll48SMXe.mjs → brand-DlnJ375c.mjs} +1 -1
- package/dist/{brand-Ll48SMXe.mjs.map → brand-DlnJ375c.mjs.map} +1 -1
- package/dist/cli/index.mjs +16 -16
- package/dist/cli/lib.d.mts +7 -7
- package/dist/cli/lib.mjs +8 -8
- package/dist/cli/skills.mjs +1 -1
- package/dist/{client-BwV17byk.mjs → client-CKlZhiq4.mjs} +4 -4
- package/dist/{client-BwV17byk.mjs.map → client-CKlZhiq4.mjs.map} +1 -1
- package/dist/{client-D_a50aIg.mjs → client-btP2hNF1.mjs} +1 -1
- package/dist/configure/index.d.mts +4 -4
- package/dist/configure/index.mjs +4 -4
- package/dist/{context-BXDgEQK9.d.mts → context-CUBwSBq4.d.mts} +1 -1
- package/dist/{context-BP5BUdcq.mjs → context-s0lxhu8_.mjs} +2 -2
- package/dist/{context-BP5BUdcq.mjs.map → context-s0lxhu8_.mjs.map} +1 -1
- package/dist/{crashreport-C4EbRoku.mjs → crashreport-CGE6P9Kf.mjs} +1 -1
- package/dist/{crashreport-DauPOrKn.mjs → crashreport-DJ5SS5Q-.mjs} +5 -5
- package/dist/{crashreport-DauPOrKn.mjs.map → crashreport-DJ5SS5Q-.mjs.map} +1 -1
- package/dist/{enum-constants-DI85-fPE.mjs → enum-constants-C7DaWeQo.mjs} +1 -1
- package/dist/{enum-constants-DI85-fPE.mjs.map → enum-constants-C7DaWeQo.mjs.map} +1 -1
- package/dist/env-B-g-qgE4.d.mts +7 -0
- package/dist/{errors-C4cJ0M2K.mjs → errors-EsY4XO6O.mjs} +1 -1
- package/dist/{errors-C4cJ0M2K.mjs.map → errors-EsY4XO6O.mjs.map} +1 -1
- package/dist/{field-BY2vbJ8f.mjs → field-C4zdJLW5.mjs} +1 -1
- package/dist/{field-BY2vbJ8f.mjs.map → field-C4zdJLW5.mjs.map} +1 -1
- package/dist/{file-Dc4_QrlQ.d.mts → file-DaCYOLPz.d.mts} +1 -1
- package/dist/{file-BE5Sy7lP.mjs → file-umdycPAF.mjs} +2 -2
- package/dist/{file-BE5Sy7lP.mjs.map → file-umdycPAF.mjs.map} +1 -1
- package/dist/{file-utils-BM8t5jCy.mjs → file-utils-BHPxPXmn.mjs} +2 -2
- package/dist/{file-utils-BM8t5jCy.mjs.map → file-utils-BHPxPXmn.mjs.map} +1 -1
- package/dist/{iconv-BFNfdlIS.d.mts → iconv-Chu6Hit2.d.mts} +1 -1
- package/dist/{iconv-D0yL88Il.mjs → iconv-DreIffeM.mjs} +2 -2
- package/dist/{iconv-D0yL88Il.mjs.map → iconv-DreIffeM.mjs.map} +1 -1
- package/dist/{idp-B1b4O7ia.d.mts → idp-CbxR6A_0.d.mts} +1 -1
- package/dist/{idp-CM7N7iID.mjs → idp-Ch95ag8h.mjs} +2 -2
- package/dist/{idp-CM7N7iID.mjs.map → idp-Ch95ag8h.mjs.map} +1 -1
- package/dist/{index-CYAZkd4b.d.mts → index-BCJtNXKo.d.mts} +2 -2
- package/dist/{index-aiIbrFGw.d.mts → index-BIbKrme4.d.mts} +2 -2
- package/dist/{index-BXwAT_oE.d.mts → index-BL5LQnBX.d.mts} +2 -2
- package/dist/{index-CfSjuxzK.d.mts → index-DW6gAGmC.d.mts} +2 -2
- package/dist/{index-BD99GoHO.d.mts → index-UySZfxON.d.mts} +8 -6
- package/dist/{index-Dy3ZH5Wm.d.mts → index-wuuZLoFt.d.mts} +8 -8
- package/dist/{interceptor-Cr3kZWMc.mjs → interceptor-DOqRkCya.mjs} +1 -1
- package/dist/{interceptor-Cr3kZWMc.mjs.map → interceptor-DOqRkCya.mjs.map} +1 -1
- package/dist/{job-4GOnasfT.mjs → job-CEAJLiGp.mjs} +8 -5
- package/dist/job-CEAJLiGp.mjs.map +1 -0
- package/dist/kysely/index.mjs.map +1 -1
- package/dist/{kysely-type-BUoVDC5r.mjs → kysely-type-D1e0Vwkd.mjs} +2 -2
- package/dist/{kysely-type-BUoVDC5r.mjs.map → kysely-type-D1e0Vwkd.mjs.map} +1 -1
- package/dist/{logger-B1g4I9wT.mjs → logger-DpJyJvNz.mjs} +1 -1
- package/dist/{logger-B1g4I9wT.mjs.map → logger-DpJyJvNz.mjs.map} +1 -1
- package/dist/{mock-B2t5gDMl.mjs → mock-BabuSqbj.mjs} +20 -1
- package/dist/mock-BabuSqbj.mjs.map +1 -0
- package/dist/{multiline-G1yF18OH.mjs → multiline-Cf9ODpr1.mjs} +1 -1
- package/dist/{multiline-G1yF18OH.mjs.map → multiline-Cf9ODpr1.mjs.map} +1 -1
- package/dist/{package-json-ZL0MkZOO.mjs → package-json-DcQApfPQ.mjs} +1 -1
- package/dist/{package-json-ZL0MkZOO.mjs.map → package-json-DcQApfPQ.mjs.map} +1 -1
- package/dist/package-json-wzO6nV9O.mjs +4 -0
- package/dist/plugin/builtin/enum-constants/index.d.mts +1 -1
- package/dist/plugin/builtin/enum-constants/index.mjs +1 -1
- package/dist/plugin/builtin/file-utils/index.d.mts +1 -1
- package/dist/plugin/builtin/file-utils/index.mjs +1 -1
- package/dist/plugin/builtin/kysely-type/index.d.mts +1 -1
- package/dist/plugin/builtin/kysely-type/index.mjs +1 -1
- package/dist/plugin/builtin/seed/index.d.mts +1 -1
- package/dist/plugin/builtin/seed/index.mjs +1 -1
- package/dist/plugin/index.d.mts +3 -2
- package/dist/{repl-editor-yAjwS5_M.mjs → repl-editor-ihh8koiR.mjs} +1 -1
- package/dist/{repl-editor-yAjwS5_M.mjs.map → repl-editor-ihh8koiR.mjs.map} +1 -1
- package/dist/runtime/authconnection.d.mts +1 -1
- package/dist/runtime/authconnection.mjs +1 -1
- package/dist/runtime/context.d.mts +1 -1
- package/dist/runtime/context.mjs +1 -1
- package/dist/runtime/file.d.mts +1 -1
- package/dist/runtime/file.mjs +1 -1
- package/dist/runtime/globals.d.mts +6 -6
- package/dist/runtime/iconv.d.mts +1 -1
- package/dist/runtime/iconv.mjs +1 -1
- package/dist/runtime/idp.d.mts +1 -1
- package/dist/runtime/idp.mjs +1 -1
- package/dist/runtime/index.d.mts +8 -8
- package/dist/runtime/index.mjs +7 -7
- package/dist/runtime/secretmanager.d.mts +1 -1
- package/dist/runtime/secretmanager.mjs +1 -1
- package/dist/runtime/workflow.d.mts +1 -1
- package/dist/runtime/workflow.mjs +1 -1
- package/dist/{runtime-1NlbDNN0.mjs → runtime-BN484A6U.mjs} +264 -42
- package/dist/runtime-BN484A6U.mjs.map +1 -0
- package/dist/{schema-DBq6hr6h.mjs → schema-CQrYG_55.mjs} +3 -3
- package/dist/{schema-DBq6hr6h.mjs.map → schema-CQrYG_55.mjs.map} +1 -1
- package/dist/{secret-file-DnbmTWec.mjs → secret-file-CWzF8rry.mjs} +1 -1
- package/dist/{secret-file-DnbmTWec.mjs.map → secret-file-CWzF8rry.mjs.map} +1 -1
- package/dist/{secretmanager-CQTTuCmn.mjs → secretmanager-B9h-U_8U.mjs} +2 -2
- package/dist/{secretmanager-CQTTuCmn.mjs.map → secretmanager-B9h-U_8U.mjs.map} +1 -1
- package/dist/{secretmanager-Cjq3s2aU.d.mts → secretmanager-BhpDmxwT.d.mts} +1 -1
- package/dist/{seed-kNk-xLoB.mjs → seed-DfLyRh63.mjs} +2 -2
- package/dist/{seed-kNk-xLoB.mjs.map → seed-DfLyRh63.mjs.map} +1 -1
- package/dist/{service-DHgJ4YEF.mjs → service-aPT0fx3y.mjs} +3 -3
- package/dist/{service-DHgJ4YEF.mjs.map → service-aPT0fx3y.mjs.map} +1 -1
- package/dist/{tailor-db-field-BhWvOyky.d.mts → tailor-db-field-Y_zEoGu1.d.mts} +1 -1
- package/dist/{telemetry-C8xKz3GM.mjs → telemetry-BQbbVo2t.mjs} +2 -2
- package/dist/{telemetry-C8xKz3GM.mjs.map → telemetry-BQbbVo2t.mjs.map} +1 -1
- package/dist/telemetry-w92bvGdC.mjs +4 -0
- package/dist/test-env-key-CSnK4W1Y.mjs +30 -0
- package/dist/test-env-key-CSnK4W1Y.mjs.map +1 -0
- package/dist/{types-Duhhsx3R.mjs → types-BinLwXM9.mjs} +2 -2
- package/dist/{types-Duhhsx3R.mjs.map → types-BinLwXM9.mjs.map} +1 -1
- package/dist/types-UeXbHFXW.mjs +5 -0
- package/dist/utils/test/index.d.mts +3 -3
- package/dist/utils/test/index.mjs +1 -1
- package/dist/vitest/environment.mjs +1 -1
- package/dist/vitest/index.d.mts +7 -7
- package/dist/vitest/index.mjs +1 -1
- package/dist/vitest/setup.mjs +1 -1
- package/dist/{workflow-DJRr-0nl.mjs → workflow--aPbA8Uq.mjs} +2 -2
- package/dist/{workflow-DJRr-0nl.mjs.map → workflow--aPbA8Uq.mjs.map} +1 -1
- package/dist/{workflow-DV_88JEf.d.mts → workflow-dYYH7QFa.d.mts} +1 -1
- package/dist/{workflow.generated-DV87DJfO.d.mts → workflow.generated-BIY41La-.d.mts} +2 -2
- package/docs/cli/application.md +15 -6
- package/docs/cli/completion.md +5 -3
- package/docs/testing.md +13 -13
- package/package.json +13 -13
- package/dist/application-Bcx-FbDE.mjs +0 -4
- package/dist/job-4GOnasfT.mjs.map +0 -1
- package/dist/mock-B2t5gDMl.mjs.map +0 -1
- package/dist/package-json-CAGKAJff.mjs +0 -4
- package/dist/runtime-1NlbDNN0.mjs.map +0 -1
- package/dist/telemetry-DQl47E1s.mjs +0 -4
- package/dist/types-BnphjkIJ.mjs +0 -5
- /package/dist/{chunk-DLeslSnM.mjs → chunk-BkoGK1jX.mjs} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"idp-
|
|
1
|
+
{"version":3,"file":"idp-Ch95ag8h.mjs","names":["#impl"],"sources":["../src/runtime/idp.ts"],"sourcesContent":["/**\n * IDP (Identity Provider) utilities.\n *\n * Thin typed wrapper around the platform-provided `tailor.idp` runtime API.\n * At runtime this delegates to `globalThis.tailor.idp`. Use `idpMock` from\n * `@tailor-platform/sdk/vitest` to mock these calls in unit tests.\n * @example\n * import { idp } from \"@tailor-platform/sdk/runtime\";\n *\n * const client = new idp.Client({ namespace: \"my-namespace\" });\n * const { users } = await client.users({ first: 10 });\n */\n\n/** Configuration object for {@link Client}. */\nexport interface ClientConfig {\n namespace: string;\n}\n\n/** User record returned by IDP operations. */\nexport interface User {\n id: string;\n name: string;\n disabled: boolean;\n createdAt?: string;\n updatedAt?: string;\n}\n\n/** Filter options for {@link Client.users}. */\nexport interface UserQuery {\n /** Filter by user IDs */\n ids?: string[];\n /** Filter by user names */\n names?: string[];\n}\n\n/** Pagination/filter options for {@link Client.users}. */\nexport interface ListUsersOptions {\n /** Maximum number of users to return */\n first?: number;\n /** Page token for pagination */\n after?: string;\n /** Query filter for users */\n query?: UserQuery;\n}\n\n/** Response shape for {@link Client.users}. */\nexport interface ListUsersResponse {\n users: User[];\n nextPageToken: string | null;\n totalCount: number;\n}\n\n/** Input for {@link Client.createUser}. */\nexport interface CreateUserInput {\n /** The user's name (typically email) */\n name: string;\n /** The user's password. If omitted, the user is created without a password (cannot log in with any password). */\n password?: string;\n /** Whether the user is disabled */\n disabled?: boolean;\n}\n\n/** Input for {@link Client.updateUser}. */\nexport interface UpdateUserInput {\n /** The user's ID */\n id: string;\n /** New name for the user */\n name?: string;\n /** New password for the user. Cannot be used with clearPassword. */\n password?: string;\n /** If true, remove the user's password. Cannot be used with password. */\n clearPassword?: boolean;\n /** New disabled status for the user */\n disabled?: boolean;\n}\n\n/** Input for {@link Client.sendPasswordResetEmail}. */\nexport interface SendPasswordResetEmailInput {\n /** The ID of the user */\n userId: string;\n /** The URI to redirect to after password reset */\n redirectUri: string;\n /** The sender display name. Defaults to 'Tailor Platform IdP'. */\n fromName?: string;\n /** The email subject line. Defaults to the localized default subject. */\n subject?: string;\n}\n\n/** Instance methods exposed by `tailor.idp.Client`. */\nexport interface IdpClientInstance {\n users(options?: ListUsersOptions): Promise<ListUsersResponse>;\n user(userId: string): Promise<User>;\n userByName(name: string): Promise<User>;\n createUser(input: CreateUserInput): Promise<User>;\n updateUser(input: UpdateUserInput): Promise<User>;\n deleteUser(userId: string): Promise<boolean>;\n sendPasswordResetEmail(input: SendPasswordResetEmailInput): Promise<boolean>;\n}\n\n/**\n * Constructor shape for `tailor.idp.Client`.\n * @internal\n */\nexport interface IdpClientConstructor {\n new (config: ClientConfig): IdpClientInstance;\n}\n\n/**\n * Platform API surface for `tailor.idp`. Describes the shape the platform\n * runtime injects on `globalThis.tailor.idp`.\n * @internal\n */\nexport interface TailorIdpAPI {\n Client: IdpClientConstructor;\n}\n\n/**\n * IDP Client for user management operations.\n *\n * Wraps the platform-provided `tailor.idp.Client` and exposes the same surface.\n */\nexport class Client {\n #impl: IdpClientInstance;\n\n constructor(config: ClientConfig) {\n this.#impl = new (globalThis as { tailor: { idp: TailorIdpAPI } }).tailor.idp.Client(config);\n }\n\n /**\n * List users in the namespace with optional filtering and pagination.\n * @param options - Pagination and filter options\n * @returns Page of users with `nextPageToken` and `totalCount`\n */\n users(options?: ListUsersOptions): Promise<ListUsersResponse> {\n return this.#impl.users(options);\n }\n\n /**\n * Get a user by ID.\n * @param userId - IDP user ID\n * @returns The matching user\n */\n user(userId: string): Promise<User> {\n return this.#impl.user(userId);\n }\n\n /**\n * Get a user by name.\n * @param name - IDP user name\n * @returns The matching user\n */\n userByName(name: string): Promise<User> {\n return this.#impl.userByName(name);\n }\n\n /**\n * Create a new user.\n * @param input - User attributes\n * @returns The newly created user\n */\n createUser(input: CreateUserInput): Promise<User> {\n return this.#impl.createUser(input);\n }\n\n /**\n * Update an existing user.\n * @param input - User ID plus attributes to update\n * @returns The updated user\n */\n updateUser(input: UpdateUserInput): Promise<User> {\n return this.#impl.updateUser(input);\n }\n\n /**\n * Delete a user by ID.\n * @param userId - IDP user ID\n * @returns `true` when the user was deleted\n */\n deleteUser(userId: string): Promise<boolean> {\n return this.#impl.deleteUser(userId);\n }\n\n /**\n * Send a password reset email to a user.\n * @param input - Target user ID and redirect URI\n * @returns `true` when the email was queued\n */\n sendPasswordResetEmail(input: SendPasswordResetEmailInput): Promise<boolean> {\n return this.#impl.sendPasswordResetEmail(input);\n }\n}\n"],"mappings":";;;;;;;;;;AAyHA,IAAa,SAAb,MAAoB;CAClB;CAEA,YAAY,QAAsB;EAChC,KAAKA,QAAQ,IAAK,WAAiD,OAAO,IAAI,OAAO,MAAM;CAC7F;;;;;;CAOA,MAAM,SAAwD;EAC5D,OAAO,KAAKA,MAAM,MAAM,OAAO;CACjC;;;;;;CAOA,KAAK,QAA+B;EAClC,OAAO,KAAKA,MAAM,KAAK,MAAM;CAC/B;;;;;;CAOA,WAAW,MAA6B;EACtC,OAAO,KAAKA,MAAM,WAAW,IAAI;CACnC;;;;;;CAOA,WAAW,OAAuC;EAChD,OAAO,KAAKA,MAAM,WAAW,KAAK;CACpC;;;;;;CAOA,WAAW,OAAuC;EAChD,OAAO,KAAKA,MAAM,WAAW,KAAK;CACpC;;;;;;CAOA,WAAW,QAAkC;EAC3C,OAAO,KAAKA,MAAM,WAAW,MAAM;CACrC;;;;;;CAOA,uBAAuB,OAAsD;EAC3E,OAAO,KAAKA,MAAM,uBAAuB,KAAK;CAChD;AACF"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { o as Plugin } from "./tailor-db-field-
|
|
1
|
+
import { o as Plugin } from "./tailor-db-field-Y_zEoGu1.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/plugin/builtin/seed/index.d.ts
|
|
4
4
|
/** Unique identifier for the seed generator plugin. */
|
|
@@ -44,4 +44,4 @@ type SeedPluginOptions = {
|
|
|
44
44
|
declare function seedPlugin(options: SeedPluginOptions): Plugin<unknown, SeedPluginOptions>;
|
|
45
45
|
//#endregion
|
|
46
46
|
export { seedPlugin as n, SeedGeneratorID as t };
|
|
47
|
-
//# sourceMappingURL=index-
|
|
47
|
+
//# sourceMappingURL=index-BCJtNXKo.d.mts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { o as Plugin } from "./tailor-db-field-
|
|
1
|
+
import { o as Plugin } from "./tailor-db-field-Y_zEoGu1.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/plugin/builtin/kysely-type/index.d.ts
|
|
4
4
|
/** Unique identifier for the Kysely type generator plugin. */
|
|
@@ -15,4 +15,4 @@ type KyselyTypePluginOptions = {
|
|
|
15
15
|
declare function kyselyTypePlugin(options: KyselyTypePluginOptions): Plugin<unknown, KyselyTypePluginOptions>;
|
|
16
16
|
//#endregion
|
|
17
17
|
export { kyselyTypePlugin as n, KyselyGeneratorID as t };
|
|
18
|
-
//# sourceMappingURL=index-
|
|
18
|
+
//# sourceMappingURL=index-BIbKrme4.d.mts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { o as Plugin } from "./tailor-db-field-
|
|
1
|
+
import { o as Plugin } from "./tailor-db-field-Y_zEoGu1.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/plugin/builtin/file-utils/index.d.ts
|
|
4
4
|
/** Unique identifier for the file utilities generator plugin. */
|
|
@@ -15,4 +15,4 @@ type FileUtilsPluginOptions = {
|
|
|
15
15
|
declare function fileUtilsPlugin(options: FileUtilsPluginOptions): Plugin<unknown, FileUtilsPluginOptions>;
|
|
16
16
|
//#endregion
|
|
17
17
|
export { fileUtilsPlugin as n, FileUtilsGeneratorID as t };
|
|
18
|
-
//# sourceMappingURL=index-
|
|
18
|
+
//# sourceMappingURL=index-BL5LQnBX.d.mts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { o as Plugin } from "./tailor-db-field-
|
|
1
|
+
import { o as Plugin } from "./tailor-db-field-Y_zEoGu1.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/plugin/builtin/enum-constants/index.d.ts
|
|
4
4
|
/** Unique identifier for the enum constants generator plugin. */
|
|
@@ -15,4 +15,4 @@ type EnumConstantsPluginOptions = {
|
|
|
15
15
|
declare function enumConstantsPlugin(options: EnumConstantsPluginOptions): Plugin<unknown, EnumConstantsPluginOptions>;
|
|
16
16
|
//#endregion
|
|
17
17
|
export { enumConstantsPlugin as n, EnumConstantsGeneratorID as t };
|
|
18
|
-
//# sourceMappingURL=index-
|
|
18
|
+
//# sourceMappingURL=index-DW6gAGmC.d.mts.map
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { $ as ResolverInput, At as FieldMetadata, Bt as InferredAttributeMap, Dt as ArrayFieldOutput, Ft as FieldValidateInput, G as UserAttributeListKey, Gt as JsonCompatible, Ht as TailorUser, Jt as output$1, K as UserAttributeMap, Kt as JsonValue, Mt as FieldOutput, Nt as TailorFieldType, Ot as DefinedFieldMetadata, Q as Resolver, V as DefinedAuth, Vt as TailorInvoker, Wt as InferFieldsOutput, Y as TailorField$1, at as FunctionOperation$1, ct as IncomingWebhookTrigger$1, dt as TailorDBTrigger$1, et as GeneratorConfig, ft as WebhookOperation$1, it as ExecutorInput, jt as FieldOptions, lt as ResolverExecutedTrigger$1, mt as AuthInvoker$1, nt as AuthAccessTokenTrigger$1, o as Plugin, ot as GqlOperation$1, pt as WorkflowOperation$1, qt as Prettify, st as IdpUserTrigger$1, tt as BaseGeneratorConfig, ut as ScheduleTriggerInput, z as AuthServiceInput } from "./tailor-db-field-
|
|
2
|
-
import { C as IdPInput, D as TailorDBInstance, F as AllowedValues, I as AllowedValuesOutput, O as TailorDBType, f as StaticWebsiteDefinitionBrand, h as SecretsDefinitionBrand, n as RetryPolicy, p as StaticWebsiteInput, r as AppConfig, t as ConcurrencyPolicy, v as IdPUserField, y as IdpDefinitionBrand } from "./workflow.generated-
|
|
3
|
-
import {
|
|
1
|
+
import { $ as ResolverInput, At as FieldMetadata, Bt as InferredAttributeMap, Dt as ArrayFieldOutput, Ft as FieldValidateInput, G as UserAttributeListKey, Gt as JsonCompatible, Ht as TailorUser, Jt as output$1, K as UserAttributeMap, Kt as JsonValue, Mt as FieldOutput, Nt as TailorFieldType, Ot as DefinedFieldMetadata, Q as Resolver, V as DefinedAuth, Vt as TailorInvoker, Wt as InferFieldsOutput, Y as TailorField$1, at as FunctionOperation$1, ct as IncomingWebhookTrigger$1, dt as TailorDBTrigger$1, et as GeneratorConfig, ft as WebhookOperation$1, it as ExecutorInput, jt as FieldOptions, lt as ResolverExecutedTrigger$1, mt as AuthInvoker$1, nt as AuthAccessTokenTrigger$1, o as Plugin, ot as GqlOperation$1, pt as WorkflowOperation$1, qt as Prettify, st as IdpUserTrigger$1, tt as BaseGeneratorConfig, ut as ScheduleTriggerInput, z as AuthServiceInput } from "./tailor-db-field-Y_zEoGu1.mjs";
|
|
2
|
+
import { C as IdPInput, D as TailorDBInstance, F as AllowedValues, I as AllowedValuesOutput, O as TailorDBType, f as StaticWebsiteDefinitionBrand, h as SecretsDefinitionBrand, n as RetryPolicy, p as StaticWebsiteInput, r as AppConfig, t as ConcurrencyPolicy, v as IdPUserField, y as IdpDefinitionBrand } from "./workflow.generated-BIY41La-.mjs";
|
|
3
|
+
import { n as TailorEnv } from "./env-B-g-qgE4.mjs";
|
|
4
|
+
import { t as TailorActor } from "./actor-DwAh0Dij.mjs";
|
|
4
5
|
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
5
6
|
import { Client } from "@urql/core";
|
|
6
7
|
import { StandardCRON } from "ts-cron-validator";
|
|
@@ -247,8 +248,9 @@ interface WorkflowJob<Name extends string = string, Input = undefined, Output =
|
|
|
247
248
|
body: (input: Input, context: WorkflowJobContext) => Output | Promise<Output>;
|
|
248
249
|
}
|
|
249
250
|
/**
|
|
250
|
-
*
|
|
251
|
-
*
|
|
251
|
+
* Env-var fallback read by `.trigger()` when `workflowMock.setEnv()` is unset.
|
|
252
|
+
* Kept for backward compatibility.
|
|
253
|
+
* @deprecated Use `workflowMock.setEnv()` from `@tailor-platform/sdk/vitest`.
|
|
252
254
|
*/
|
|
253
255
|
declare const WORKFLOW_TEST_ENV_KEY = "TAILOR_TEST_WORKFLOW_ENV";
|
|
254
256
|
interface CreateWorkflowJobConfig<Name extends string, I, O> {
|
|
@@ -1120,4 +1122,4 @@ declare namespace t {
|
|
|
1120
1122
|
}
|
|
1121
1123
|
//#endregion
|
|
1122
1124
|
export { recordDeletedTrigger as $, AuthAccessTokenRefreshedArgs as A, RecordUpdatedArgs as B, IncomingWebhookTriggerOptions as C, MachineUserNameRegistry as Ct, scheduleTrigger as D, ScheduleTrigger as E, IdpUserDeletedArgs as F, authAccessTokenRefreshedTrigger as G, ResolverExecutedTrigger as H, IdpUserTrigger as I, idpUserCreatedTrigger as J, authAccessTokenRevokedTrigger as K, IdpUserUpdatedArgs as L, AuthAccessTokenTrigger as M, IdpUserArgs as N, AuthAccessTokenArgs as O, IdpUserCreatedArgs as P, recordCreatedTrigger as Q, RecordCreatedArgs as R, IncomingWebhookTrigger as S, MachineUserName as St, ScheduleArgs as T, TailorDBTrigger as U, ResolverExecutedArgs as V, authAccessTokenIssuedTrigger as W, idpUserTrigger as X, idpUserDeletedTrigger as Y, idpUserUpdatedTrigger as Z, Trigger as _, AuthInvoker as _t, defineGenerators as a, Operation as at, IncomingWebhookResponse as b, IdpNameRegistry as bt, defineIdp as c, Workflow as ct, unsafeAllowAllIdPPermission as d, WORKFLOW_TEST_ENV_KEY as dt, recordTrigger as et, defineStaticWebSite as f, WorkflowJob as ft, createExecutor as g, createResolver as gt, defineWaitPoints as h, QueryType as ht, defineConfig as i, GqlOperation as it, AuthAccessTokenRevokedArgs as j, AuthAccessTokenIssuedArgs as k, IdPPermission as l, WorkflowConfig as lt, defineWaitPoint as m, createWorkflowJob as mt, output as n, resolverExecutedTrigger as nt, definePlugins as o, WebhookOperation as ot, WaitPointInstance as p, WorkflowJobContext as pt, authAccessTokenTrigger as q, t as r, FunctionOperation as rt, defineSecretManager as s, WorkflowOperation as st, infer as t, recordUpdatedTrigger as tt, IdPPermissionCondition as u, createWorkflow as ut, IncomingWebhookArgs as v, defineAuth as vt, incomingWebhookTrigger as w, IncomingWebhookResponseConfig as x, TailorField as xt, IncomingWebhookRequest as y, IdpName as yt, RecordDeletedArgs as z };
|
|
1123
|
-
//# sourceMappingURL=index-
|
|
1125
|
+
//# sourceMappingURL=index-UySZfxON.d.mts.map
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { t as TailorAuthconnectionAPI } from "./authconnection-
|
|
2
|
-
import { r as TailorContextAPI } from "./context-
|
|
3
|
-
import { u as TailorDBFileAPI } from "./file-
|
|
4
|
-
import { i as TailorIconvAPI } from "./iconv-
|
|
5
|
-
import { l as TailorIdpAPI } from "./idp-
|
|
6
|
-
import { t as TailorSecretmanagerAPI } from "./secretmanager-
|
|
7
|
-
import { n as TailorWorkflowAPI } from "./workflow-
|
|
1
|
+
import { t as TailorAuthconnectionAPI } from "./authconnection-TsdLYaLs.mjs";
|
|
2
|
+
import { r as TailorContextAPI } from "./context-CUBwSBq4.mjs";
|
|
3
|
+
import { u as TailorDBFileAPI } from "./file-DaCYOLPz.mjs";
|
|
4
|
+
import { i as TailorIconvAPI } from "./iconv-Chu6Hit2.mjs";
|
|
5
|
+
import { l as TailorIdpAPI } from "./idp-CbxR6A_0.mjs";
|
|
6
|
+
import { t as TailorSecretmanagerAPI } from "./secretmanager-BhpDmxwT.mjs";
|
|
7
|
+
import { n as TailorWorkflowAPI } from "./workflow-dYYH7QFa.mjs";
|
|
8
8
|
|
|
9
9
|
//#region src/runtime/index.d.ts
|
|
10
10
|
/** SQL command type recorded on a {@link TailordbQueryResult}. */
|
|
@@ -43,4 +43,4 @@ interface TailordbRuntime {
|
|
|
43
43
|
}
|
|
44
44
|
//#endregion
|
|
45
45
|
export { TailordbQueryResult as a, TailordbCommandType as i, TailordbClientConstructor as n, TailordbRuntime as o, TailordbClientInstance as r, TailorRuntime as t };
|
|
46
|
-
//# sourceMappingURL=index-
|
|
46
|
+
//# sourceMappingURL=index-wuuZLoFt.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interceptor-
|
|
1
|
+
{"version":3,"file":"interceptor-DOqRkCya.mjs","names":[],"sources":["../src/cli/telemetry/interceptor.ts"],"sourcesContent":["import { trace, SpanStatusCode } from \"@opentelemetry/api\";\nimport type { Interceptor } from \"@connectrpc/connect\";\n\n/**\n * Create a Connect-RPC interceptor that records OTLP spans for each RPC call.\n * When no TracerProvider is registered, the OTel API automatically provides\n * noop spans with zero overhead.\n * @returns Tracing interceptor\n */\nexport function createTracingInterceptor(): Interceptor {\n return (next) => async (req) => {\n const tracer = trace.getTracer(\"tailor-sdk\");\n\n return tracer.startActiveSpan(`rpc.${req.method.name}`, async (span) => {\n span.setAttribute(\"rpc.method\", req.method.name);\n span.setAttribute(\"rpc.service\", \"OperatorService\");\n span.setAttribute(\"rpc.system\", \"connect-rpc\");\n\n try {\n const response = await next(req);\n span.setStatus({ code: SpanStatusCode.OK });\n return response;\n } catch (error) {\n span.setStatus({ code: SpanStatusCode.ERROR });\n if (error instanceof Error) {\n span.recordException(error);\n }\n throw error;\n } finally {\n span.end();\n }\n });\n };\n}\n"],"mappings":";;;;;;;;;;AASA,SAAgB,2BAAwC;CACtD,QAAQ,SAAS,OAAO,QAAQ;EAG9B,OAFe,MAAM,UAAU,YAEnB,EAAE,gBAAgB,OAAO,IAAI,OAAO,QAAQ,OAAO,SAAS;GACtE,KAAK,aAAa,cAAc,IAAI,OAAO,IAAI;GAC/C,KAAK,aAAa,eAAe,iBAAiB;GAClD,KAAK,aAAa,cAAc,aAAa;GAE7C,IAAI;IACF,MAAM,WAAW,MAAM,KAAK,GAAG;IAC/B,KAAK,UAAU,EAAE,MAAM,eAAe,GAAG,CAAC;IAC1C,OAAO;GACT,SAAS,OAAO;IACd,KAAK,UAAU,EAAE,MAAM,eAAe,MAAM,CAAC;IAC7C,IAAI,iBAAiB,OACnB,KAAK,gBAAgB,KAAK;IAE5B,MAAM;GACR,UAAU;IACR,KAAK,IAAI;GACX;EACF,CAAC;CACH;AACF"}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
|
|
2
|
-
import { t as brandValue } from "./brand-
|
|
2
|
+
import { t as brandValue } from "./brand-DlnJ375c.mjs";
|
|
3
|
+
import { n as readWorkflowTestEnv } from "./test-env-key-CSnK4W1Y.mjs";
|
|
3
4
|
|
|
4
5
|
//#region src/configure/services/workflow/job.ts
|
|
5
6
|
/**
|
|
6
|
-
*
|
|
7
|
-
*
|
|
7
|
+
* Env-var fallback read by `.trigger()` when `workflowMock.setEnv()` is unset.
|
|
8
|
+
* Kept for backward compatibility.
|
|
9
|
+
* @deprecated Use `workflowMock.setEnv()` from `@tailor-platform/sdk/vitest`.
|
|
8
10
|
*/
|
|
9
11
|
const WORKFLOW_TEST_ENV_KEY = "TAILOR_TEST_WORKFLOW_ENV";
|
|
10
12
|
/**
|
|
@@ -46,8 +48,9 @@ function createWorkflowJob(config) {
|
|
|
46
48
|
return brandValue({
|
|
47
49
|
name: config.name,
|
|
48
50
|
trigger: async (args) => {
|
|
51
|
+
const fromGlobal = readWorkflowTestEnv();
|
|
49
52
|
return await body(args, {
|
|
50
|
-
env: JSON.parse(process.env["TAILOR_TEST_WORKFLOW_ENV"] || "{}"),
|
|
53
|
+
env: fromGlobal !== void 0 ? { ...fromGlobal } : JSON.parse(process.env["TAILOR_TEST_WORKFLOW_ENV"] || "{}"),
|
|
51
54
|
invoker: null
|
|
52
55
|
});
|
|
53
56
|
},
|
|
@@ -57,4 +60,4 @@ function createWorkflowJob(config) {
|
|
|
57
60
|
|
|
58
61
|
//#endregion
|
|
59
62
|
export { createWorkflowJob as n, WORKFLOW_TEST_ENV_KEY as t };
|
|
60
|
-
//# sourceMappingURL=job-
|
|
63
|
+
//# sourceMappingURL=job-CEAJLiGp.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"job-CEAJLiGp.mjs","names":[],"sources":["../src/configure/services/workflow/job.ts"],"sourcesContent":["import { brandValue } from \"@/utils/brand\";\nimport { readWorkflowTestEnv } from \"./test-env-key\";\nimport type { TailorEnv } from \"@/types/env\";\nimport type { JsonCompatible } from \"@/types/helpers\";\nimport type { TailorInvoker } from \"@/types/user\";\n\n/**\n * Context object passed as the second argument to workflow job body functions.\n */\nexport type WorkflowJobContext = {\n env: TailorEnv;\n invoker?: TailorInvoker;\n};\n\n/**\n * The body function type for a workflow job.\n * Resolves to the callable signature when `I` / `O` are JsonValue-compatible,\n * or to a template-literal error string that surfaces at the `body:` property.\n */\ntype JobBody<I, O> = [null] extends [I]\n ? \"ERROR: Input cannot be null at the top level\"\n : [I] extends [undefined]\n ? [O] extends [JsonCompatible<O> | undefined | void]\n ? (input: I, context: WorkflowJobContext) => O | Promise<O>\n : \"ERROR: Output must be JsonValue-compatible (plain objects/arrays; no class instances or functions)\"\n : [undefined] extends [I]\n ? \"ERROR: Input cannot include undefined at the top level\"\n : [I] extends [JsonCompatible<I>]\n ? [O] extends [JsonCompatible<O> | undefined | void]\n ? (input: I, context: WorkflowJobContext) => O | Promise<O>\n : \"ERROR: Output must be JsonValue-compatible (plain objects/arrays; no class instances or functions)\"\n : \"ERROR: Input must be JsonValue-compatible (plain objects/arrays; no class instances or functions)\";\n\n/**\n * WorkflowJob represents a job that can be triggered in a workflow.\n *\n * Type constraints:\n * - Input: Must be JsonValue-compatible (plain objects/arrays; no class instances or functions) or undefined.\n * - Output: Must be JsonValue-compatible (plain objects/arrays; no class instances or functions), undefined, or void.\n * - Trigger returns `Awaited<Output>` as-is (no Jsonify transformation).\n */\nexport interface WorkflowJob<Name extends string = string, Input = undefined, Output = undefined> {\n name: Name;\n /**\n * Trigger this job with the given input. Returns a Promise that resolves\n * to the job's output value.\n * @example\n * body: async (input) => {\n * const a = await jobA.trigger({ id: input.id });\n * const b = await jobB.trigger({ id: input.id });\n * return { a, b };\n * }\n */\n trigger: [Input] extends [undefined]\n ? () => Promise<Awaited<Output>>\n : (input: Input) => Promise<Awaited<Output>>;\n body: (input: Input, context: WorkflowJobContext) => Output | Promise<Output>;\n}\n\n/**\n * Env-var fallback read by `.trigger()` when `workflowMock.setEnv()` is unset.\n * Kept for backward compatibility.\n * @deprecated Use `workflowMock.setEnv()` from `@tailor-platform/sdk/vitest`.\n */\nexport const WORKFLOW_TEST_ENV_KEY = \"TAILOR_TEST_WORKFLOW_ENV\";\n\ninterface CreateWorkflowJobConfig<Name extends string, I, O> {\n readonly name: Name;\n readonly body: JobBody<I, O>;\n}\n\n/**\n * Create a workflow job definition.\n *\n * All jobs must be named exports from the workflow file.\n * Job names must be unique across the entire project.\n *\n * Input and output must be JsonValue-compatible (primitives, plain objects, arrays).\n * Functions and objects with a `toJSON` method are rejected at the type level;\n * class instances exposing methods are rejected via the property walk.\n * @param config - Job configuration with name and body function.\n * @param config.name - Unique job name across the project.\n * @param config.body - Async function that processes the job input.\n * @returns A WorkflowJob that can be triggered from other jobs.\n * @example\n * // Simple job with async body:\n * export const fetchData = createWorkflowJob({\n * name: \"fetch-data\",\n * body: async (input: { id: string }) => {\n * const db = getDB(\"tailordb\");\n * return await db.selectFrom(\"Table\").selectAll().where(\"id\", \"=\", input.id).executeTakeFirst();\n * },\n * });\n * @example\n * // Orchestrator job that fans out to other jobs.\n * export const orchestrate = createWorkflowJob({\n * name: \"orchestrate\",\n * body: async (input: { orderId: string }) => {\n * const inventory = await checkInventory.trigger({ orderId: input.orderId });\n * const payment = await processPayment.trigger({ orderId: input.orderId });\n * return { inventory, payment };\n * },\n * });\n */\n/* @__NO_SIDE_EFFECTS__ */\nexport function createWorkflowJob<const Name extends string, I = undefined, O = undefined>(\n config: CreateWorkflowJobConfig<Name, I, O>,\n): WorkflowJob<Name, I, Awaited<O>> {\n const body = config.body as (input: I, context: WorkflowJobContext) => O | Promise<O>;\n return brandValue(\n {\n name: config.name,\n trigger: async (args?: unknown) => {\n // Read env from workflowMock.setEnv() with deprecated env-var fallback.\n // Shallow-copy to isolate against cross-trigger mutation.\n const fromGlobal = readWorkflowTestEnv();\n const env = (\n fromGlobal !== undefined\n ? { ...fromGlobal }\n : JSON.parse(process.env[WORKFLOW_TEST_ENV_KEY] || \"{}\")\n ) as TailorEnv;\n return await body(args as I, { env, invoker: null });\n },\n body,\n } as WorkflowJob<Name, I, Awaited<O>>,\n \"workflow-job\",\n );\n}\n"],"mappings":";;;;;;;;;;AAgEA,MAAa,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyCrC,SAAgB,kBACd,QACkC;CAClC,MAAM,OAAO,OAAO;CACpB,OAAO,WACL;EACE,MAAM,OAAO;EACb,SAAS,OAAO,SAAmB;GAGjC,MAAM,aAAa,oBAAoB;GAMvC,OAAO,MAAM,KAAK,MAAW;IAAE,KAJ7B,eAAe,SACX,EAAE,GAAG,WAAW,IAChB,KAAK,MAAM,QAAQ,mCAA8B,IAAI;IAEvB,SAAS;GAAK,CAAC;EACrD;EACA;CACF,GACA,cACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["Kysely","TailordbDialect"],"sources":["../../src/kysely/index.ts"],"sourcesContent":["/**\n * Kysely integration module for generated TailorDB code.\n *\n * Re-exports kysely and function-kysely-tailordb types through a single import path\n * to avoid phantom dependency issues with pnpm, and provides namespace-aware\n * utility types and factory functions used by the code generator.\n */\n\nimport { TailordbDialect } from \"@tailor-platform/function-kysely-tailordb\";\nimport {\n type ColumnType,\n Kysely,\n type Insertable,\n type KyselyConfig,\n type Selectable,\n
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["Kysely","TailordbDialect"],"sources":["../../src/kysely/index.ts"],"sourcesContent":["/**\n * Kysely integration module for generated TailorDB code.\n *\n * Re-exports kysely and function-kysely-tailordb types through a single import path\n * to avoid phantom dependency issues with pnpm, and provides namespace-aware\n * utility types and factory functions used by the code generator.\n */\n\nimport { TailordbDialect } from \"@tailor-platform/function-kysely-tailordb\";\nimport {\n type ColumnType,\n Kysely,\n type Insertable,\n type KyselyConfig,\n type Selectable,\n type Transaction as KyselyTransaction,\n type Updateable,\n} from \"kysely\";\n\nexport {\n type ColumnType,\n Kysely,\n type KyselyConfig,\n type Transaction,\n type Insertable,\n type Selectable,\n sql,\n type Updateable,\n} from \"kysely\";\n\nexport { TailordbDialect } from \"@tailor-platform/function-kysely-tailordb\";\n\nexport type Timestamp = ColumnType<Date, Date | string, Date | string>;\ntype ResolveSelect<T> = T extends ColumnType<infer S, unknown, unknown> ? S : T;\ntype ResolveInsert<T> = T extends ColumnType<unknown, infer I, unknown> ? I : T;\ntype ResolveUpdate<T> = T extends ColumnType<unknown, unknown, infer U> ? U : T;\nexport type ObjectColumnType<T> = ColumnType<\n { [K in keyof T]-?: Exclude<ResolveSelect<T[K]>, undefined> },\n { [K in keyof T]: ResolveInsert<T[K]> },\n { [K in keyof T]: ResolveUpdate<T[K]> }\n>;\nexport type ArrayColumnType<T> = ColumnType<\n ResolveSelect<T>[],\n ResolveInsert<T>[],\n ResolveUpdate<T>[]\n>;\nexport type Generated<T> =\n T extends ColumnType<infer S, infer I, infer U>\n ? ColumnType<S, I | undefined, U>\n : ColumnType<T, T | undefined, T>;\nexport type Serial<T = string | number> = ColumnType<T, never, never>;\n\nexport type TailordbKysely<DB> = Kysely<DB>;\nexport type NamespaceDB<NS, N extends keyof NS = keyof NS> = TailordbKysely<NS[N]>;\n\n/**\n * Create a namespace-aware getDB function for generated code.\n * @returns A getDB function that creates Kysely instances for specific namespaces\n */\nexport function createGetDB<NS>() {\n return function getDB<const N extends keyof NS & string>(\n namespace: N,\n config?: Omit<KyselyConfig, \"dialect\">,\n ): TailordbKysely<NS[N]> {\n const client = new tailordb.Client({ namespace });\n return new Kysely<NS[N]>({\n dialect: new TailordbDialect(client),\n ...config,\n });\n };\n}\n\nexport type NamespaceTransaction<NS, K extends keyof NS | TailordbKysely<NS[keyof NS]> = keyof NS> =\n K extends TailordbKysely<infer DB>\n ? KyselyTransaction<DB>\n : K extends keyof NS\n ? KyselyTransaction<NS[K]>\n : never;\n\nexport type NamespaceTableName<NS> = {\n [N in keyof NS]: keyof NS[N];\n}[keyof NS];\n\nexport type NamespaceTable<NS, T extends NamespaceTableName<NS>> = {\n [N in keyof NS]: T extends keyof NS[N] ? NS[N][T] : never;\n}[keyof NS];\n\nexport type NamespaceInsertable<NS, T extends NamespaceTableName<NS>> = Insertable<\n NamespaceTable<NS, T>\n>;\nexport type NamespaceSelectable<NS, T extends NamespaceTableName<NS>> = Selectable<\n NamespaceTable<NS, T>\n>;\nexport type NamespaceUpdateable<NS, T extends NamespaceTableName<NS>> = Updateable<\n NamespaceTable<NS, T>\n>;\n"],"mappings":";;;;;;;;;;;;;;;;AA2DA,SAAgB,cAAkB;CAChC,OAAO,SAAS,MACd,WACA,QACuB;EAEvB,OAAO,IAAIA,SAAc;GACvB,SAAS,IAAIC,kBAAgB,IAFZ,SAAS,OAAO,EAAE,UAAU,CAEX,CAAC;GACnC,GAAG;EACL,CAAC;CACH;AACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
import { t as multiline } from "./multiline-
|
|
2
|
+
import { t as multiline } from "./multiline-Cf9ODpr1.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/plugin/builtin/kysely-type/type-processor.ts
|
|
5
5
|
/**
|
|
@@ -272,4 +272,4 @@ function kyselyTypePlugin(options) {
|
|
|
272
272
|
|
|
273
273
|
//#endregion
|
|
274
274
|
export { kyselyTypePlugin as n, KyselyGeneratorID as t };
|
|
275
|
-
//# sourceMappingURL=kysely-type-
|
|
275
|
+
//# sourceMappingURL=kysely-type-D1e0Vwkd.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kysely-type-BUoVDC5r.mjs","names":[],"sources":["../src/plugin/builtin/kysely-type/type-processor.ts","../src/plugin/builtin/kysely-type/index.ts"],"sourcesContent":["import multiline from \"@/utils/multiline\";\nimport { type KyselyNamespaceMetadata, type KyselyTypeMetadata } from \"./types\";\nimport type { OperatorFieldConfig, TailorDBType } from \"@/types/tailordb\";\n\ntype UsedUtilityTypes = { Timestamp: boolean; Serial: boolean };\n\ntype FieldTypeResult = {\n type: string;\n usedUtilityTypes: UsedUtilityTypes;\n};\n\n/**\n * Get the enum type definition.\n * @param fieldConfig - The field configuration\n * @returns The enum type as a string union\n */\nfunction getEnumType(fieldConfig: OperatorFieldConfig): string {\n const allowedValues = fieldConfig.allowedValues;\n\n if (allowedValues && Array.isArray(allowedValues)) {\n return allowedValues\n .map((v: string | { value: string }) => {\n const value = typeof v === \"string\" ? v : v.value;\n return `\"${value}\"`;\n })\n .join(\" | \");\n }\n return \"string\";\n}\n\n/**\n * Get the nested object type definition.\n * @param fieldConfig - The field configuration\n * @returns The nested type with used utility types\n */\nfunction getNestedType(fieldConfig: OperatorFieldConfig): FieldTypeResult {\n const fields = fieldConfig.fields;\n if (!fields || typeof fields !== \"object\") {\n return {\n type: \"string\",\n usedUtilityTypes: { Timestamp: false, Serial: false },\n };\n }\n\n const fieldResults = Object.entries(fields).map(([fieldName, config]) => {\n const result = generateFieldType(config);\n const optional = config.required !== true ? \"?\" : \"\";\n return {\n fieldType: `${fieldName}${optional}: ${result.type}`,\n usedUtilityTypes: result.usedUtilityTypes,\n };\n });\n\n const aggregatedUtilityTypes = fieldResults.reduce(\n (acc, result) => ({\n Timestamp: acc.Timestamp || result.usedUtilityTypes.Timestamp,\n Serial: acc.Serial || result.usedUtilityTypes.Serial,\n }),\n { Timestamp: false, Serial: false },\n );\n\n const fieldTypes = fieldResults.map((r) => r.fieldType);\n const obj = `{\\n ${fieldTypes.join(\";\\n \")}${fieldTypes.length > 0 ? \";\" : \"\"}\\n}`;\n\n const hasOptionalFields = Object.values(fields).some((config) => config.required !== true);\n if (aggregatedUtilityTypes.Timestamp || hasOptionalFields) {\n return { type: `ObjectColumnType<${obj}>`, usedUtilityTypes: aggregatedUtilityTypes };\n }\n return { type: obj, usedUtilityTypes: aggregatedUtilityTypes };\n}\n\n/**\n * Get the base Kysely type for a field (without array/null modifiers).\n * @param fieldConfig - The field configuration\n * @returns The base type with used utility types\n */\nfunction getBaseType(fieldConfig: OperatorFieldConfig): FieldTypeResult {\n const fieldType = fieldConfig.type;\n const usedUtilityTypes = { Timestamp: false, Serial: false };\n\n let type: string;\n switch (fieldType) {\n case \"uuid\":\n case \"string\":\n case \"decimal\":\n type = \"string\";\n break;\n case \"integer\":\n case \"float\":\n type = \"number\";\n break;\n case \"date\":\n case \"datetime\":\n usedUtilityTypes.Timestamp = true;\n type = \"Timestamp\";\n break;\n case \"bool\":\n case \"boolean\":\n type = \"boolean\";\n break;\n case \"enum\":\n type = getEnumType(fieldConfig);\n break;\n case \"nested\": {\n const nestedResult = getNestedType(fieldConfig);\n return nestedResult;\n }\n default:\n type = \"string\";\n break;\n }\n\n return { type, usedUtilityTypes };\n}\n\n/**\n * Generate the complete field type including array and null modifiers.\n * @param fieldConfig - The field configuration\n * @returns The complete field type with used utility types\n */\nfunction generateFieldType(fieldConfig: OperatorFieldConfig): FieldTypeResult {\n const baseTypeResult = getBaseType(fieldConfig);\n const usedUtilityTypes = { ...baseTypeResult.usedUtilityTypes };\n\n const isArray = fieldConfig.array === true;\n const isNullable = fieldConfig.required !== true;\n\n // Types that use ColumnType internally (Timestamp, ObjectColumnType) cannot be\n // directly wrapped with [] for arrays, because Kysely only resolves ColumnType at\n // the top-level table property. Use ArrayColumnType/ObjectArrayColumnType to keep\n // the ColumnType at the top level with arrays inside.\n const columnTypeBaseTypes = new Set([\"Timestamp\"]);\n const isColumnTypeBase = columnTypeBaseTypes.has(baseTypeResult.type);\n\n let finalType = baseTypeResult.type;\n if (isArray) {\n if (isColumnTypeBase || finalType.startsWith(\"ObjectColumnType<\")) {\n finalType = `ArrayColumnType<${baseTypeResult.type}>`;\n } else {\n const needsParens = fieldConfig.type === \"enum\";\n finalType = needsParens ? `(${baseTypeResult.type})[]` : `${baseTypeResult.type}[]`;\n }\n }\n if (isNullable) {\n finalType = `${finalType} | null`;\n }\n\n if (fieldConfig.serial) {\n usedUtilityTypes.Serial = true;\n finalType = `Serial<${finalType}>`;\n }\n if (fieldConfig.hooks?.create) {\n finalType = `Generated<${finalType}>`;\n }\n\n return { type: finalType, usedUtilityTypes };\n}\n\n/**\n * Generate the table interface.\n * @param type - The parsed TailorDB type\n * @returns The type definition and used utility types\n */\nfunction generateTableInterface(type: TailorDBType): {\n typeDef: string;\n usedUtilityTypes: UsedUtilityTypes;\n} {\n const fieldEntries = Object.entries(type.fields).filter(([fieldName]) => fieldName !== \"id\");\n\n const fieldResults = fieldEntries.map(([fieldName, parsedField]) => ({\n fieldName,\n ...generateFieldType(parsedField.config),\n }));\n\n const fields = [\n \"id: Generated<string>;\",\n ...fieldResults.map((result) => `${result.fieldName}: ${result.type};`),\n ];\n\n const aggregatedUtilityTypes = fieldResults.reduce(\n (acc, result) => ({\n Timestamp: acc.Timestamp || result.usedUtilityTypes.Timestamp,\n\n Serial: acc.Serial || result.usedUtilityTypes.Serial,\n }),\n { Timestamp: false, Serial: false },\n );\n\n const typeDef = multiline /* ts */ `\n ${type.name}: {\n ${fields.join(\"\\n\")}\n }\n `;\n\n return { typeDef, usedUtilityTypes: aggregatedUtilityTypes };\n}\n\n/**\n * Convert a TailorDBType into KyselyTypeMetadata.\n * @param type - Parsed TailorDB type\n * @returns Generated Kysely type metadata\n */\nexport async function processKyselyType(type: TailorDBType): Promise<KyselyTypeMetadata> {\n const result = generateTableInterface(type);\n\n return {\n name: type.name,\n typeDef: result.typeDef,\n usedUtilityTypes: result.usedUtilityTypes,\n };\n}\n\n/**\n * Generate unified types file from multiple namespaces.\n * @param namespaceData - Namespace metadata\n * @returns Generated types file contents\n */\nexport function generateUnifiedKyselyTypes(namespaceData: KyselyNamespaceMetadata[]): string {\n if (namespaceData.length === 0) {\n return \"\";\n }\n\n // Aggregate used utility types from all namespaces\n const globalUsedUtilityTypes = namespaceData.reduce(\n (acc, ns) => ({\n Timestamp: acc.Timestamp || ns.usedUtilityTypes.Timestamp,\n Serial: acc.Serial || ns.usedUtilityTypes.Serial,\n }),\n { Timestamp: false, Serial: false },\n );\n\n const utilityTypeImports: string[] = [\"type Generated\"];\n if (globalUsedUtilityTypes.Timestamp) {\n utilityTypeImports.push(\"type Timestamp\");\n }\n const hasObjectColumnType = namespaceData.some((ns) =>\n ns.types.some((t) => t.typeDef.includes(\"ObjectColumnType<\")),\n );\n if (hasObjectColumnType) {\n utilityTypeImports.push(\"type ObjectColumnType\");\n }\n const hasArrayColumnType = namespaceData.some((ns) =>\n ns.types.some((t) => t.typeDef.includes(\"ArrayColumnType<\")),\n );\n if (hasArrayColumnType) {\n utilityTypeImports.push(\"type ArrayColumnType\");\n }\n if (globalUsedUtilityTypes.Serial) {\n utilityTypeImports.push(\"type Serial\");\n }\n\n const importsSection = multiline /* ts */ `\n import {\n createGetDB,\n ${utilityTypeImports.join(\",\\n\")},\n type NamespaceDB,\n type NamespaceInsertable,\n type NamespaceSelectable,\n type NamespaceTable,\n type NamespaceTableName,\n type NamespaceTransaction,\n type NamespaceUpdateable,\n } from \"@tailor-platform/sdk/kysely\";\n `;\n\n // Generate Namespace interface with multiple namespaces\n const namespaceInterfaces = namespaceData\n .map(({ namespace, types }) => {\n const typeDefsWithIndent = types\n .map((type) => {\n return type.typeDef\n .split(\"\\n\")\n .map((line) => (line.trim() ? ` ${line}` : \"\"))\n .join(\"\\n\");\n })\n .join(\"\\n\\n\");\n\n return ` \"${namespace}\": {\\n${typeDefsWithIndent}\\n }`;\n })\n .join(\",\\n\");\n\n const namespaceInterface = `export interface Namespace {\\n${namespaceInterfaces}\\n}`;\n\n const getDBFunction = multiline /* ts */ `\n export const getDB = createGetDB<Namespace>();\n\n export type DB<N extends keyof Namespace = keyof Namespace> = NamespaceDB<Namespace, N>;\n `;\n\n const utilityTypeExports = multiline /* ts */ `\n export type Transaction<K extends keyof Namespace | DB = keyof Namespace> =\n NamespaceTransaction<Namespace, K>;\n\n type TableName = NamespaceTableName<Namespace>;\n export type Table<T extends TableName> = NamespaceTable<Namespace, T>;\n\n export type Insertable<T extends TableName> = NamespaceInsertable<Namespace, T>;\n export type Selectable<T extends TableName> = NamespaceSelectable<Namespace, T>;\n export type Updateable<T extends TableName> = NamespaceUpdateable<Namespace, T>;\n `;\n\n return (\n [importsSection, namespaceInterface, getDBFunction, utilityTypeExports].join(\"\\n\\n\") + \"\\n\"\n );\n}\n","import { processKyselyType, generateUnifiedKyselyTypes } from \"./type-processor\";\nimport type { KyselyTypeMetadata, KyselyNamespaceMetadata } from \"./types\";\nimport type { Plugin } from \"@/types/plugin\";\nimport type { GeneratorResult, TailorDBReadyContext } from \"@/types/plugin-generation\";\n\n/** Unique identifier for the Kysely type generator plugin. */\nexport const KyselyGeneratorID = \"@tailor-platform/kysely-type\";\n\ntype KyselyTypePluginOptions = {\n distPath: string;\n};\n\n/**\n * Plugin that generates Kysely type definitions for TailorDB types.\n * @param options - Plugin options\n * @param options.distPath - Output file path for generated types\n * @returns Plugin instance with onTailorDBReady hook\n */\nexport function kyselyTypePlugin(\n options: KyselyTypePluginOptions,\n): Plugin<unknown, KyselyTypePluginOptions> {\n return {\n id: KyselyGeneratorID,\n description: \"Generates Kysely type definitions for TailorDB types\",\n pluginConfig: options,\n\n async onTailorDBReady(\n ctx: TailorDBReadyContext<KyselyTypePluginOptions>,\n ): Promise<GeneratorResult> {\n const allNamespaceData: KyselyNamespaceMetadata[] = [];\n\n for (const ns of ctx.tailordb) {\n const typeMetadataList: KyselyTypeMetadata[] = [];\n\n for (const type of Object.values(ns.types)) {\n const metadata = await processKyselyType(type);\n typeMetadataList.push(metadata);\n }\n\n if (typeMetadataList.length === 0) continue;\n\n const usedUtilityTypes = typeMetadataList.reduce(\n (acc, type) => ({\n Timestamp: acc.Timestamp || type.usedUtilityTypes.Timestamp,\n Serial: acc.Serial || type.usedUtilityTypes.Serial,\n }),\n { Timestamp: false, Serial: false },\n );\n\n allNamespaceData.push({\n namespace: ns.namespace,\n types: typeMetadataList,\n usedUtilityTypes,\n });\n }\n\n const files: GeneratorResult[\"files\"] = [];\n if (allNamespaceData.length > 0) {\n const content = generateUnifiedKyselyTypes(allNamespaceData);\n files.push({\n path: ctx.pluginConfig.distPath,\n content,\n });\n }\n\n return { files };\n },\n };\n}\n"],"mappings":";;;;;;;;;AAgBA,SAAS,YAAY,aAA0C;CAC7D,MAAM,gBAAgB,YAAY;CAElC,IAAI,iBAAiB,MAAM,QAAQ,aAAa,GAC9C,OAAO,cACJ,KAAK,MAAkC;EAEtC,OAAO,IADO,OAAO,MAAM,WAAW,IAAI,EAAE,MAC3B;CACnB,CAAC,EACA,KAAK,KAAK;CAEf,OAAO;AACT;;;;;;AAOA,SAAS,cAAc,aAAmD;CACxE,MAAM,SAAS,YAAY;CAC3B,IAAI,CAAC,UAAU,OAAO,WAAW,UAC/B,OAAO;EACL,MAAM;EACN,kBAAkB;GAAE,WAAW;GAAO,QAAQ;EAAM;CACtD;CAGF,MAAM,eAAe,OAAO,QAAQ,MAAM,EAAE,KAAK,CAAC,WAAW,YAAY;EACvE,MAAM,SAAS,kBAAkB,MAAM;EAEvC,OAAO;GACL,WAAW,GAAG,YAFC,OAAO,aAAa,OAAO,MAAM,GAEb,IAAI,OAAO;GAC9C,kBAAkB,OAAO;EAC3B;CACF,CAAC;CAED,MAAM,yBAAyB,aAAa,QACzC,KAAK,YAAY;EAChB,WAAW,IAAI,aAAa,OAAO,iBAAiB;EACpD,QAAQ,IAAI,UAAU,OAAO,iBAAiB;CAChD,IACA;EAAE,WAAW;EAAO,QAAQ;CAAM,CACpC;CAEA,MAAM,aAAa,aAAa,KAAK,MAAM,E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AiB;KAClD,QAAQ,IAAI,UAAU,KAAK,iBAAiB;IAC9C,IACA;KAAE,WAAW;KAAO,QAAQ;IAAM,CACpC;IAEA,iBAAiB,KAAK;KACpB,WAAW,GAAG;KACd,OAAO;KACP;IACF,CAAC;GACH;GAEA,MAAM,QAAkC,CAAC;GACzC,IAAI,iBAAiB,SAAS,GAAG;IAC/B,MAAM,UAAU,2BAA2B,gBAAgB;IAC3D,MAAM,KAAK;KACT,MAAM,IAAI,aAAa;KACvB;IACF,CAAC;GACH;GAEA,OAAO,EAAE,MAAM;EACjB;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"kysely-type-D1e0Vwkd.mjs","names":[],"sources":["../src/plugin/builtin/kysely-type/type-processor.ts","../src/plugin/builtin/kysely-type/index.ts"],"sourcesContent":["import multiline from \"@/utils/multiline\";\nimport { type KyselyNamespaceMetadata, type KyselyTypeMetadata } from \"./types\";\nimport type { OperatorFieldConfig, TailorDBType } from \"@/types/tailordb\";\n\ntype UsedUtilityTypes = { Timestamp: boolean; Serial: boolean };\n\ntype FieldTypeResult = {\n type: string;\n usedUtilityTypes: UsedUtilityTypes;\n};\n\n/**\n * Get the enum type definition.\n * @param fieldConfig - The field configuration\n * @returns The enum type as a string union\n */\nfunction getEnumType(fieldConfig: OperatorFieldConfig): string {\n const allowedValues = fieldConfig.allowedValues;\n\n if (allowedValues && Array.isArray(allowedValues)) {\n return allowedValues\n .map((v: string | { value: string }) => {\n const value = typeof v === \"string\" ? v : v.value;\n return `\"${value}\"`;\n })\n .join(\" | \");\n }\n return \"string\";\n}\n\n/**\n * Get the nested object type definition.\n * @param fieldConfig - The field configuration\n * @returns The nested type with used utility types\n */\nfunction getNestedType(fieldConfig: OperatorFieldConfig): FieldTypeResult {\n const fields = fieldConfig.fields;\n if (!fields || typeof fields !== \"object\") {\n return {\n type: \"string\",\n usedUtilityTypes: { Timestamp: false, Serial: false },\n };\n }\n\n const fieldResults = Object.entries(fields).map(([fieldName, config]) => {\n const result = generateFieldType(config);\n const optional = config.required !== true ? \"?\" : \"\";\n return {\n fieldType: `${fieldName}${optional}: ${result.type}`,\n usedUtilityTypes: result.usedUtilityTypes,\n };\n });\n\n const aggregatedUtilityTypes = fieldResults.reduce(\n (acc, result) => ({\n Timestamp: acc.Timestamp || result.usedUtilityTypes.Timestamp,\n Serial: acc.Serial || result.usedUtilityTypes.Serial,\n }),\n { Timestamp: false, Serial: false },\n );\n\n const fieldTypes = fieldResults.map((r) => r.fieldType);\n const obj = `{\\n ${fieldTypes.join(\";\\n \")}${fieldTypes.length > 0 ? \";\" : \"\"}\\n}`;\n\n const hasOptionalFields = Object.values(fields).some((config) => config.required !== true);\n if (aggregatedUtilityTypes.Timestamp || hasOptionalFields) {\n return { type: `ObjectColumnType<${obj}>`, usedUtilityTypes: aggregatedUtilityTypes };\n }\n return { type: obj, usedUtilityTypes: aggregatedUtilityTypes };\n}\n\n/**\n * Get the base Kysely type for a field (without array/null modifiers).\n * @param fieldConfig - The field configuration\n * @returns The base type with used utility types\n */\nfunction getBaseType(fieldConfig: OperatorFieldConfig): FieldTypeResult {\n const fieldType = fieldConfig.type;\n const usedUtilityTypes = { Timestamp: false, Serial: false };\n\n let type: string;\n switch (fieldType) {\n case \"uuid\":\n case \"string\":\n case \"decimal\":\n type = \"string\";\n break;\n case \"integer\":\n case \"float\":\n type = \"number\";\n break;\n case \"date\":\n case \"datetime\":\n usedUtilityTypes.Timestamp = true;\n type = \"Timestamp\";\n break;\n case \"bool\":\n case \"boolean\":\n type = \"boolean\";\n break;\n case \"enum\":\n type = getEnumType(fieldConfig);\n break;\n case \"nested\": {\n const nestedResult = getNestedType(fieldConfig);\n return nestedResult;\n }\n default:\n type = \"string\";\n break;\n }\n\n return { type, usedUtilityTypes };\n}\n\n/**\n * Generate the complete field type including array and null modifiers.\n * @param fieldConfig - The field configuration\n * @returns The complete field type with used utility types\n */\nfunction generateFieldType(fieldConfig: OperatorFieldConfig): FieldTypeResult {\n const baseTypeResult = getBaseType(fieldConfig);\n const usedUtilityTypes = { ...baseTypeResult.usedUtilityTypes };\n\n const isArray = fieldConfig.array === true;\n const isNullable = fieldConfig.required !== true;\n\n // Types that use ColumnType internally (Timestamp, ObjectColumnType) cannot be\n // directly wrapped with [] for arrays, because Kysely only resolves ColumnType at\n // the top-level table property. Use ArrayColumnType/ObjectArrayColumnType to keep\n // the ColumnType at the top level with arrays inside.\n const columnTypeBaseTypes = new Set([\"Timestamp\"]);\n const isColumnTypeBase = columnTypeBaseTypes.has(baseTypeResult.type);\n\n let finalType = baseTypeResult.type;\n if (isArray) {\n if (isColumnTypeBase || finalType.startsWith(\"ObjectColumnType<\")) {\n finalType = `ArrayColumnType<${baseTypeResult.type}>`;\n } else {\n const needsParens = fieldConfig.type === \"enum\";\n finalType = needsParens ? `(${baseTypeResult.type})[]` : `${baseTypeResult.type}[]`;\n }\n }\n if (isNullable) {\n finalType = `${finalType} | null`;\n }\n\n if (fieldConfig.serial) {\n usedUtilityTypes.Serial = true;\n finalType = `Serial<${finalType}>`;\n }\n if (fieldConfig.hooks?.create) {\n finalType = `Generated<${finalType}>`;\n }\n\n return { type: finalType, usedUtilityTypes };\n}\n\n/**\n * Generate the table interface.\n * @param type - The parsed TailorDB type\n * @returns The type definition and used utility types\n */\nfunction generateTableInterface(type: TailorDBType): {\n typeDef: string;\n usedUtilityTypes: UsedUtilityTypes;\n} {\n const fieldEntries = Object.entries(type.fields).filter(([fieldName]) => fieldName !== \"id\");\n\n const fieldResults = fieldEntries.map(([fieldName, parsedField]) => ({\n fieldName,\n ...generateFieldType(parsedField.config),\n }));\n\n const fields = [\n \"id: Generated<string>;\",\n ...fieldResults.map((result) => `${result.fieldName}: ${result.type};`),\n ];\n\n const aggregatedUtilityTypes = fieldResults.reduce(\n (acc, result) => ({\n Timestamp: acc.Timestamp || result.usedUtilityTypes.Timestamp,\n\n Serial: acc.Serial || result.usedUtilityTypes.Serial,\n }),\n { Timestamp: false, Serial: false },\n );\n\n const typeDef = multiline /* ts */ `\n ${type.name}: {\n ${fields.join(\"\\n\")}\n }\n `;\n\n return { typeDef, usedUtilityTypes: aggregatedUtilityTypes };\n}\n\n/**\n * Convert a TailorDBType into KyselyTypeMetadata.\n * @param type - Parsed TailorDB type\n * @returns Generated Kysely type metadata\n */\nexport async function processKyselyType(type: TailorDBType): Promise<KyselyTypeMetadata> {\n const result = generateTableInterface(type);\n\n return {\n name: type.name,\n typeDef: result.typeDef,\n usedUtilityTypes: result.usedUtilityTypes,\n };\n}\n\n/**\n * Generate unified types file from multiple namespaces.\n * @param namespaceData - Namespace metadata\n * @returns Generated types file contents\n */\nexport function generateUnifiedKyselyTypes(namespaceData: KyselyNamespaceMetadata[]): string {\n if (namespaceData.length === 0) {\n return \"\";\n }\n\n // Aggregate used utility types from all namespaces\n const globalUsedUtilityTypes = namespaceData.reduce(\n (acc, ns) => ({\n Timestamp: acc.Timestamp || ns.usedUtilityTypes.Timestamp,\n Serial: acc.Serial || ns.usedUtilityTypes.Serial,\n }),\n { Timestamp: false, Serial: false },\n );\n\n const utilityTypeImports: string[] = [\"type Generated\"];\n if (globalUsedUtilityTypes.Timestamp) {\n utilityTypeImports.push(\"type Timestamp\");\n }\n const hasObjectColumnType = namespaceData.some((ns) =>\n ns.types.some((t) => t.typeDef.includes(\"ObjectColumnType<\")),\n );\n if (hasObjectColumnType) {\n utilityTypeImports.push(\"type ObjectColumnType\");\n }\n const hasArrayColumnType = namespaceData.some((ns) =>\n ns.types.some((t) => t.typeDef.includes(\"ArrayColumnType<\")),\n );\n if (hasArrayColumnType) {\n utilityTypeImports.push(\"type ArrayColumnType\");\n }\n if (globalUsedUtilityTypes.Serial) {\n utilityTypeImports.push(\"type Serial\");\n }\n\n const importsSection = multiline /* ts */ `\n import {\n createGetDB,\n ${utilityTypeImports.join(\",\\n\")},\n type NamespaceDB,\n type NamespaceInsertable,\n type NamespaceSelectable,\n type NamespaceTable,\n type NamespaceTableName,\n type NamespaceTransaction,\n type NamespaceUpdateable,\n } from \"@tailor-platform/sdk/kysely\";\n `;\n\n // Generate Namespace interface with multiple namespaces\n const namespaceInterfaces = namespaceData\n .map(({ namespace, types }) => {\n const typeDefsWithIndent = types\n .map((type) => {\n return type.typeDef\n .split(\"\\n\")\n .map((line) => (line.trim() ? ` ${line}` : \"\"))\n .join(\"\\n\");\n })\n .join(\"\\n\\n\");\n\n return ` \"${namespace}\": {\\n${typeDefsWithIndent}\\n }`;\n })\n .join(\",\\n\");\n\n const namespaceInterface = `export interface Namespace {\\n${namespaceInterfaces}\\n}`;\n\n const getDBFunction = multiline /* ts */ `\n export const getDB = createGetDB<Namespace>();\n\n export type DB<N extends keyof Namespace = keyof Namespace> = NamespaceDB<Namespace, N>;\n `;\n\n const utilityTypeExports = multiline /* ts */ `\n export type Transaction<K extends keyof Namespace | DB = keyof Namespace> =\n NamespaceTransaction<Namespace, K>;\n\n type TableName = NamespaceTableName<Namespace>;\n export type Table<T extends TableName> = NamespaceTable<Namespace, T>;\n\n export type Insertable<T extends TableName> = NamespaceInsertable<Namespace, T>;\n export type Selectable<T extends TableName> = NamespaceSelectable<Namespace, T>;\n export type Updateable<T extends TableName> = NamespaceUpdateable<Namespace, T>;\n `;\n\n return (\n [importsSection, namespaceInterface, getDBFunction, utilityTypeExports].join(\"\\n\\n\") + \"\\n\"\n );\n}\n","import { processKyselyType, generateUnifiedKyselyTypes } from \"./type-processor\";\nimport type { KyselyTypeMetadata, KyselyNamespaceMetadata } from \"./types\";\nimport type { Plugin } from \"@/types/plugin\";\nimport type { GeneratorResult, TailorDBReadyContext } from \"@/types/plugin-generation\";\n\n/** Unique identifier for the Kysely type generator plugin. */\nexport const KyselyGeneratorID = \"@tailor-platform/kysely-type\";\n\ntype KyselyTypePluginOptions = {\n distPath: string;\n};\n\n/**\n * Plugin that generates Kysely type definitions for TailorDB types.\n * @param options - Plugin options\n * @param options.distPath - Output file path for generated types\n * @returns Plugin instance with onTailorDBReady hook\n */\nexport function kyselyTypePlugin(\n options: KyselyTypePluginOptions,\n): Plugin<unknown, KyselyTypePluginOptions> {\n return {\n id: KyselyGeneratorID,\n description: \"Generates Kysely type definitions for TailorDB types\",\n pluginConfig: options,\n\n async onTailorDBReady(\n ctx: TailorDBReadyContext<KyselyTypePluginOptions>,\n ): Promise<GeneratorResult> {\n const allNamespaceData: KyselyNamespaceMetadata[] = [];\n\n for (const ns of ctx.tailordb) {\n const typeMetadataList: KyselyTypeMetadata[] = [];\n\n for (const type of Object.values(ns.types)) {\n const metadata = await processKyselyType(type);\n typeMetadataList.push(metadata);\n }\n\n if (typeMetadataList.length === 0) continue;\n\n const usedUtilityTypes = typeMetadataList.reduce(\n (acc, type) => ({\n Timestamp: acc.Timestamp || type.usedUtilityTypes.Timestamp,\n Serial: acc.Serial || type.usedUtilityTypes.Serial,\n }),\n { Timestamp: false, Serial: false },\n );\n\n allNamespaceData.push({\n namespace: ns.namespace,\n types: typeMetadataList,\n usedUtilityTypes,\n });\n }\n\n const files: GeneratorResult[\"files\"] = [];\n if (allNamespaceData.length > 0) {\n const content = generateUnifiedKyselyTypes(allNamespaceData);\n files.push({\n path: ctx.pluginConfig.distPath,\n content,\n });\n }\n\n return { files };\n },\n };\n}\n"],"mappings":";;;;;;;;;AAgBA,SAAS,YAAY,aAA0C;CAC7D,MAAM,gBAAgB,YAAY;CAElC,IAAI,iBAAiB,MAAM,QAAQ,aAAa,GAC9C,OAAO,cACJ,KAAK,MAAkC;EAEtC,OAAO,IADO,OAAO,MAAM,WAAW,IAAI,EAAE,MAC3B;CACnB,CAAC,EACA,KAAK,KAAK;CAEf,OAAO;AACT;;;;;;AAOA,SAAS,cAAc,aAAmD;CACxE,MAAM,SAAS,YAAY;CAC3B,IAAI,CAAC,UAAU,OAAO,WAAW,UAC/B,OAAO;EACL,MAAM;EACN,kBAAkB;GAAE,WAAW;GAAO,QAAQ;EAAM;CACtD;CAGF,MAAM,eAAe,OAAO,QAAQ,MAAM,EAAE,KAAK,CAAC,WAAW,YAAY;EACvE,MAAM,SAAS,kBAAkB,MAA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AAM,mBAA8C,CAAC;GAErD,KAAK,MAAM,MAAM,IAAI,UAAU;IAC7B,MAAM,mBAAyC,CAAC;IAEhD,KAAK,MAAM,QAAQ,OAAO,OAAO,GAAG,KAAK,GAAG;KAC1C,MAAM,WAAW,MAAM,kBAAkB,IAAI;KAC7C,iBAAiB,KAAK,QAAQ;IAChC;IAEA,IAAI,iBAAiB,WAAW,GAAG;IAEnC,MAAM,mBAAmB,iBAAiB,QACvC,KAAK,UAAU;KACd,WAAW,IAAI,aAAa,KAAK,iBAAiB;KAClD,QAAQ,IAAI,UAAU,KAAK,iBAAiB;IAC9C,IACA;KAAE,WAAW;KAAO,QAAQ;IAAM,CACpC;IAEA,iBAAiB,KAAK;KACpB,WAAW,GAAG;KACd,OAAO;KACP;IACF,CAAC;GACH;GAEA,MAAM,QAAkC,CAAC;GACzC,IAAI,iBAAiB,SAAS,GAAG;IAC/B,MAAM,UAAU,2BAA2B,gBAAgB;IAC3D,MAAM,KAAK;KACT,MAAM,IAAI,aAAa;KACvB;IACF,CAAC;GACH;GAEA,OAAO,EAAE,MAAM;EACjB;CACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger-B1g4I9wT.mjs","names":[],"sources":["../src/cli/shared/parse-boolean.ts","../src/cli/shared/logger.ts"],"sourcesContent":["const TRUTHY_VALUES = new Set([\"true\", \"t\", \"yes\", \"y\", \"on\", \"1\"]);\nconst FALSY_VALUES = new Set([\"false\", \"f\", \"no\", \"n\", \"off\", \"0\"]);\n\n/**\n * Parse a string value as a boolean.\n *\n * Recognized values (case-insensitive, trimmed) follow Python's\n * `distutils.util.strtobool` convention:\n * - truthy: `true, t, yes, y, on, 1`\n * - falsy: `false, f, no, n, off, 0`\n *\n * Undefined, empty strings, and unrecognized values return `undefined` so\n * that callers can fall back to their own defaults.\n * @param value - The input string (e.g. an environment variable or CLI flag value)\n * @returns `true`, `false`, or `undefined` when the value is unset or unrecognized\n */\nexport function parseBoolean(value: string | undefined): boolean | undefined {\n if (value === undefined) return undefined;\n const normalized = value.trim().toLowerCase();\n if (normalized === \"\") return undefined;\n if (TRUTHY_VALUES.has(normalized)) return true;\n if (FALSY_VALUES.has(normalized)) return false;\n return undefined;\n}\n","import { formatWithOptions, type InspectOptions } from \"node:util\";\nimport chalk from \"chalk\";\nimport { formatDistanceToNowStrict } from \"date-fns\";\nimport { getBorderCharacters, table } from \"table\";\nimport { parseBoolean } from \"./parse-boolean\";\n\n/**\n * Error thrown when a prompt is attempted in a CI environment\n */\nexport class CIPromptError extends Error {\n constructor(message?: string) {\n super(\n message ??\n \"Interactive prompts are not available in CI environments. Use --yes flag to skip confirmation prompts.\",\n );\n this.name = \"CIPromptError\";\n }\n}\n\n/**\n * Semantic style functions for inline text styling\n */\nexport const styles = {\n // Status colors\n success: chalk.green,\n error: chalk.red,\n warning: chalk.yellow,\n info: chalk.cyan,\n\n // Action colors (for change sets)\n create: chalk.green,\n update: chalk.yellow,\n delete: chalk.red,\n unchanged: chalk.gray,\n\n // Emphasis\n bold: chalk.bold,\n dim: chalk.gray,\n highlight: chalk.cyanBright,\n successBright: chalk.greenBright,\n errorBright: chalk.redBright,\n\n // Resource types\n resourceType: chalk.bold,\n resourceName: chalk.cyan,\n\n // File paths\n path: chalk.cyan,\n\n // Values\n value: chalk.white,\n placeholder: chalk.gray.italic,\n};\n\n/**\n * Standardized symbols for CLI output\n */\nexport const symbols = {\n success: chalk.green(\"\\u2713\"),\n error: chalk.red(\"\\u2716\"),\n warning: chalk.yellow(\"\\u26a0\"),\n info: chalk.cyan(\"i\"),\n create: chalk.green(\"+\"),\n update: chalk.yellow(\"~\"),\n delete: chalk.red(\"-\"),\n replace: chalk.magenta(\"\\u00b1\"),\n bullet: chalk.gray(\"\\u2022\"),\n arrow: chalk.gray(\"\\u2192\"),\n};\n\n/**\n * Log output modes\n */\nexport type LogMode = \"default\" | \"stream\" | \"plain\";\n\nexport interface LogOptions {\n /** Output mode (default: \"default\") */\n mode?: LogMode;\n /** Number of spaces to indent the entire line (default: 0) */\n indent?: number;\n}\n\n/** Field transformer function. null excludes the field from table output. */\nexport type FieldTransformer = ((value: unknown, item: object) => string) | null;\n\nexport interface OutOptions {\n /** Table display field transform/exclude settings. Only applied in table mode (not JSON). */\n display?: Record<string, FieldTransformer>;\n\n /** Show null values in table output (default: false) */\n showNull?: boolean;\n}\n\n// In JSON mode, all logs go to stderr to keep stdout clean for JSON data\nlet _jsonMode = false;\n\n// Type icons for log output\nconst TYPE_ICONS: Record<string, string> = {\n info: \"ℹ\",\n success: \"✔\",\n warn: \"⚠\",\n error: \"✖\",\n debug: \"⚙\",\n trace: \"→\",\n log: \"\",\n};\n\n// Color functions for icon and message text\nconst TYPE_COLORS: Record<string, (text: string) => string> = {\n info: chalk.cyan,\n success: chalk.green,\n warn: chalk.yellow,\n error: chalk.red,\n debug: chalk.gray,\n trace: chalk.gray,\n log: (text) => text,\n};\n\ninterface FormatLogLineOptions {\n mode: string;\n indent: number;\n type: string;\n message: string;\n timestamp?: string;\n}\n\n/**\n * Formats a log line with the appropriate prefix and indentation\n * @param opts - Formatting options\n * @returns Formatted log line\n */\nexport function formatLogLine(opts: FormatLogLineOptions): string {\n const { mode, indent, type, message, timestamp } = opts;\n const indentPrefix = indent > 0 ? \" \".repeat(indent) : \"\";\n const colorFn = TYPE_COLORS[type] || ((text: string) => text);\n\n // Plain mode: color only, no icon, no timestamp\n if (mode === \"plain\") {\n return `${indentPrefix}${colorFn(message)}\\n`;\n }\n\n // Default/Stream mode: with icon and color\n const icon = TYPE_ICONS[type] || \"\";\n const prefix = icon ? `${icon} ` : \"\";\n const coloredOutput = colorFn(`${prefix}${message}`);\n const timestampPrefix = timestamp ?? \"\";\n\n return `${indentPrefix}${timestampPrefix}${coloredOutput}\\n`;\n}\n\n/**\n * Writes a formatted log line to stderr.\n * @param type - Log type (info, success, warn, error, log)\n * @param message - Log message\n * @param opts - Log options (mode and indent)\n */\nfunction writeLog(type: string, message: string, opts?: LogOptions): void {\n const mode = opts?.mode ?? \"default\";\n const indent = opts?.indent ?? 0;\n const inspectOpts: InspectOptions = {\n breakLength: process.stdout.columns || 80,\n };\n const formattedMessage = formatWithOptions(inspectOpts, message);\n const timestamp = mode === \"stream\" ? `${new Date().toLocaleTimeString()} ` : \"\";\n const output = formatLogLine({ mode, indent, type, message: formattedMessage, timestamp });\n process.stderr.write(output);\n}\n\nexport const logger = {\n get jsonMode(): boolean {\n return _jsonMode;\n },\n set jsonMode(value: boolean) {\n _jsonMode = value;\n },\n\n info(message: string, opts?: LogOptions): void {\n writeLog(\"info\", message, opts);\n },\n\n success(message: string, opts?: LogOptions): void {\n writeLog(\"success\", message, opts);\n },\n\n warn(message: string, opts?: LogOptions): void {\n writeLog(\"warn\", message, opts);\n },\n\n error(message: string, opts?: LogOptions): void {\n writeLog(\"error\", message, opts);\n },\n\n log(message: string): void {\n writeLog(\"log\", message, { mode: \"plain\" });\n },\n\n newline(): void {\n process.stderr.write(\"\\n\");\n },\n\n debug(message: string): void {\n if (parseBoolean(process.env.DEBUG) === true) {\n writeLog(\"log\", styles.dim(message), { mode: \"plain\" });\n }\n },\n\n out(data: string | object | object[], options?: OutOptions): void {\n if (typeof data === \"string\") {\n process.stdout.write(data.endsWith(\"\\n\") ? data : data + \"\\n\");\n return;\n }\n\n if (this.jsonMode) {\n // eslint-disable-next-line no-restricted-syntax\n console.log(JSON.stringify(data));\n return;\n }\n\n const display = options?.display;\n\n // Helper to format a value for table display\n const formatValue = (value: unknown, pretty = false): string => {\n if (options?.showNull && value === null) return \"NULL\";\n if (value === null || value === undefined) return \"N/A\";\n if (value instanceof Date) {\n return formatDistanceToNowStrict(value, { addSuffix: true });\n }\n if (typeof value === \"object\") {\n return pretty ? JSON.stringify(value, null, 2) : JSON.stringify(value);\n }\n return String(value);\n };\n\n // Helper to check if field should be excluded\n const isExcluded = (key: string): boolean => {\n return display !== undefined && key in display && display[key] === null;\n };\n\n // Helper to apply transformer or default formatting\n const transformValue = (key: string, value: unknown, item: object, pretty = false): string => {\n if (display && key in display) {\n const transformer = display[key];\n if (transformer) {\n return transformer(value, item);\n }\n }\n return formatValue(value, pretty);\n };\n\n if (!Array.isArray(data)) {\n const entries = Object.entries(data).filter(([key]) => !isExcluded(key));\n const formattedEntries = entries.map(([key, value]) => [\n key,\n transformValue(key, value, data, true),\n ]);\n const t = table(formattedEntries, {\n singleLine: false,\n border: getBorderCharacters(\"norc\"),\n });\n process.stdout.write(t);\n return;\n }\n\n if (data.length === 0) {\n return;\n }\n\n const allHeaders = Array.from(new Set(data.flatMap((item) => Object.keys(item))));\n const headers = allHeaders.filter((h) => !isExcluded(h));\n const rows = data.map((item) =>\n headers.map((header) =>\n transformValue(header, (item as Record<string, unknown>)[header], item),\n ),\n );\n\n const t = table([headers, ...rows], {\n border: getBorderCharacters(\"norc\"),\n drawHorizontalLine: (lineIndex, rowCount) => {\n return lineIndex === 0 || lineIndex === 1 || lineIndex === rowCount;\n },\n });\n process.stdout.write(t);\n },\n};\n"],"mappings":";;;;;;;AAAA,MAAM,gBAAgB,IAAI,IAAI;CAAC;CAAQ;CAAK;CAAO;CAAK;CAAM;AAAG,CAAC;AAClE,MAAM,eAAe,IAAI,IAAI;CAAC;CAAS;CAAK;CAAM;CAAK;CAAO;AAAG,CAAC;;;;;;;;;;;;;;AAelE,SAAgB,aAAa,OAAgD;CAC3E,IAAI,UAAU,QAAW,OAAO;CAChC,MAAM,aAAa,MAAM,KAAK,EAAE,YAAY;CAC5C,IAAI,eAAe,IAAI,OAAO;CAC9B,IAAI,cAAc,IAAI,UAAU,GAAG,OAAO;CAC1C,IAAI,aAAa,IAAI,UAAU,GAAG,OAAO;AAE3C;;;;;;;ACdA,IAAa,gBAAb,cAAmC,MAAM;CACvC,YAAY,SAAkB;EAC5B,MACE,WACE,wGACJ;EACA,KAAK,OAAO;CACd;AACF;;;;AAKA,MAAa,SAAS;CAEpB,SAAS,MAAM;CACf,OAAO,MAAM;CACb,SAAS,MAAM;CACf,MAAM,MAAM;CA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,oBAAoB,MAAM;GAClC,qBAAqB,WAAW,aAAa;IAC3C,OAAO,cAAc,KAAK,cAAc,KAAK,cAAc;GAC7D;EACF,CAAC;EACD,QAAQ,OAAO,MAAM,CAAC;CACxB;AACF"}
|
|
1
|
+
{"version":3,"file":"logger-DpJyJvNz.mjs","names":[],"sources":["../src/cli/shared/parse-boolean.ts","../src/cli/shared/logger.ts"],"sourcesContent":["const TRUTHY_VALUES = new Set([\"true\", \"t\", \"yes\", \"y\", \"on\", \"1\"]);\nconst FALSY_VALUES = new Set([\"false\", \"f\", \"no\", \"n\", \"off\", \"0\"]);\n\n/**\n * Parse a string value as a boolean.\n *\n * Recognized values (case-insensitive, trimmed) follow Python's\n * `distutils.util.strtobool` convention:\n * - truthy: `true, t, yes, y, on, 1`\n * - falsy: `false, f, no, n, off, 0`\n *\n * Undefined, empty strings, and unrecognized values return `undefined` so\n * that callers can fall back to their own defaults.\n * @param value - The input string (e.g. an environment variable or CLI flag value)\n * @returns `true`, `false`, or `undefined` when the value is unset or unrecognized\n */\nexport function parseBoolean(value: string | undefined): boolean | undefined {\n if (value === undefined) return undefined;\n const normalized = value.trim().toLowerCase();\n if (normalized === \"\") return undefined;\n if (TRUTHY_VALUES.has(normalized)) return true;\n if (FALSY_VALUES.has(normalized)) return false;\n return undefined;\n}\n","import { formatWithOptions, type InspectOptions } from \"node:util\";\nimport chalk from \"chalk\";\nimport { formatDistanceToNowStrict } from \"date-fns\";\nimport { getBorderCharacters, table } from \"table\";\nimport { parseBoolean } from \"./parse-boolean\";\n\n/**\n * Error thrown when a prompt is attempted in a CI environment\n */\nexport class CIPromptError extends Error {\n constructor(message?: string) {\n super(\n message ??\n \"Interactive prompts are not available in CI environments. Use --yes flag to skip confirmation prompts.\",\n );\n this.name = \"CIPromptError\";\n }\n}\n\n/**\n * Semantic style functions for inline text styling\n */\nexport const styles = {\n // Status colors\n success: chalk.green,\n error: chalk.red,\n warning: chalk.yellow,\n info: chalk.cyan,\n\n // Action colors (for change sets)\n create: chalk.green,\n update: chalk.yellow,\n delete: chalk.red,\n unchanged: chalk.gray,\n\n // Emphasis\n bold: chalk.bold,\n dim: chalk.gray,\n highlight: chalk.cyanBright,\n successBright: chalk.greenBright,\n errorBright: chalk.redBright,\n\n // Resource types\n resourceType: chalk.bold,\n resourceName: chalk.cyan,\n\n // File paths\n path: chalk.cyan,\n\n // Values\n value: chalk.white,\n placeholder: chalk.gray.italic,\n};\n\n/**\n * Standardized symbols for CLI output\n */\nexport const symbols = {\n success: chalk.green(\"\\u2713\"),\n error: chalk.red(\"\\u2716\"),\n warning: chalk.yellow(\"\\u26a0\"),\n info: chalk.cyan(\"i\"),\n create: chalk.green(\"+\"),\n update: chalk.yellow(\"~\"),\n delete: chalk.red(\"-\"),\n replace: chalk.magenta(\"\\u00b1\"),\n bullet: chalk.gray(\"\\u2022\"),\n arrow: chalk.gray(\"\\u2192\"),\n};\n\n/**\n * Log output modes\n */\nexport type LogMode = \"default\" | \"stream\" | \"plain\";\n\nexport interface LogOptions {\n /** Output mode (default: \"default\") */\n mode?: LogMode;\n /** Number of spaces to indent the entire line (default: 0) */\n indent?: number;\n}\n\n/** Field transformer function. null excludes the field from table output. */\nexport type FieldTransformer = ((value: unknown, item: object) => string) | null;\n\nexport interface OutOptions {\n /** Table display field transform/exclude settings. Only applied in table mode (not JSON). */\n display?: Record<string, FieldTransformer>;\n\n /** Show null values in table output (default: false) */\n showNull?: boolean;\n}\n\n// In JSON mode, all logs go to stderr to keep stdout clean for JSON data\nlet _jsonMode = false;\n\n// Type icons for log output\nconst TYPE_ICONS: Record<string, string> = {\n info: \"ℹ\",\n success: \"✔\",\n warn: \"⚠\",\n error: \"✖\",\n debug: \"⚙\",\n trace: \"→\",\n log: \"\",\n};\n\n// Color functions for icon and message text\nconst TYPE_COLORS: Record<string, (text: string) => string> = {\n info: chalk.cyan,\n success: chalk.green,\n warn: chalk.yellow,\n error: chalk.red,\n debug: chalk.gray,\n trace: chalk.gray,\n log: (text) => text,\n};\n\ninterface FormatLogLineOptions {\n mode: string;\n indent: number;\n type: string;\n message: string;\n timestamp?: string;\n}\n\n/**\n * Formats a log line with the appropriate prefix and indentation\n * @param opts - Formatting options\n * @returns Formatted log line\n */\nexport function formatLogLine(opts: FormatLogLineOptions): string {\n const { mode, indent, type, message, timestamp } = opts;\n const indentPrefix = indent > 0 ? \" \".repeat(indent) : \"\";\n const colorFn = TYPE_COLORS[type] || ((text: string) => text);\n\n // Plain mode: color only, no icon, no timestamp\n if (mode === \"plain\") {\n return `${indentPrefix}${colorFn(message)}\\n`;\n }\n\n // Default/Stream mode: with icon and color\n const icon = TYPE_ICONS[type] || \"\";\n const prefix = icon ? `${icon} ` : \"\";\n const coloredOutput = colorFn(`${prefix}${message}`);\n const timestampPrefix = timestamp ?? \"\";\n\n return `${indentPrefix}${timestampPrefix}${coloredOutput}\\n`;\n}\n\n/**\n * Writes a formatted log line to stderr.\n * @param type - Log type (info, success, warn, error, log)\n * @param message - Log message\n * @param opts - Log options (mode and indent)\n */\nfunction writeLog(type: string, message: string, opts?: LogOptions): void {\n const mode = opts?.mode ?? \"default\";\n const indent = opts?.indent ?? 0;\n const inspectOpts: InspectOptions = {\n breakLength: process.stdout.columns || 80,\n };\n const formattedMessage = formatWithOptions(inspectOpts, message);\n const timestamp = mode === \"stream\" ? `${new Date().toLocaleTimeString()} ` : \"\";\n const output = formatLogLine({ mode, indent, type, message: formattedMessage, timestamp });\n process.stderr.write(output);\n}\n\nexport const logger = {\n get jsonMode(): boolean {\n return _jsonMode;\n },\n set jsonMode(value: boolean) {\n _jsonMode = value;\n },\n\n info(message: string, opts?: LogOptions): void {\n writeLog(\"info\", message, opts);\n },\n\n success(message: string, opts?: LogOptions): void {\n writeLog(\"success\", message, opts);\n },\n\n warn(message: string, opts?: LogOptions): void {\n writeLog(\"warn\", message, opts);\n },\n\n error(message: string, opts?: LogOptions): void {\n writeLog(\"error\", message, opts);\n },\n\n log(message: string): void {\n writeLog(\"log\", message, { mode: \"plain\" });\n },\n\n newline(): void {\n process.stderr.write(\"\\n\");\n },\n\n debug(message: string): void {\n if (parseBoolean(process.env.DEBUG) === true) {\n writeLog(\"log\", styles.dim(message), { mode: \"plain\" });\n }\n },\n\n out(data: string | object | object[], options?: OutOptions): void {\n if (typeof data === \"string\") {\n process.stdout.write(data.endsWith(\"\\n\") ? data : data + \"\\n\");\n return;\n }\n\n if (this.jsonMode) {\n // eslint-disable-next-line no-restricted-syntax\n console.log(JSON.stringify(data));\n return;\n }\n\n const display = options?.display;\n\n // Helper to format a value for table display\n const formatValue = (value: unknown, pretty = false): string => {\n if (options?.showNull && value === null) return \"NULL\";\n if (value === null || value === undefined) return \"N/A\";\n if (value instanceof Date) {\n return formatDistanceToNowStrict(value, { addSuffix: true });\n }\n if (typeof value === \"object\") {\n return pretty ? JSON.stringify(value, null, 2) : JSON.stringify(value);\n }\n return String(value);\n };\n\n // Helper to check if field should be excluded\n const isExcluded = (key: string): boolean => {\n return display !== undefined && key in display && display[key] === null;\n };\n\n // Helper to apply transformer or default formatting\n const transformValue = (key: string, value: unknown, item: object, pretty = false): string => {\n if (display && key in display) {\n const transformer = display[key];\n if (transformer) {\n return transformer(value, item);\n }\n }\n return formatValue(value, pretty);\n };\n\n if (!Array.isArray(data)) {\n const entries = Object.entries(data).filter(([key]) => !isExcluded(key));\n const formattedEntries = entries.map(([key, value]) => [\n key,\n transformValue(key, value, data, true),\n ]);\n const t = table(formattedEntries, {\n singleLine: false,\n border: getBorderCharacters(\"norc\"),\n });\n process.stdout.write(t);\n return;\n }\n\n if (data.length === 0) {\n return;\n }\n\n const allHeaders = Array.from(new Set(data.flatMap((item) => Object.keys(item))));\n const headers = allHeaders.filter((h) => !isExcluded(h));\n const rows = data.map((item) =>\n headers.map((header) =>\n transformValue(header, (item as Record<string, unknown>)[header], item),\n ),\n );\n\n const t = table([headers, ...rows], {\n border: getBorderCharacters(\"norc\"),\n drawHorizontalLine: (lineIndex, rowCount) => {\n return lineIndex === 0 || lineIndex === 1 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A,OAAO,YAAY,OAAO,MAAM;EAClC;EAEA,IAAI,CAAC,MAAM,QAAQ,IAAI,GAAG;GAMxB,MAAM,IAAI,MALM,OAAO,QAAQ,IAAI,EAAE,QAAQ,CAAC,SAAS,CAAC,WAAW,GAAG,CACvC,EAAE,KAAK,CAAC,KAAK,WAAW,CACrD,KACA,eAAe,KAAK,OAAO,MAAM,IAAI,CACvC,CAC+B,GAAG;IAChC,YAAY;IACZ,QAAQ,oBAAoB,MAAM;GACpC,CAAC;GACD,QAAQ,OAAO,MAAM,CAAC;GACtB;EACF;EAEA,IAAI,KAAK,WAAW,GAClB;EAIF,MAAM,UADa,MAAM,KAAK,IAAI,IAAI,KAAK,SAAS,SAAS,OAAO,KAAK,IAAI,CAAC,CAAC,CACtD,EAAE,QAAQ,MAAM,CAAC,WAAW,CAAC,CAAC;EAOvD,MAAM,IAAI,MAAM,CAAC,SAAS,GANb,KAAK,KAAK,SACrB,QAAQ,KAAK,WACX,eAAe,QAAS,KAAiC,SAAS,IAAI,CACxE,CAG8B,CAAC,GAAG;GAClC,QAAQ,oBAAoB,MAAM;GAClC,qBAAqB,WAAW,aAAa;IAC3C,OAAO,cAAc,KAAK,cAAc,KAAK,cAAc;GAC7D;EACF,CAAC;EACD,QAAQ,OAAO,MAAM,CAAC;CACxB;AACF"}
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
|
|
2
|
+
import { r as writeWorkflowTestEnv, t as clearWorkflowTestEnv } from "./test-env-key-CSnK4W1Y.mjs";
|
|
3
|
+
|
|
2
4
|
//#region src/vitest/mock.ts
|
|
5
|
+
/**
|
|
6
|
+
* Mock implementations for Tailor Platform APIs.
|
|
7
|
+
*
|
|
8
|
+
* Provides singleton mock objects that are automatically injected into
|
|
9
|
+
* globalThis by the tailor-runtime Vitest environment. Tests can configure
|
|
10
|
+
* responses and assert on recorded calls via the exported mock objects.
|
|
11
|
+
*/
|
|
3
12
|
const STATE_KEY = "__tailorMockState";
|
|
4
13
|
const RUNTIME_FLAG_KEY = "__tailorRuntimeActive";
|
|
5
14
|
function getState() {
|
|
@@ -195,6 +204,14 @@ const workflowMock = {
|
|
|
195
204
|
getState().waitHandler = handler;
|
|
196
205
|
}),
|
|
197
206
|
/**
|
|
207
|
+
* Set the `env` passed to job bodies invoked via `createWorkflowJob().trigger()`.
|
|
208
|
+
* Cleared by `workflowMock.reset()`.
|
|
209
|
+
* @param env - Env passed to job bodies.
|
|
210
|
+
*/
|
|
211
|
+
setEnv(env) {
|
|
212
|
+
writeWorkflowTestEnv({ ...env });
|
|
213
|
+
},
|
|
214
|
+
/**
|
|
198
215
|
* Configure how `tailor.workflow.resolve` runs the user-supplied callback. The handler
|
|
199
216
|
* receives `(executionId, key, callback)` — invoke `callback(payload)` to drive
|
|
200
217
|
* resolve→wait wiring in tests. Default: callback is not invoked (records the call only).
|
|
@@ -240,6 +257,7 @@ const workflowMock = {
|
|
|
240
257
|
state.waitHandler = null;
|
|
241
258
|
state.resolveHandler = null;
|
|
242
259
|
state.workflowCalls.length = 0;
|
|
260
|
+
clearWorkflowTestEnv();
|
|
243
261
|
}
|
|
244
262
|
};
|
|
245
263
|
/** Mock control for `tailor.secretmanager` — secret store and call recording. */
|
|
@@ -795,8 +813,9 @@ function cleanupMocks(global) {
|
|
|
795
813
|
delete g.TailorDBFileError;
|
|
796
814
|
delete g[STATE_KEY];
|
|
797
815
|
delete g[RUNTIME_FLAG_KEY];
|
|
816
|
+
clearWorkflowTestEnv();
|
|
798
817
|
}
|
|
799
818
|
|
|
800
819
|
//#endregion
|
|
801
820
|
export { fileMock as a, injectMocks as c, workflowMock as d, cleanupMocks as i, secretmanagerMock as l, STATE_KEY as n, iconvMock as o, authconnectionMock as r, idpMock as s, RUNTIME_FLAG_KEY as t, tailordbMock as u };
|
|
802
|
-
//# sourceMappingURL=mock-
|
|
821
|
+
//# sourceMappingURL=mock-BabuSqbj.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mock-BabuSqbj.mjs","names":["#record","#namespace","#fromEncoding","#toEncoding"],"sources":["../src/vitest/mock.ts"],"sourcesContent":["/**\n * Mock implementations for Tailor Platform APIs.\n *\n * Provides singleton mock objects that are automatically injected into\n * globalThis by the tailor-runtime Vitest environment. Tests can configure\n * responses and assert on recorded calls via the exported mock objects.\n */\n\nimport {\n clearWorkflowTestEnv,\n writeWorkflowTestEnv,\n} from \"../configure/services/workflow/test-env-key\";\nimport type { ContextInvoker } from \"../runtime/context\";\nimport type { TailorDBFileErrorCode } from \"../runtime/file\";\nimport type { User as IdpUser } from \"../runtime/idp\";\nimport type { TailorEnv } from \"../types/env\";\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\ntype QueryResolver = (query: string, params: unknown[]) => unknown[];\ntype JobHandler = (jobName: string, args: unknown) => unknown;\ntype IdpResolver = (method: string, args: unknown[], namespace: string) => unknown;\ntype FileResolver = (method: string, call: FileCall) => unknown;\ntype IconvResolver = (method: string, args: unknown[]) => unknown;\n\ntype TriggerWorkflowOptions = {\n authInvoker?: { namespace: string; machineUserName: string };\n};\ntype TriggerHandlerFn = (\n workflowName: string,\n args: unknown,\n options?: TriggerWorkflowOptions,\n) => string;\ntype WaitHandlerFn = (key: string, payload: unknown) => unknown;\ntype ResolveHandler = (\n executionId: string,\n key: string,\n callback: (payload: unknown) => unknown,\n) => unknown | Promise<unknown>;\n\n// Overloaded so TypeScript narrows to WaitHandlerFn first (giving inferred\n// `(key: string, payload: unknown) => …` for callers) before falling back\n// to the static-value form. A union type would let `unknown` swallow the\n// function variant and break inference.\ntype SetWaitHandler = {\n (handler: WaitHandlerFn): void;\n (handler: unknown): void;\n};\n\ninterface ExecutedQuery {\n query: string;\n params: unknown[];\n}\n\ninterface CreatedClient {\n namespace: string | undefined;\n ended: boolean;\n}\n\ninterface TriggeredJob {\n jobName: string;\n args: unknown;\n}\n\ninterface SecretCall {\n method: \"getSecret\" | \"getSecrets\";\n vault: string;\n name?: string;\n names?: readonly string[];\n}\n\ninterface AuthConnectionCall {\n connectionName: string;\n}\n\ninterface IdpCall {\n method: string;\n args: unknown[];\n namespace: string;\n}\n\ninterface FileCall {\n method: string;\n namespace: string;\n typeName: string;\n fieldName: string;\n recordId: string;\n}\n\ninterface IconvCall {\n method: string;\n args: unknown[];\n}\n\ninterface WorkflowCall {\n method: \"triggerWorkflow\" | \"wait\" | \"resolve\";\n args: unknown[];\n}\n\ninterface MockState {\n // TailorDB\n queryResolver: QueryResolver;\n queryResultQueue: unknown[][];\n executedQueries: ExecutedQuery[];\n createdClients: CreatedClient[];\n // Workflow\n jobHandler: JobHandler;\n jobResultQueue: unknown[];\n triggeredJobs: TriggeredJob[];\n triggerHandler: string | TriggerHandlerFn;\n waitHandler: unknown | WaitHandlerFn;\n resolveHandler: ResolveHandler | null;\n workflowCalls: WorkflowCall[];\n // SecretManager\n secretStore: Record<string, Record<string, string>>;\n secretCalls: SecretCall[];\n // AuthConnection\n authTokens: Record<string, unknown>;\n authCalls: AuthConnectionCall[];\n // IDP\n idpResolver: IdpResolver;\n idpResultQueue: unknown[];\n idpCalls: IdpCall[];\n // File\n fileResolver: FileResolver;\n fileResultQueue: unknown[];\n fileCalls: FileCall[];\n // Iconv\n iconvResolver: IconvResolver | null;\n iconvCalls: IconvCall[];\n}\n\n// ---------------------------------------------------------------------------\n// State management (shared via globalThis for environment/test interop)\n// ---------------------------------------------------------------------------\n\nexport const STATE_KEY = \"__tailorMockState\";\n\n// Sentinel set by the tailor-runtime environment in injectMocks() and cleared\n// in cleanupMocks(). Distinct from STATE_KEY, which is created lazily by\n// getState() whenever a mock helper runs (even from a non-tailor-runtime\n// project that happens to import the mocks). Use this flag to detect whether\n// the environment itself is active.\nexport const RUNTIME_FLAG_KEY = \"__tailorRuntimeActive\";\n\nfunction getState(): MockState {\n const g = globalThis as Record<string, unknown>;\n if (!g[STATE_KEY]) {\n g[STATE_KEY] = createDefaultState();\n }\n return g[STATE_KEY] as MockState;\n}\n\nfunction createDefaultState(): MockState {\n return {\n queryResolver: () => [],\n queryResultQueue: [],\n executedQueries: [],\n createdClients: [],\n jobHandler: () => null,\n jobResultQueue: [],\n triggeredJobs: [],\n triggerHandler: \"mock-execution-id\",\n waitHandler: null,\n resolveHandler: null,\n workflowCalls: [],\n secretStore: {},\n secretCalls: [],\n authTokens: {},\n authCalls: [],\n idpResolver: () => null,\n idpResultQueue: [],\n idpCalls: [],\n fileResolver: () => null,\n fileResultQueue: [],\n fileCalls: [],\n iconvResolver: null,\n iconvCalls: [],\n };\n}\n\n// ---------------------------------------------------------------------------\n// TailorDB Mock\n// ---------------------------------------------------------------------------\n\n/**\n * Mock control object for TailorDB operations.\n *\n * Automatically injected into `globalThis.tailordb` by the tailor-runtime environment.\n * Use this object to configure query responses and assert on executed queries.\n * @example\n * ```typescript\n * import { tailordbMock } from \"@tailor-platform/sdk/vitest\";\n *\n * beforeEach(() => tailordbMock.reset());\n *\n * test(\"content-based\", () => {\n * tailordbMock.setQueryResolver((query) => {\n * if (query.includes(\"SELECT\")) return [{ id: \"1\" }];\n * return [];\n * });\n * });\n *\n * test(\"order-based\", () => {\n * tailordbMock.enqueueResults(\n * [], // BEGIN (empty result)\n * [{ age: 30 }], // SELECT (one row)\n * [], // COMMIT (empty result)\n * );\n * });\n * ```\n */\nexport const tailordbMock = {\n /**\n * Set a fallback query resolver. Called when the result queue is empty.\n * @param resolver - Function that returns rows for a given query and params\n */\n setQueryResolver(resolver: QueryResolver): void {\n getState().queryResolver = resolver;\n },\n\n /**\n * Enqueue rows for the next `queryObject` call. Arguments are the row objects returned\n * by that single query. Call with no arguments for an empty result. Consumed in FIFO\n * order; when the queue is exhausted, subsequent calls fall back to `setQueryResolver`\n * (default: empty rows). Use `enqueueResults` to stage rows for multiple queries in one\n * call.\n * @param rows - Row objects to return from the next `queryObject` call\n */\n enqueueResult(...rows: unknown[]): void {\n getState().queryResultQueue.push(rows);\n },\n\n /**\n * Enqueue rows for multiple subsequent `queryObject` calls. Each argument is a rows\n * array for one query, consumed in FIFO order.\n * @param rowsList - Rows arrays, one per upcoming query\n */\n enqueueResults(...rowsList: unknown[][]): void {\n getState().queryResultQueue.push(...rowsList);\n },\n\n /**\n * All queries executed via `queryObject`, in order.\n * @returns Executed queries array\n */\n get executedQueries(): ExecutedQuery[] {\n return getState().executedQueries;\n },\n\n /**\n * All TailorDB clients created, with their namespace and end state.\n * @returns Created clients array\n */\n get createdClients(): CreatedClient[] {\n return getState().createdClients;\n },\n\n /** Reset all TailorDB mock state. Call in `beforeEach`. */\n reset(): void {\n const state = getState();\n state.queryResolver = () => [];\n state.queryResultQueue.length = 0;\n state.executedQueries.length = 0;\n state.createdClients.length = 0;\n },\n};\n\n// ---------------------------------------------------------------------------\n// Workflow Mock\n// ---------------------------------------------------------------------------\n\n/**\n * Mock control object for workflow operations.\n *\n * Automatically injected into `globalThis.tailor.workflow` by the tailor-runtime environment.\n * @example\n * ```typescript\n * import { workflowMock } from \"@tailor-platform/sdk/vitest\";\n *\n * beforeEach(() => workflowMock.reset());\n *\n * test(\"job handler\", () => {\n * workflowMock.setJobHandler((jobName, args) => {\n * if (jobName === \"validate\") return { valid: true };\n * return null;\n * });\n * });\n *\n * test(\"wait point\", () => {\n * workflowMock.setWaitHandler(() => ({ approved: true }));\n * // …\n * expect(workflowMock.waitCalls).toEqual([{ key: \"approval\", payload: undefined }]);\n * });\n *\n * test(\"resolve point\", () => {\n * workflowMock.setResolveHandler((_executionId, _key, callback) =>\n * callback({ approved: true }),\n * );\n * // …\n * expect(workflowMock.resolveCalls).toEqual([\n * { executionId: \"mock-execution-id\", key: \"approval\" },\n * ]);\n * });\n * ```\n */\nexport const workflowMock = {\n /**\n * Set a fallback job handler. Called when the result queue is empty.\n * @param handler - Function that returns a result for a given job name and args\n */\n setJobHandler(handler: JobHandler): void {\n getState().jobHandler = handler;\n },\n\n /**\n * Enqueue a single result for the next `triggerJobFunction` call. Consumed in FIFO\n * order; when the queue is exhausted, subsequent calls fall back to `setJobHandler`\n * (default: null). Use `enqueueResults` to stage multiple results in one call.\n * @param result - Result to return from the next `triggerJobFunction` call\n */\n enqueueResult(result: unknown): void {\n getState().jobResultQueue.push(result);\n },\n\n /**\n * Enqueue results for multiple subsequent `triggerJobFunction` calls.\n * @param results - Results to enqueue, one per upcoming call\n */\n enqueueResults(...results: unknown[]): void {\n const queue = getState().jobResultQueue;\n for (const result of results) {\n queue.push(result);\n }\n },\n\n /**\n * All jobs triggered via `triggerJobFunction`, in order.\n * @returns Triggered jobs array\n */\n get triggeredJobs(): TriggeredJob[] {\n return getState().triggeredJobs;\n },\n\n /**\n * Configure what `tailor.workflow.triggerWorkflow` returns. Pass a string to return\n * the same execution ID for every call, or a function `(name, args, options) => string`\n * to compute one per call. Default: `\"mock-execution-id\"`.\n * @param handler - Static execution ID or a function that returns one\n */\n setTriggerHandler(handler: string | TriggerHandlerFn): void {\n getState().triggerHandler = handler;\n },\n\n /**\n * Configure what `tailor.workflow.wait` returns. Pass a function `(key, payload) => unknown`\n * to compute one per call, or any other value to return it for every call. Default: `null`.\n * @param handler - Static value or a function that returns one\n */\n setWaitHandler: ((handler: unknown) => {\n getState().waitHandler = handler;\n }) as SetWaitHandler,\n\n /**\n * Set the `env` passed to job bodies invoked via `createWorkflowJob().trigger()`.\n * Cleared by `workflowMock.reset()`.\n * @param env - Env passed to job bodies.\n */\n setEnv(env: TailorEnv): void {\n writeWorkflowTestEnv({ ...env });\n },\n\n /**\n * Configure how `tailor.workflow.resolve` runs the user-supplied callback. The handler\n * receives `(executionId, key, callback)` — invoke `callback(payload)` to drive\n * resolve→wait wiring in tests. Default: callback is not invoked (records the call only).\n * @param handler - Function invoked per `resolve` call\n */\n setResolveHandler(handler: ResolveHandler): void {\n getState().resolveHandler = handler;\n },\n\n /**\n * Calls to triggerWorkflow, wait, resolve (not triggerJobFunction — use triggeredJobs).\n * @returns Workflow calls array\n */\n get calls(): WorkflowCall[] {\n return getState().workflowCalls;\n },\n\n /**\n * `tailor.workflow.wait` calls reshaped as `{ key, payload }` for assertions.\n * @returns Wait call records\n */\n get waitCalls(): { key: string; payload: unknown }[] {\n return getState()\n .workflowCalls.filter((c) => c.method === \"wait\")\n .map((c) => ({ key: c.args[0] as string, payload: c.args[1] }));\n },\n\n /**\n * `tailor.workflow.resolve` calls reshaped as `{ executionId, key }` for assertions.\n * @returns Resolve call records\n */\n get resolveCalls(): { executionId: string; key: string }[] {\n return getState()\n .workflowCalls.filter((c) => c.method === \"resolve\")\n .map((c) => ({ executionId: c.args[0] as string, key: c.args[1] as string }));\n },\n\n /** Reset all workflow mock state. Call in `beforeEach`. */\n reset(): void {\n const state = getState();\n state.jobHandler = () => null;\n state.jobResultQueue.length = 0;\n state.triggeredJobs.length = 0;\n state.triggerHandler = \"mock-execution-id\";\n state.waitHandler = null;\n state.resolveHandler = null;\n state.workflowCalls.length = 0;\n clearWorkflowTestEnv();\n },\n};\n\n// ---------------------------------------------------------------------------\n// SecretManager Mock\n// ---------------------------------------------------------------------------\n\n/** Mock control for `tailor.secretmanager` — secret store and call recording. */\nexport const secretmanagerMock = {\n setSecrets(secrets: Record<string, Record<string, string>>): void {\n getState().secretStore = secrets;\n },\n\n get calls(): SecretCall[] {\n return getState().secretCalls;\n },\n\n reset(): void {\n const state = getState();\n state.secretStore = {};\n state.secretCalls.length = 0;\n },\n};\n\n// ---------------------------------------------------------------------------\n// AuthConnection Mock\n// ---------------------------------------------------------------------------\n\n/** Mock control for `tailor.authconnection` — token store and call recording. */\nexport const authconnectionMock = {\n setTokens(tokens: Record<string, unknown>): void {\n getState().authTokens = tokens;\n },\n\n get calls(): AuthConnectionCall[] {\n return getState().authCalls;\n },\n\n reset(): void {\n const state = getState();\n state.authTokens = {};\n state.authCalls.length = 0;\n },\n};\n\n// ---------------------------------------------------------------------------\n// IDP Mock\n// ---------------------------------------------------------------------------\n\n/** Mock control for `tailor.idp` — IDP client responses and call recording. */\nexport const idpMock = {\n setResolver(resolver: IdpResolver): void {\n getState().idpResolver = resolver;\n },\n\n /**\n * Enqueue a single result for the next IDP call. Consumed in FIFO order; falls back\n * to `setResolver` when exhausted. Use `enqueueResults` to stage multiple in one call.\n * @param result - Result to return from the next IDP call\n */\n enqueueResult(result: unknown): void {\n getState().idpResultQueue.push(result);\n },\n\n /**\n * Enqueue results for multiple subsequent IDP calls.\n * @param results - Results to enqueue, one per upcoming call\n */\n enqueueResults(...results: unknown[]): void {\n const queue = getState().idpResultQueue;\n for (const result of results) {\n queue.push(result);\n }\n },\n\n get calls(): IdpCall[] {\n return getState().idpCalls;\n },\n\n reset(): void {\n const state = getState();\n state.idpResolver = () => null;\n state.idpResultQueue.length = 0;\n state.idpCalls.length = 0;\n },\n};\n\n// ---------------------------------------------------------------------------\n// File Mock\n// ---------------------------------------------------------------------------\n\n/** Mock control for `tailordb.file` — file operation responses and call recording. */\nexport const fileMock = {\n setResolver(resolver: FileResolver): void {\n getState().fileResolver = resolver;\n },\n\n /**\n * Enqueue a single result for the next `tailordb.file` call. Consumed in FIFO order;\n * falls back to `setResolver` when exhausted. Use `enqueueResults` to stage multiple\n * in one call.\n * @param result - Result to return from the next file call\n */\n enqueueResult(result: unknown): void {\n getState().fileResultQueue.push(result);\n },\n\n /**\n * Enqueue results for multiple subsequent `tailordb.file` calls.\n * @param results - Results to enqueue, one per upcoming call\n */\n enqueueResults(...results: unknown[]): void {\n const queue = getState().fileResultQueue;\n for (const result of results) {\n queue.push(result);\n }\n },\n\n get calls(): FileCall[] {\n return getState().fileCalls;\n },\n\n reset(): void {\n const state = getState();\n state.fileResolver = () => null;\n state.fileResultQueue.length = 0;\n state.fileCalls.length = 0;\n },\n};\n\n// ---------------------------------------------------------------------------\n// Iconv Mock\n// ---------------------------------------------------------------------------\n\n/** Mock control for `tailor.iconv` — encoding call recording. */\nexport const iconvMock = {\n setResolver(resolver: IconvResolver): void {\n getState().iconvResolver = resolver;\n },\n\n get calls(): IconvCall[] {\n return getState().iconvCalls;\n },\n\n reset(): void {\n const state = getState();\n state.iconvResolver = null;\n state.iconvCalls.length = 0;\n },\n};\n\n// ---------------------------------------------------------------------------\n// Mock Client implementation (injected as globalThis.tailordb.Client)\n// ---------------------------------------------------------------------------\n\nclass MockQueryResult {\n command: string;\n rowCount: number;\n rows: unknown[];\n\n constructor(rows: unknown[]) {\n this.command = \"\";\n this.rowCount = rows.length;\n this.rows = rows;\n }\n}\n\nclass MockTransaction {\n async begin(): Promise<void> {\n /* noop */\n }\n async commit(): Promise<void> {\n /* noop */\n }\n async rollback(): Promise<void> {\n /* noop */\n }\n\n async queryObject(query: string, params: unknown[] = []): Promise<MockQueryResult> {\n return resolveQuery(query, params);\n }\n}\n\nclass MockTailordbClient {\n #record: CreatedClient;\n\n constructor(config?: { namespace?: string }) {\n this.#record = { namespace: config?.namespace, ended: false };\n getState().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<MockQueryResult> {\n return resolveQuery(query, params);\n }\n\n createTransaction(name: string): MockTransaction {\n if (!name) {\n throw new Error(\"Transaction name must be a non-empty string\");\n }\n return new MockTransaction();\n }\n}\n\nfunction resolveQuery(query: string, params: unknown[]): MockQueryResult {\n const state = getState();\n state.executedQueries.push({ query, params });\n\n // 1. Queue takes priority (order-based)\n if (state.queryResultQueue.length > 0) {\n return new MockQueryResult(state.queryResultQueue.shift()!);\n }\n\n // 2. Fallback to query resolver (content-based)\n const rows = state.queryResolver(query, params) ?? [];\n return new MockQueryResult(rows);\n}\n\n// ---------------------------------------------------------------------------\n// Mock: tailor.workflow\n// ---------------------------------------------------------------------------\n\nfunction mockTriggerJobFunction(jobName: string, args?: unknown): unknown {\n const state = getState();\n state.triggeredJobs.push({ jobName, args });\n if (state.jobResultQueue.length > 0) return state.jobResultQueue.shift();\n return state.jobHandler(jobName, args);\n}\n\nasync function mockTriggerWorkflow(\n workflowName: string,\n args?: unknown,\n options?: TriggerWorkflowOptions,\n): Promise<string> {\n const state = getState();\n state.workflowCalls.push({ method: \"triggerWorkflow\", args: [workflowName, args, options] });\n const handler = state.triggerHandler;\n return typeof handler === \"function\" ? handler(workflowName, args, options) : handler;\n}\n\nfunction mockWait(key: string, payload?: unknown): unknown {\n const state = getState();\n state.workflowCalls.push({ method: \"wait\", args: [key, payload] });\n const handler = state.waitHandler;\n return typeof handler === \"function\" ? (handler as WaitHandlerFn)(key, payload) : handler;\n}\n\n// Records the resolve call. By default the callback is not invoked, mirroring\n// platform semantics where tailor.workflow.resolve enqueues the callback\n// against the wait point and returns immediately. Tests that need\n// resolve→wait wiring can register a handler via workflowMock.setResolveHandler\n// — the handler receives `(executionId, key, callback)` and decides whether to\n// invoke the callback (typically with a synthesized payload).\nasync function mockResolve(\n executionId: string,\n key: string,\n callback: (payload: unknown) => unknown | Promise<unknown>,\n): Promise<void> {\n const state = getState();\n state.workflowCalls.push({ method: \"resolve\", args: [executionId, key, callback] });\n if (state.resolveHandler) {\n await state.resolveHandler(executionId, key, callback);\n }\n}\n\n// ---------------------------------------------------------------------------\n// Mock: tailor.context\n// ---------------------------------------------------------------------------\n\n// Stub-only injection. SDK consumers configure invokers at the body level\n// (resolver/executor/workflow `.body()` `invoker` arg) or, for bundled tests,\n// via `vi.spyOn(globalThis.tailor.context, \"getInvoker\")`.\nfunction mockGetInvoker(): ContextInvoker | null {\n return null;\n}\n\n// ---------------------------------------------------------------------------\n// Mock: tailor.secretmanager\n// ---------------------------------------------------------------------------\n\nasync function mockGetSecrets<const T extends readonly string[]>(\n vault: string,\n names: T,\n): Promise<Partial<Record<T[number], string>>> {\n const state = getState();\n state.secretCalls.push({ method: \"getSecrets\", vault, names });\n const vaultData = state.secretStore[vault] ?? {};\n const result: Record<string, string> = {};\n for (const name of names) {\n if (name in vaultData) {\n result[name] = vaultData[name];\n }\n }\n return result as Partial<Record<T[number], string>>;\n}\n\nasync function mockGetSecret(vault: string, name: string): Promise<string | undefined> {\n const state = getState();\n state.secretCalls.push({ method: \"getSecret\", vault, name });\n return state.secretStore[vault]?.[name];\n}\n\n// ---------------------------------------------------------------------------\n// Mock: tailor.authconnection\n// ---------------------------------------------------------------------------\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nasync function mockGetConnectionToken(connectionName: string): Promise<any> {\n const state = getState();\n state.authCalls.push({ connectionName });\n return state.authTokens[connectionName] ?? { access_token: \"mock-token\" };\n}\n\n// ---------------------------------------------------------------------------\n// Mock: tailor.idp\n// ---------------------------------------------------------------------------\n\nconst IDP_DEFAULTS: Record<string, unknown> = {\n users: { users: [], nextPageToken: null, totalCount: 0 },\n user: { id: \"mock-id\", name: \"mock-user\", disabled: false },\n userByName: { id: \"mock-id\", name: \"mock-user\", disabled: false },\n createUser: { id: \"mock-id\", name: \"mock-user\", disabled: false },\n updateUser: { id: \"mock-id\", name: \"mock-user\", disabled: false },\n deleteUser: true,\n sendPasswordResetEmail: true,\n};\n\nfunction resolveIdpCall(method: string, args: unknown[], namespace: string): unknown {\n const state = getState();\n state.idpCalls.push({ method, args, namespace });\n if (state.idpResultQueue.length > 0) return state.idpResultQueue.shift();\n const resolved = state.idpResolver(method, args, namespace);\n // Treat null and undefined alike as \"no override\" — resolvers commonly\n // `return null` for unmatched methods.\n if (resolved != null) return resolved;\n // Clone the default so a test mutating the returned value (e.g.\n // `result.users.push(x)`) cannot corrupt the shared module-level object\n // for subsequent tests in the same worker.\n const fallback = IDP_DEFAULTS[method];\n return fallback === undefined ? undefined : structuredClone(fallback);\n}\n\nclass MockIdpClient {\n #namespace: string;\n constructor(config: { namespace: string }) {\n this.#namespace = config.namespace;\n }\n async users(options?: {\n first?: number;\n after?: string;\n query?: { ids?: string[]; names?: string[] };\n }): Promise<{ users: IdpUser[]; nextPageToken: string | null; totalCount: number }> {\n return resolveIdpCall(\"users\", [options], this.#namespace) as Awaited<\n ReturnType<typeof this.users>\n >;\n }\n async user(userId: string): Promise<IdpUser> {\n return resolveIdpCall(\"user\", [userId], this.#namespace) as IdpUser;\n }\n async userByName(name: string): Promise<IdpUser> {\n return resolveIdpCall(\"userByName\", [name], this.#namespace) as IdpUser;\n }\n async createUser(input: {\n name: string;\n password?: string;\n disabled?: boolean;\n }): Promise<IdpUser> {\n return resolveIdpCall(\"createUser\", [input], this.#namespace) as IdpUser;\n }\n async updateUser(input: {\n id: string;\n name?: string;\n password?: string;\n clearPassword?: boolean;\n disabled?: boolean;\n }): Promise<IdpUser> {\n return resolveIdpCall(\"updateUser\", [input], this.#namespace) as IdpUser;\n }\n async deleteUser(userId: string): Promise<boolean> {\n return resolveIdpCall(\"deleteUser\", [userId], this.#namespace) as boolean;\n }\n async sendPasswordResetEmail(input: { userId: string; redirectUri: string }): Promise<boolean> {\n return resolveIdpCall(\"sendPasswordResetEmail\", [input], this.#namespace) as boolean;\n }\n}\n\n// ---------------------------------------------------------------------------\n// Mock: tailor.iconv\n// ---------------------------------------------------------------------------\n\n// Iconv methods return `string` for UTF-8 target encodings and `Uint8Array`\n// for any other byte-producing encoding (the platform API mirrors this).\n// Default returns must respect that contract so tests that don't configure a\n// resolver still get type-consistent values.\nfunction isUtf8(encoding: unknown): boolean {\n return encoding === \"UTF8\" || encoding === \"UTF-8\";\n}\n\nfunction defaultIconvResult(method: string, args: unknown[]): unknown {\n switch (method) {\n case \"convert\":\n case \"convertBuffer\":\n return isUtf8(args[2]) ? \"\" : new Uint8Array();\n case \"decode\":\n return \"\";\n case \"encode\":\n return isUtf8(args[1]) ? \"\" : new Uint8Array();\n case \"encodings\":\n return [];\n default:\n return undefined;\n }\n}\n\nfunction resolveIconvCall(method: string, args: unknown[]): unknown {\n const state = getState();\n state.iconvCalls.push({ method, args: [...args] });\n if (state.iconvResolver) {\n const result = state.iconvResolver(method, args);\n // Treat both null and undefined as \"no override\" so resolvers using\n // implicit returns (e.g. early `return;` for unhandled methods) still\n // fall through to the type-consistent default.\n if (result != null) return result;\n }\n return defaultIconvResult(method, args);\n}\n\nfunction mockConvert<T extends string>(\n str: string | Uint8Array | ArrayBuffer,\n fromEncoding: string,\n toEncoding: T,\n): T extends \"UTF8\" | \"UTF-8\" ? string : Uint8Array {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return resolveIconvCall(\"convert\", [str, fromEncoding, toEncoding]) as any;\n}\n\nfunction mockConvertBuffer<T extends string>(\n buffer: Uint8Array | ArrayBuffer,\n fromEncoding: string,\n toEncoding: T,\n): T extends \"UTF8\" | \"UTF-8\" ? string : Uint8Array {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return resolveIconvCall(\"convertBuffer\", [buffer, fromEncoding, toEncoding]) as any;\n}\n\nfunction mockDecode(buffer: Uint8Array | ArrayBuffer, encoding: string): string {\n return resolveIconvCall(\"decode\", [buffer, encoding]) as string;\n}\n\nfunction mockEncode<T extends string>(\n str: string,\n encoding: T,\n): T extends \"UTF8\" | \"UTF-8\" ? string : Uint8Array {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return resolveIconvCall(\"encode\", [str, encoding]) as any;\n}\n\nfunction mockEncodings(): string[] {\n return resolveIconvCall(\"encodings\", []) as string[];\n}\n\nclass MockIconv {\n #fromEncoding: string;\n #toEncoding: string;\n\n constructor(fromEncoding: string, toEncoding: string) {\n this.#fromEncoding = fromEncoding;\n this.#toEncoding = toEncoding;\n }\n\n convert(input: string | Uint8Array | ArrayBuffer): string | Uint8Array {\n return resolveIconvCall(\"convert\", [input, this.#fromEncoding, this.#toEncoding]) as\n | string\n | Uint8Array;\n }\n}\n\n// ---------------------------------------------------------------------------\n// Mock: tailordb.file\n// ---------------------------------------------------------------------------\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst FILE_DEFAULTS: Record<string, any> = {\n upload: { metadata: { fileSize: 0, sha256sum: \"\" } },\n download: {\n data: new Uint8Array(),\n metadata: { contentType: \"\", fileSize: 0, sha256sum: \"\", lastUploadedAt: \"\" },\n },\n downloadAsBase64: {\n data: \"\",\n metadata: { contentType: \"\", fileSize: 0, sha256sum: \"\", lastUploadedAt: \"\" },\n },\n delete: undefined,\n getMetadata: { contentType: \"\", fileSize: 0, sha256sum: \"\", urlPath: \"\" },\n};\n\nfunction resolveFileCall(\n method: string,\n namespace: string,\n typeName: string,\n fieldName: string,\n recordId: string,\n): unknown {\n const state = getState();\n const call: FileCall = { method, namespace, typeName, fieldName, recordId };\n state.fileCalls.push(call);\n if (state.fileResultQueue.length > 0) return state.fileResultQueue.shift();\n const resolved = state.fileResolver(method, call);\n // Treat null and undefined alike as \"no override\" — resolvers commonly\n // `return null` for unmatched methods.\n if (resolved != null) return resolved;\n // Clone the default so a test mutating the returned value (e.g. the\n // `data: Uint8Array` payload from `download`) cannot corrupt the shared\n // module-level object for subsequent tests in the same worker.\n const fallback = FILE_DEFAULTS[method];\n return fallback === undefined ? undefined : structuredClone(fallback);\n}\n\nconst mockTailordbFile = {\n async upload(\n namespace: string,\n typeName: string,\n fieldName: string,\n recordId: string,\n _data: string | ArrayBuffer | Uint8Array | number[],\n _options?: { contentType?: string },\n ): Promise<{ metadata: { fileSize: number; sha256sum: string } }> {\n return resolveFileCall(\"upload\", namespace, typeName, fieldName, recordId) as Awaited<\n ReturnType<typeof this.upload>\n >;\n },\n async download(\n namespace: string,\n typeName: string,\n fieldName: string,\n recordId: string,\n ): Promise<{\n data: Uint8Array;\n metadata: { contentType: string; fileSize: number; sha256sum: string; lastUploadedAt: string };\n }> {\n return resolveFileCall(\"download\", namespace, typeName, fieldName, recordId) as Awaited<\n ReturnType<typeof this.download>\n >;\n },\n async downloadAsBase64(\n namespace: string,\n typeName: string,\n fieldName: string,\n recordId: string,\n ): Promise<{\n data: string;\n metadata: { contentType: string; fileSize: number; sha256sum: string; lastUploadedAt: string };\n }> {\n return resolveFileCall(\"downloadAsBase64\", namespace, typeName, fieldName, recordId) as Awaited<\n ReturnType<typeof this.downloadAsBase64>\n >;\n },\n async delete(\n namespace: string,\n typeName: string,\n fieldName: string,\n recordId: string,\n ): Promise<void> {\n resolveFileCall(\"delete\", namespace, typeName, fieldName, recordId);\n },\n async getMetadata(\n namespace: string,\n typeName: string,\n fieldName: string,\n recordId: string,\n ): Promise<{\n contentType: string;\n fileSize: number;\n sha256sum: string;\n urlPath: string;\n lastUploadedAt?: string;\n }> {\n return resolveFileCall(\"getMetadata\", namespace, typeName, fieldName, recordId) as Awaited<\n ReturnType<typeof this.getMetadata>\n >;\n },\n async openDownloadStream(\n namespace: string,\n typeName: string,\n fieldName: string,\n recordId: string,\n ): Promise<AsyncIterableIterator<unknown> & { close(): Promise<void> }> {\n const resolved = resolveFileCall(\n \"openDownloadStream\",\n namespace,\n typeName,\n fieldName,\n recordId,\n );\n return toFileStream(resolved);\n },\n};\n\ntype FileStream = AsyncIterableIterator<unknown> & { close(): Promise<void> };\n\nfunction toFileStream(value: unknown): FileStream {\n // Already a complete stream-like object: pass through.\n if (\n value !== null &&\n typeof value === \"object\" &&\n Symbol.asyncIterator in value &&\n typeof (value as { close?: unknown }).close === \"function\"\n ) {\n return value as FileStream;\n }\n // Guard against passing raw bytes directly: `Uint8Array` is iterable as\n // numbers, which would silently yield byte values as chunks. The platform's\n // stream protocol emits structured `StreamValue` items, so callers must\n // enqueue an iterable of `StreamValue` instead.\n if (value instanceof ArrayBuffer || ArrayBuffer.isView(value)) {\n throw new TypeError(\n \"fileMock.openDownloadStream expects an iterable of StreamValue items \" +\n '(e.g. [{ type: \"chunk\", data, position }, { type: \"complete\" }]); ' +\n \"got raw bytes. Wrap the bytes in a structured chunk first.\",\n );\n }\n // Iterable (array, sync iterator, etc.): wrap as a chunked async iterator\n // so `fileMock.enqueueResult([{ type: \"metadata\", ... }, { type: \"chunk\", ... }, ...])`\n // controls stream contents. The platform emits structured StreamValue items;\n // tests should enqueue an iterable of StreamValue to mirror that contract.\n if (\n value !== null &&\n typeof value === \"object\" &&\n (Symbol.iterator in value || Symbol.asyncIterator in value)\n ) {\n const source = value as Iterable<unknown> | AsyncIterable<unknown>;\n const inner =\n Symbol.asyncIterator in source\n ? (source as AsyncIterable<unknown>)[Symbol.asyncIterator]()\n : (source as Iterable<unknown>)[Symbol.iterator]();\n const stream: FileStream = {\n async next() {\n const r = await inner.next();\n if (!r.done) {\n assertStreamValue(r.value);\n }\n return r.done ? { done: true as const, value: undefined } : r;\n },\n async close() {},\n [Symbol.asyncIterator]() {\n return stream;\n },\n };\n return stream;\n }\n const empty: FileStream = {\n async next() {\n return { done: true as const, value: undefined };\n },\n async close() {},\n [Symbol.asyncIterator]() {\n return empty;\n },\n };\n return empty;\n}\n\nfunction assertStreamValue(v: unknown): void {\n if (v === null || typeof v !== \"object\") {\n throw new TypeError(\n 'fileMock.openDownloadStream expected a StreamValue item ({ type: \"metadata\" | \"chunk\" | \"complete\", ... }); ' +\n `got ${typeof v === \"object\" ? \"null\" : typeof v}.`,\n );\n }\n // ArrayBuffer / TypedArray are objects but never valid StreamValue items.\n if (v instanceof ArrayBuffer || ArrayBuffer.isView(v)) {\n throw new TypeError(\n \"fileMock.openDownloadStream expected a StreamValue item, got raw bytes. \" +\n 'Wrap the bytes in a structured chunk first (e.g. { type: \"chunk\", data, position }).',\n );\n }\n const type = (v as { type?: unknown }).type;\n if (type !== \"metadata\" && type !== \"chunk\" && type !== \"complete\") {\n throw new TypeError(\n 'fileMock.openDownloadStream expected a StreamValue item with type \"metadata\" | \"chunk\" | \"complete\"; ' +\n `got ${JSON.stringify(type)}.`,\n );\n }\n}\n\n// ---------------------------------------------------------------------------\n// Error class mocks\n// ---------------------------------------------------------------------------\n\ninterface TailorErrorItem {\n message: string;\n path: (string | number)[];\n}\n\nclass TailorErrorsMock extends Error {\n errors: TailorErrorItem[];\n\n constructor(errors: TailorErrorItem[]) {\n if (!Array.isArray(errors)) {\n throw new TypeError(\"TailorErrors: errors must be an array\");\n }\n const validated = errors.map((e, i) => {\n if (typeof e.message !== \"string\") {\n throw new TypeError(`TailorErrors: errors[${i}].message must be a string`);\n }\n if (!Array.isArray(e.path)) {\n throw new TypeError(`TailorErrors: errors[${i}].path must be an array`);\n }\n return { message: e.message, path: e.path };\n });\n // Match the PF runtime's TailorErrors serialization, which prefixes the\n // JSON payload with \"TailorErrors: \". Other SDK code (e.g. apply\n // integration fixtures) strips this prefix before JSON.parse.\n super(`TailorErrors: ${JSON.stringify({ errors: validated })}`);\n this.name = \"TailorErrors\";\n this.errors = validated;\n }\n}\n\nclass TailorErrorMessageMock extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"TailorErrorMessage\";\n }\n}\n\nclass TailorDBFileErrorMock extends Error {\n code?: TailorDBFileErrorCode;\n override cause: unknown;\n\n constructor(message: string, code?: TailorDBFileErrorCode, cause?: unknown) {\n super(message);\n this.name = \"TailorDBFileError\";\n this.code = code;\n this.cause = cause;\n }\n}\n\n// ---------------------------------------------------------------------------\n// Injection / Cleanup (called by environment.ts)\n// ---------------------------------------------------------------------------\n\n/**\n * Inject all platform API mocks into globalThis.\n * Called by the tailor-runtime Vitest environment during setup.\n * @param global - The global object to inject mocks into\n */\nexport function injectMocks(global: typeof globalThis): void {\n const g = global as Record<string, unknown>;\n\n // Ensure fresh state and mark the environment as active so setup.ts can\n // distinguish \"tailor-runtime is selected\" from \"some test code happened\n // to read a mock helper and lazily created STATE_KEY\".\n g[STATE_KEY] = createDefaultState();\n g[RUNTIME_FLAG_KEY] = true;\n\n g.tailordb = {\n Client: MockTailordbClient,\n file: mockTailordbFile,\n };\n\n g.tailor = {\n secretmanager: {\n getSecrets: mockGetSecrets,\n getSecret: mockGetSecret,\n },\n authconnection: {\n getConnectionToken: mockGetConnectionToken,\n },\n workflow: {\n triggerJobFunction: mockTriggerJobFunction,\n triggerWorkflow: mockTriggerWorkflow,\n wait: mockWait,\n resolve: mockResolve,\n },\n context: {\n getInvoker: mockGetInvoker,\n },\n idp: { Client: MockIdpClient },\n iconv: {\n convert: mockConvert,\n convertBuffer: mockConvertBuffer,\n decode: mockDecode,\n encode: mockEncode,\n encodings: mockEncodings,\n Iconv: MockIconv,\n },\n };\n\n g.TailorErrors = TailorErrorsMock;\n g.TailorErrorMessage = TailorErrorMessageMock;\n g.TailorDBFileError = TailorDBFileErrorMock;\n}\n\n/**\n * Remove all injected mocks from globalThis.\n * Called by the tailor-runtime Vitest environment during teardown.\n * @param global - The global object to clean up mocks from\n */\nexport function cleanupMocks(global: typeof globalThis): void {\n const g = global as Record<string, unknown>;\n delete g.tailordb;\n delete g.tailor;\n delete g.TailorErrors;\n delete g.TailorErrorMessage;\n delete g.TailorDBFileError;\n delete g[STATE_KEY];\n delete g[RUNTIME_FLAG_KEY];\n clearWorkflowTestEnv();\n}\n"],"mappings":";;;;;;;;;;;AA0IA,MAAa,YAAY;AAOzB,MAAa,mBAAmB;AAEhC,SAAS,WAAsB;CAC7B,MAAM,IAAI;CACV,IAAI,CAAC,wBACH,EAAE,aAAa,mBAAmB;CAEpC,OAAO,EAAE;AACX;AAEA,SAAS,qBAAgC;CACvC,OAAO;EACL,qBAAqB,CAAC;EACtB,kBAAkB,CAAC;EACnB,iBAAiB,CAAC;EAClB,gBAAgB,CAAC;EACjB,kBAAkB;EAClB,gBAAgB,CAAC;EACjB,eAAe,CAAC;EAChB,gBAAgB;EAChB,aAAa;EACb,gBAAgB;EAChB,eAAe,CAAC;EAChB,aAAa,CAAC;EACd,aAAa,CAAC;EACd,YAAY,CAAC;EACb,WAAW,CAAC;EACZ,mBAAmB;EACnB,gBAAgB,CAAC;EACjB,UAAU,CAAC;EACX,oBAAoB;EACpB,iBAAiB,CAAC;EAClB,WAAW,CAAC;EACZ,eAAe;EACf,YAAY,CAAC;CACf;AACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiCA,MAAa,eAAe;;;;;CAK1B,iBAAiB,UAA+B;EAC9C,SAAS,EAAE,gBAAgB;CAC7B;;;;;;;;;CAUA,cAAc,GAAG,MAAuB;EACtC,SAAS,EAAE,iBAAiB,KAAK,IAAI;CACvC;;;;;;CAOA,eAAe,GAAG,UAA6B;EAC7C,SAAS,EAAE,iBAAiB,KAAK,GAAG,QAAQ;CAC9C;;;;;CAMA,IAAI,kBAAmC;EACrC,OAAO,SAAS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