@tailor-platform/sdk 2.4.0 → 2.6.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 +131 -0
- package/bin/tailor.mjs +3 -2
- package/dist/aigateway-DsWDjzk4.mjs +2 -0
- package/dist/{aigateway-DR4Kwuik.mjs.map → aigateway-DsWDjzk4.mjs.map} +1 -1
- package/dist/application-CNeOcaLc.mjs +1 -0
- package/dist/application-CmXOqTaK.mjs +192 -0
- package/dist/application-CmXOqTaK.mjs.map +1 -0
- package/dist/assert-WeXvmG4j.mjs +2 -0
- package/dist/{assert-DBxo8jPo.mjs.map → assert-WeXvmG4j.mjs.map} +1 -1
- package/dist/authconnection-CynFBIv8.mjs +2 -0
- package/dist/{authconnection-CZvi9ANm.mjs.map → authconnection-CynFBIv8.mjs.map} +1 -1
- package/dist/brand-C8nMKhJC.mjs +2 -0
- package/dist/{brand-Eo4pLXPJ.mjs.map → brand-C8nMKhJC.mjs.map} +1 -1
- package/dist/cli/commands/api/index.d.mts +1 -1
- package/dist/cli/commands/deploy/deploy.d.mts +2 -2
- package/dist/cli/commands/deploy/deployment-target.d.mts +2 -0
- package/dist/cli/commands/deploy/event-subscriptions.d.mts +3 -0
- package/dist/cli/commands/deploy/tailordb/apply.d.mts +3 -0
- package/dist/cli/commands/deploy/tailordb/index.d.mts +3 -10
- package/dist/cli/commands/deploy/tailordb/migration-validation.d.mts +5 -0
- package/dist/cli/commands/deploy/tailordb/plan.d.mts +8 -0
- package/dist/cli/commands/executor/jobs.d.mts +1 -1
- package/dist/cli/commands/executor/trigger.d.mts +1 -1
- package/dist/cli/commands/generate/seed/bundler.d.mts +2 -2
- package/dist/cli/commands/show.d.mts +1 -1
- package/dist/cli/commands/tailordb/migrate/diff-calculator.d.mts +11 -11
- package/dist/cli/commands/tailordb/migrate/generate.d.mts +4 -0
- package/dist/cli/commands/tailordb/migrate/rename-detection.d.mts +1 -1
- package/dist/cli/commands/tailordb/migrate/snapshot-comparison.d.mts +43 -0
- package/dist/cli/commands/tailordb/migrate/snapshot-files.d.mts +62 -0
- package/dist/cli/commands/tailordb/migrate/snapshot-local.d.mts +12 -0
- package/dist/cli/commands/tailordb/migrate/snapshot-migrations.d.mts +12 -0
- package/dist/cli/commands/tailordb/migrate/snapshot-remote.d.mts +1 -0
- package/dist/cli/commands/tailordb/migrate/snapshot-types.d.mts +3 -1
- package/dist/cli/commands/tailordb/migrate/snapshot.d.mts +5 -117
- package/dist/cli/commands/workflow/start.d.mts +1 -1
- package/dist/cli/commands/workspace/list.d.mts +1 -1
- package/dist/cli/lib.d.mts +12 -4
- package/dist/cli/lib.mjs +1 -9
- package/dist/cli/lib.mjs.map +1 -1
- package/dist/cli/main.d.mts +2 -0
- package/dist/cli/main.mjs +1170 -7754
- package/dist/cli/main.mjs.map +1 -1
- package/dist/cli/shared/args.d.mts +65 -1
- package/dist/cli/shared/command.d.mts +11 -0
- package/dist/cli/shared/context.d.mts +1 -1
- package/dist/cli/shared/logger.d.mts +64 -0
- package/dist/cli/shared/script-executor.d.mts +1 -1
- package/dist/cli/shared/seed-chunker.d.mts +5 -5
- package/dist/completion/zsh-worker.zsh +82 -9
- package/dist/configure/config/index.d.mts +1 -1
- package/dist/configure/config/types.d.mts +2 -2
- package/dist/configure/index.d.mts +48 -12
- package/dist/configure/index.mjs +1 -1267
- package/dist/configure/index.mjs.map +1 -1
- package/dist/configure/services/auth/types.d.mts +1 -1
- package/dist/configure/services/idp/types.d.mts +1 -1
- package/dist/configure/services/tailordb/schema.d.mts +22 -8
- package/dist/configure/services/tailordb/types.d.mts +2 -2
- package/dist/configure/services/workflow/execution-policy.d.mts +3 -3
- package/dist/configure/services/workflow/job.d.mts +12 -2
- package/dist/configure/types/field.types.d.mts +1 -1
- package/dist/configure/types/permission-operand.types.d.mts +1 -1
- package/dist/context-D0QjfxzD.mjs +2 -0
- package/dist/{context-DYQVYWqZ.mjs.map → context-D0QjfxzD.mjs.map} +1 -1
- package/dist/crashreport-BN28xp5B.mjs +42 -0
- package/dist/{crashreport-Q0pDAlrj.mjs.map → crashreport-BN28xp5B.mjs.map} +1 -1
- package/dist/crashreport-By23O2k-.mjs +1 -0
- package/dist/errors-DLsQ_-ol.mjs +2 -0
- package/dist/errors-DLsQ_-ol.mjs.map +1 -0
- package/dist/es-builtins-n3wBv4Sv.mjs +2 -0
- package/dist/es-builtins-n3wBv4Sv.mjs.map +1 -0
- package/dist/file-COPYfju_.mjs +2 -0
- package/dist/file-COPYfju_.mjs.map +1 -0
- package/dist/globals-CMHSnj4w.mjs +2 -0
- package/dist/{globals-B2nlxBrz.mjs.map → globals-CMHSnj4w.mjs.map} +1 -1
- package/dist/iconv-DlFMt2gW.mjs +2 -0
- package/dist/{iconv-QWaZh0TT.mjs.map → iconv-DlFMt2gW.mjs.map} +1 -1
- package/dist/idp-G_ojPBB5.mjs +2 -0
- package/dist/{idp-RA_swu-h.mjs.map → idp-G_ojPBB5.mjs.map} +1 -1
- package/dist/interceptor-DQg3cR_9.mjs +2 -0
- package/dist/{interceptor-e33JtsC-.mjs.map → interceptor-DQg3cR_9.mjs.map} +1 -1
- package/dist/kysely/index.mjs +1 -32
- package/dist/kysely/index.mjs.map +1 -1
- package/dist/kysely-type-BTi3BMtL.mjs +43 -0
- package/dist/kysely-type-BTi3BMtL.mjs.map +1 -0
- package/dist/logger-CCjs1DuH.mjs +9 -0
- package/dist/logger-CCjs1DuH.mjs.map +1 -0
- package/dist/logger-DP2BjQ93.mjs +2 -0
- package/dist/{logger-BtX0suGY.mjs.map → logger-DP2BjQ93.mjs.map} +1 -1
- package/dist/multiline-EyzjEwn9.mjs +3 -0
- package/dist/{multiline-sfHpTZZK.mjs.map → multiline-EyzjEwn9.mjs.map} +1 -1
- package/dist/node-builtins-oBl7EbyV.mjs +2 -0
- package/dist/{node-builtins-CmaL2Cbq.mjs.map → node-builtins-oBl7EbyV.mjs.map} +1 -1
- package/dist/package-json-C690ceex.mjs +2 -0
- package/dist/{package-json-8b0O9TlX.mjs.map → package-json-C690ceex.mjs.map} +1 -1
- package/dist/package-json-CmqhDJ__.mjs +1 -0
- package/dist/parser/service/tailordb/type-source.d.mts +5 -5
- package/dist/parser/service/tailordb/types.d.mts +4 -4
- package/dist/platform-serialize-DkiTdHOt.mjs +2 -0
- package/dist/{platform-serialize-RoRtBS0v.mjs.map → platform-serialize-DkiTdHOt.mjs.map} +1 -1
- package/dist/plugin/builtin/enum-constants/index.mjs +5 -114
- package/dist/plugin/builtin/enum-constants/index.mjs.map +1 -1
- package/dist/plugin/builtin/file-utils/index.mjs +22 -104
- package/dist/plugin/builtin/file-utils/index.mjs.map +1 -1
- package/dist/plugin/builtin/kysely-type/index.d.mts +8 -1
- package/dist/plugin/builtin/kysely-type/index.mjs +1 -275
- package/dist/plugin/builtin/seed/index.d.mts +5 -0
- package/dist/plugin/builtin/seed/index.mjs +1 -3
- package/dist/plugin/builtin/seed/seed-type-processor.d.mts +0 -2
- package/dist/plugin/{get-generated-type.d.mts → get-generated-table.d.mts} +5 -5
- package/dist/plugin/index.d.mts +3 -2
- package/dist/plugin/index.mjs +1 -251
- package/dist/plugin/index.mjs.map +1 -1
- package/dist/plugin/types.d.mts +30 -23
- package/dist/plugin/with-context.d.mts +3 -3
- package/dist/register-ts-hook-oDA2JLp2.mjs +640 -0
- package/dist/register-ts-hook-oDA2JLp2.mjs.map +1 -0
- package/dist/registry-HlEaGvl5.mjs +2 -0
- package/dist/{registry-BIGVUrMB.mjs.map → registry-HlEaGvl5.mjs.map} +1 -1
- package/dist/repl-editor-BG1aDOfH.mjs +2 -0
- package/dist/{repl-editor-F9LotMNx.mjs.map → repl-editor-BG1aDOfH.mjs.map} +1 -1
- package/dist/runtime/aigateway.mjs +1 -3
- package/dist/runtime/authconnection.mjs +1 -3
- package/dist/runtime/context.mjs +1 -3
- package/dist/runtime/file.d.mts +21 -21
- package/dist/runtime/file.mjs +1 -3
- package/dist/runtime/globals.mjs +1 -1
- package/dist/runtime/iconv.mjs +1 -3
- package/dist/runtime/idp.mjs +1 -3
- package/dist/runtime/index.mjs +1 -11
- package/dist/runtime/logger.mjs +1 -3
- package/dist/runtime/secretmanager.mjs +1 -3
- package/dist/runtime/types.d.mts +1 -1
- package/dist/runtime/workflow.mjs +1 -3
- package/dist/schema-AYG4OhXY.mjs +2 -0
- package/dist/schema-AYG4OhXY.mjs.map +1 -0
- package/dist/secret-file-C9wp_FCX.mjs +2 -0
- package/dist/{secret-file-C3J4Gy8r.mjs.map → secret-file-C9wp_FCX.mjs.map} +1 -1
- package/dist/secretmanager-5olfnI1b.mjs +2 -0
- package/dist/{secretmanager-IY4UvinW.mjs.map → secretmanager-5olfnI1b.mjs.map} +1 -1
- package/dist/secretmanager-vHQoXdQz.mjs +2 -0
- package/dist/{secretmanager-CYlpffsz.mjs.map → secretmanager-vHQoXdQz.mjs.map} +1 -1
- package/dist/seed/index.mjs +8 -244
- package/dist/seed/index.mjs.map +1 -1
- package/dist/seed-DwqRFdqP.mjs +207 -0
- package/dist/seed-DwqRFdqP.mjs.map +1 -0
- package/dist/service-CLPMoj9n.mjs +2 -0
- package/dist/{service-LTfp03ZZ.mjs.map → service-CLPMoj9n.mjs.map} +1 -1
- package/dist/service-D7iXk0BT.mjs +1 -0
- package/dist/service-YqDsHmlK.mjs +7 -0
- package/dist/service-YqDsHmlK.mjs.map +1 -0
- package/dist/service_pb-DGKCLuAs.mjs +2 -0
- package/dist/{service_pb-BEWj1pOV.mjs.map → service_pb-DGKCLuAs.mjs.map} +1 -1
- package/dist/service_pb-_aeFE-Nv.mjs +1 -0
- package/dist/shared/src/color.d.mts +5 -0
- package/dist/tailor-proto/src/tailor/v1/workspace_pb.d.mts +1 -1
- package/dist/telemetry-Bklv9kQY.mjs +2 -0
- package/dist/{telemetry-BRVdwh14.mjs.map → telemetry-Bklv9kQY.mjs.map} +1 -1
- package/dist/telemetry-DXHP3VVi.mjs +1 -0
- package/dist/type-source--ZNcV8RJ.mjs +2 -0
- package/dist/type-source--ZNcV8RJ.mjs.map +1 -0
- package/dist/types/executor.generated.d.mts +1 -1
- package/dist/user-agent-vdHYF3QL.mjs +2 -0
- package/dist/{user-agent-Bgsszb5I.mjs.map → user-agent-vdHYF3QL.mjs.map} +1 -1
- package/dist/utils/test/index.mjs +1 -109
- package/dist/utils/test/index.mjs.map +1 -1
- package/dist/vitest/environment.mjs +1 -41
- package/dist/vitest/environment.mjs.map +1 -1
- package/dist/vitest/index.mjs +1 -1986
- package/dist/vitest/index.mjs.map +1 -1
- package/dist/vitest/mocks/file.d.mts +8 -8
- package/dist/vitest/setup.mjs +1 -140
- package/dist/vitest/setup.mjs.map +1 -1
- package/dist/wait-point-invoker-eiP-IIux.mjs +2 -0
- package/dist/wait-point-invoker-eiP-IIux.mjs.map +1 -0
- package/dist/wait-point-registry-B-ESkTZX.mjs +2 -0
- package/dist/wait-point-registry-B-ESkTZX.mjs.map +1 -0
- package/dist/workflow-Cs9ISw6j.mjs +2 -0
- package/dist/{workflow-Bamae_Yc.mjs.map → workflow-Cs9ISw6j.mjs.map} +1 -1
- package/dist/workspace_resource_pb--GeYQPXu.mjs +2 -0
- package/dist/{workspace_resource_pb-HNIL_Vfj.mjs.map → workspace_resource_pb--GeYQPXu.mjs.map} +1 -1
- package/docs/cli/function.md +66 -6
- package/docs/cli/setup.md +24 -14
- package/docs/cli/tailordb.md +2 -0
- package/docs/cli-reference.md +9 -8
- package/docs/github-actions.md +14 -12
- package/docs/migration/v2.md +18 -2
- package/docs/migration/v3.md +121 -0
- package/docs/plugin/custom.md +130 -85
- package/docs/plugin/index.md +3 -3
- package/docs/services/tailordb-migration.md +21 -7
- package/docs/services/tailordb.md +9 -7
- package/docs/services/workflow.md +10 -9
- package/package.json +14 -13
- package/postinstall.mjs +1 -1
- package/dist/aigateway-DR4Kwuik.mjs +0 -9
- package/dist/application-C8a0UJ-z.mjs +0 -6071
- package/dist/application-C8a0UJ-z.mjs.map +0 -1
- package/dist/application-D4zOiLLa.mjs +0 -3
- package/dist/assert-DBxo8jPo.mjs +0 -9
- package/dist/authconnection-CZvi9ANm.mjs +0 -9
- package/dist/brand-Eo4pLXPJ.mjs +0 -36
- package/dist/context-DYQVYWqZ.mjs +0 -23
- package/dist/crashreport-Cd4TqfZq.mjs +0 -3
- package/dist/crashreport-Q0pDAlrj.mjs +0 -427
- package/dist/errors-Bxut5_Sy.mjs +0 -89
- package/dist/errors-Bxut5_Sy.mjs.map +0 -1
- package/dist/file-BUcmVIH2.mjs +0 -58
- package/dist/file-BUcmVIH2.mjs.map +0 -1
- package/dist/globals-B2nlxBrz.mjs +0 -126
- package/dist/iconv-QWaZh0TT.mjs +0 -38
- package/dist/idp-RA_swu-h.mjs +0 -82
- package/dist/interceptor-e33JtsC-.mjs +0 -33
- package/dist/logger-BtX0suGY.mjs +0 -48
- package/dist/logger-D0bEznPv.mjs +0 -362
- package/dist/logger-D0bEznPv.mjs.map +0 -1
- package/dist/multiline-sfHpTZZK.mjs +0 -38
- package/dist/node-builtins-CmaL2Cbq.mjs +0 -36
- package/dist/package-json-8b0O9TlX.mjs +0 -17
- package/dist/package-json-Cv2Z-TqQ.mjs +0 -3
- package/dist/platform-serialize-RoRtBS0v.mjs +0 -46
- package/dist/plugin/builtin/kysely-type/index.mjs.map +0 -1
- package/dist/plugin/builtin/seed/types.d.mts +0 -2
- package/dist/register-ts-hook-Vqjza10T.mjs +0 -25679
- package/dist/register-ts-hook-Vqjza10T.mjs.map +0 -1
- package/dist/registry-BIGVUrMB.mjs +0 -54
- package/dist/repl-editor-F9LotMNx.mjs +0 -252
- package/dist/schema-D4TC4BC3.mjs +0 -640
- package/dist/schema-D4TC4BC3.mjs.map +0 -1
- package/dist/secret-file-C3J4Gy8r.mjs +0 -64
- package/dist/secretmanager-CYlpffsz.mjs +0 -13
- package/dist/secretmanager-IY4UvinW.mjs +0 -131
- package/dist/seed-Cibjmtry.mjs +0 -489
- package/dist/seed-Cibjmtry.mjs.map +0 -1
- package/dist/service-2grcAOCJ.mjs +0 -898
- package/dist/service-2grcAOCJ.mjs.map +0 -1
- package/dist/service-CaBPNDIZ.mjs +0 -3
- package/dist/service-LTfp03ZZ.mjs +0 -133
- package/dist/service_pb-BEWj1pOV.mjs +0 -167
- package/dist/service_pb-BjlhvK9E.mjs +0 -3
- package/dist/telemetry-BRVdwh14.mjs +0 -84
- package/dist/telemetry-CkbkeJxl.mjs +0 -3
- package/dist/type-source-DH_LH20p.mjs +0 -13
- package/dist/type-source-DH_LH20p.mjs.map +0 -1
- package/dist/user-agent-Bgsszb5I.mjs +0 -28
- package/dist/wait-point-invoker-__oE88_P.mjs +0 -148
- package/dist/wait-point-invoker-__oE88_P.mjs.map +0 -1
- package/dist/wait-point-registry-TL99zotw.mjs +0 -47
- package/dist/wait-point-registry-TL99zotw.mjs.map +0 -1
- package/dist/workflow-Bamae_Yc.mjs +0 -34
- package/dist/workspace_resource_pb-HNIL_Vfj.mjs +0 -860
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../../../../src/plugin/builtin/enum-constants/generate-enum-constants.ts","../../../../src/plugin/builtin/enum-constants/process-enum-type.ts","../../../../src/plugin/builtin/enum-constants/index.ts"],"sourcesContent":["import type { EnumDefinition } from \"./types\";\n\n/**\n * Generate enum constant definitions from collected metadata.\n * @param allEnums - All collected enum definitions\n * @returns Generated enum constant definitions\n */\nexport function generateUnifiedEnumConstants(allEnums: EnumDefinition[]): string {\n if (allEnums.length === 0) {\n return \"\";\n }\n\n const enumMap = new Map<string, EnumDefinition>();\n for (const enumDef of allEnums) {\n enumMap.set(enumDef.name, enumDef);\n }\n\n const enumDefs = Array.from(enumMap.values())\n .map((e) => {\n const members = e.values\n .map((v) => {\n const key = v.value.replace(/[-\\s]/g, \"_\");\n return ` \"${key}\": \"${v.value}\"`;\n })\n .join(\",\\n\");\n\n const hasDescriptions = e.values.some((v) => v.description);\n let jsDoc = \"\";\n if (e.fieldDescription || hasDescriptions) {\n const lines: string[] = [];\n\n if (e.fieldDescription) {\n lines.push(` * ${e.fieldDescription}`);\n if (hasDescriptions) {\n lines.push(\" *\");\n }\n }\n\n if (hasDescriptions) {\n const propertyDocs = e.values.map((v) => {\n const key = v.value.replace(/[-\\s]/g, \"_\");\n return ` * @property ${[key, v.description].filter(Boolean).join(\" - \")}`;\n });\n lines.push(...propertyDocs);\n }\n\n if (lines.length > 0) {\n jsDoc = `/**\\n${lines.join(\"\\n\")}\\n */\\n`;\n }\n }\n\n const constDef = `${jsDoc}export const ${e.name} = {\\n${members}\\n} as const;`;\n const typeDef = `export type ${e.name} = (typeof ${e.name})[keyof typeof ${e.name}];`;\n return `${constDef}\\n${typeDef}`;\n })\n .join(\"\\n\\n\");\n\n if (!enumDefs) {\n return \"\";\n }\n\n return enumDefs + \"\\n\";\n}\n","import type { TailorDBType } from \"#/parser/service/tailordb/types\";\nimport type { EnumConstantMetadata } from \"./types\";\n\nfunction capitalizeFirst(str: string): string {\n return str.charAt(0).toUpperCase() + str.slice(1);\n}\n\nfunction collectEnums(type: TailorDBType): EnumConstantMetadata[\"enums\"] {\n const enums: EnumConstantMetadata[\"enums\"] = [];\n\n for (const [fieldName, parsedField] of Object.entries(type.fields)) {\n if (parsedField.config.type === \"enum\" && parsedField.config.allowedValues) {\n const enumTypeName = `${type.name}${capitalizeFirst(fieldName)}`;\n enums.push({\n name: enumTypeName,\n values: parsedField.config.allowedValues,\n fieldDescription: parsedField.config.description,\n });\n }\n\n // Process nested fields\n if (parsedField.config.type === \"nested\" && parsedField.config.fields) {\n for (const [nestedFieldName, nestedFieldConfig] of Object.entries(\n parsedField.config.fields,\n )) {\n if (nestedFieldConfig.type === \"enum\" && nestedFieldConfig.allowedValues) {\n const fullFieldName = `${fieldName}${capitalizeFirst(nestedFieldName)}`;\n const enumTypeName = `${type.name}${capitalizeFirst(fullFieldName)}`;\n enums.push({\n name: enumTypeName,\n values: nestedFieldConfig.allowedValues,\n fieldDescription: nestedFieldConfig.description,\n });\n }\n }\n }\n }\n\n return enums;\n}\n\n/**\n * Process a TailorDB table and extract enum metadata.\n * @param type - The parsed TailorDB table to process\n * @returns Enum constant metadata for the table\n */\nexport async function processEnumType(type: TailorDBType): Promise<EnumConstantMetadata> {\n const enums = collectEnums(type);\n\n return {\n name: type.name,\n enums,\n };\n}\n","import { generateUnifiedEnumConstants } from \"./generate-enum-constants\";\nimport { processEnumType } from \"./process-enum-type\";\nimport type { Plugin, GeneratorResult, TailorDBReadyContext } from \"#/plugin/types\";\nimport type { EnumDefinition } from \"./types\";\n\n/** Unique identifier for the enum constants generator plugin. */\nexport const EnumConstantsGeneratorID = \"@tailor-platform/enum-constants\";\n\ntype EnumConstantsPluginOptions = {\n distPath: string;\n};\n\n/**\n * Plugin that generates enum constants from TailorDB table definitions.\n * @param options - Plugin options\n * @param options.distPath - Output file path for generated constants\n * @returns Plugin instance with onTailorDBReady hook\n */\nexport function enumConstantsPlugin(\n options: EnumConstantsPluginOptions,\n): Plugin<unknown, EnumConstantsPluginOptions> {\n return {\n id: EnumConstantsGeneratorID,\n description: \"Generates enum constants from TailorDB table definitions\",\n pluginConfig: options,\n\n async onTailorDBReady(\n ctx: TailorDBReadyContext<EnumConstantsPluginOptions>,\n ): Promise<GeneratorResult> {\n const allEnums: EnumDefinition[] = [];\n\n for (const ns of ctx.tailordb) {\n for (const type of Object.values(ns.
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../../../src/plugin/builtin/enum-constants/generate-enum-constants.ts","../../../../src/plugin/builtin/enum-constants/process-enum-type.ts","../../../../src/plugin/builtin/enum-constants/index.ts"],"sourcesContent":["import type { EnumDefinition } from \"./types\";\n\n/**\n * Generate enum constant definitions from collected metadata.\n * @param allEnums - All collected enum definitions\n * @returns Generated enum constant definitions\n */\nexport function generateUnifiedEnumConstants(allEnums: EnumDefinition[]): string {\n if (allEnums.length === 0) {\n return \"\";\n }\n\n const enumMap = new Map<string, EnumDefinition>();\n for (const enumDef of allEnums) {\n enumMap.set(enumDef.name, enumDef);\n }\n\n const enumDefs = Array.from(enumMap.values())\n .map((e) => {\n const members = e.values\n .map((v) => {\n const key = v.value.replace(/[-\\s]/g, \"_\");\n return ` \"${key}\": \"${v.value}\"`;\n })\n .join(\",\\n\");\n\n const hasDescriptions = e.values.some((v) => v.description);\n let jsDoc = \"\";\n if (e.fieldDescription || hasDescriptions) {\n const lines: string[] = [];\n\n if (e.fieldDescription) {\n lines.push(` * ${e.fieldDescription}`);\n if (hasDescriptions) {\n lines.push(\" *\");\n }\n }\n\n if (hasDescriptions) {\n const propertyDocs = e.values.map((v) => {\n const key = v.value.replace(/[-\\s]/g, \"_\");\n return ` * @property ${[key, v.description].filter(Boolean).join(\" - \")}`;\n });\n lines.push(...propertyDocs);\n }\n\n if (lines.length > 0) {\n jsDoc = `/**\\n${lines.join(\"\\n\")}\\n */\\n`;\n }\n }\n\n const constDef = `${jsDoc}export const ${e.name} = {\\n${members}\\n} as const;`;\n const typeDef = `export type ${e.name} = (typeof ${e.name})[keyof typeof ${e.name}];`;\n return `${constDef}\\n${typeDef}`;\n })\n .join(\"\\n\\n\");\n\n if (!enumDefs) {\n return \"\";\n }\n\n return enumDefs + \"\\n\";\n}\n","import type { TailorDBType } from \"#/parser/service/tailordb/types\";\nimport type { EnumConstantMetadata } from \"./types\";\n\nfunction capitalizeFirst(str: string): string {\n return str.charAt(0).toUpperCase() + str.slice(1);\n}\n\nfunction collectEnums(type: TailorDBType): EnumConstantMetadata[\"enums\"] {\n const enums: EnumConstantMetadata[\"enums\"] = [];\n\n for (const [fieldName, parsedField] of Object.entries(type.fields)) {\n if (parsedField.config.type === \"enum\" && parsedField.config.allowedValues) {\n const enumTypeName = `${type.name}${capitalizeFirst(fieldName)}`;\n enums.push({\n name: enumTypeName,\n values: parsedField.config.allowedValues,\n fieldDescription: parsedField.config.description,\n });\n }\n\n // Process nested fields\n if (parsedField.config.type === \"nested\" && parsedField.config.fields) {\n for (const [nestedFieldName, nestedFieldConfig] of Object.entries(\n parsedField.config.fields,\n )) {\n if (nestedFieldConfig.type === \"enum\" && nestedFieldConfig.allowedValues) {\n const fullFieldName = `${fieldName}${capitalizeFirst(nestedFieldName)}`;\n const enumTypeName = `${type.name}${capitalizeFirst(fullFieldName)}`;\n enums.push({\n name: enumTypeName,\n values: nestedFieldConfig.allowedValues,\n fieldDescription: nestedFieldConfig.description,\n });\n }\n }\n }\n }\n\n return enums;\n}\n\n/**\n * Process a TailorDB table and extract enum metadata.\n * @param type - The parsed TailorDB table to process\n * @returns Enum constant metadata for the table\n */\nexport async function processEnumType(type: TailorDBType): Promise<EnumConstantMetadata> {\n const enums = collectEnums(type);\n\n return {\n name: type.name,\n enums,\n };\n}\n","import { generateUnifiedEnumConstants } from \"./generate-enum-constants\";\nimport { processEnumType } from \"./process-enum-type\";\nimport type { Plugin, GeneratorResult, TailorDBReadyContext } from \"#/plugin/types\";\nimport type { EnumDefinition } from \"./types\";\n\n/** Unique identifier for the enum constants generator plugin. */\nexport const EnumConstantsGeneratorID = \"@tailor-platform/enum-constants\";\n\ntype EnumConstantsPluginOptions = {\n distPath: string;\n};\n\n/**\n * Plugin that generates enum constants from TailorDB table definitions.\n * @param options - Plugin options\n * @param options.distPath - Output file path for generated constants\n * @returns Plugin instance with onTailorDBReady hook\n */\nexport function enumConstantsPlugin(\n options: EnumConstantsPluginOptions,\n): Plugin<unknown, EnumConstantsPluginOptions> {\n return {\n id: EnumConstantsGeneratorID,\n description: \"Generates enum constants from TailorDB table definitions\",\n pluginConfig: options,\n\n async onTailorDBReady(\n ctx: TailorDBReadyContext<EnumConstantsPluginOptions>,\n ): Promise<GeneratorResult> {\n const allEnums: EnumDefinition[] = [];\n\n for (const ns of ctx.tailordb) {\n for (const type of Object.values(ns.tables)) {\n const metadata = await processEnumType(type);\n allEnums.push(...metadata.enums);\n }\n }\n\n const files: GeneratorResult[\"files\"] = [];\n if (allEnums.length > 0) {\n const content = generateUnifiedEnumConstants(allEnums);\n files.push({\n path: ctx.pluginConfig.distPath,\n content,\n });\n }\n\n return { files };\n },\n };\n}\n"],"mappings":"AAOA,SAAgB,6BAA6B,EAAoC,CAC/E,GAAI,EAAS,SAAW,EACtB,MAAO,GAGT,IAAM,EAAU,IAAI,IACpB,IAAK,IAAM,KAAW,EACpB,EAAQ,IAAI,EAAQ,KAAM,CAAO,EAGnC,IAAM,EAAW,MAAM,KAAK,EAAQ,OAAO,CAAC,CAAC,CAC1C,IAAK,GAAM,CACV,IAAM,EAAU,EAAE,OACf,IAAK,GAEG,MADK,EAAE,MAAM,QAAQ,SAAU,GACvB,EAAE,MAAM,EAAE,MAAM,EAChC,CAAC,CACD,KAAK;CAAK,EAEP,EAAkB,EAAE,OAAO,KAAM,GAAM,EAAE,WAAW,EACtD,EAAQ,GACZ,GAAI,EAAE,kBAAoB,EAAiB,CACzC,IAAM,EAAkB,CAAC,EASzB,GAPI,EAAE,mBACJ,EAAM,KAAK,MAAM,EAAE,kBAAkB,EACjC,GACF,EAAM,KAAK,IAAI,GAIf,EAAiB,CACnB,IAAM,EAAe,EAAE,OAAO,IAAK,GAE1B,gBAAgB,CADX,EAAE,MAAM,QAAQ,SAAU,GACZ,EAAG,EAAE,WAAW,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,KAAK,KAAK,GACvE,EACD,EAAM,KAAK,GAAG,CAAY,CAC5B,CAEI,EAAM,OAAS,IACjB,EAAQ,QAAQ,EAAM,KAAK;CAAI,EAAE,SAErC,CAIA,MAAO,GAAG,GAFU,EAAM,eAAe,EAAE,KAAK,QAAQ,EAAQ,eAE7C,IAAI,eADQ,EAAE,KAAK,aAAa,EAAE,KAAK,iBAAiB,EAAE,KAAK,KAEpF,CAAC,CAAC,CACD,KAAK;;CAAM,EAMd,OAJK,EAIE,EAAW;EAHT,EAIX,CC3DA,SAAS,gBAAgB,EAAqB,CAC5C,OAAO,EAAI,OAAO,CAAC,CAAC,CAAC,YAAY,EAAI,EAAI,MAAM,CAAC,CAClD,CAEA,SAAS,aAAa,EAAmD,CACvE,IAAM,EAAuC,CAAC,EAE9C,IAAK,GAAM,CAAC,EAAW,KAAgB,OAAO,QAAQ,EAAK,MAAM,EAAG,CAClE,GAAI,EAAY,OAAO,OAAS,QAAU,EAAY,OAAO,cAAe,CAC1E,IAAM,EAAe,GAAG,EAAK,OAAO,gBAAgB,CAAS,IAC7D,EAAM,KAAK,CACT,KAAM,EACN,OAAQ,EAAY,OAAO,cAC3B,iBAAkB,EAAY,OAAO,WACvC,CAAC,CACH,CAGA,GAAI,EAAY,OAAO,OAAS,UAAY,EAAY,OAAO,OACxD,KAAA,GAAM,CAAC,EAAiB,KAAsB,OAAO,QACxD,EAAY,OAAO,MACrB,EACE,GAAI,EAAkB,OAAS,QAAU,EAAkB,cAAe,CACxE,IAAM,EAAgB,GAAG,IAAY,gBAAgB,CAAe,IAC9D,EAAe,GAAG,EAAK,OAAO,gBAAgB,CAAa,IACjE,EAAM,KAAK,CACT,KAAM,EACN,OAAQ,EAAkB,cAC1B,iBAAkB,EAAkB,WACtC,CAAC,CACH,EAGN,CAEA,OAAO,CACT,CAOA,eAAsB,gBAAgB,EAAmD,CACvF,IAAM,EAAQ,aAAa,CAAI,EAE/B,MAAO,CACL,KAAM,EAAK,KACX,OACF,CACF,CC/CA,MAAa,EAA2B,kCAYxC,SAAgB,oBACd,EAC6C,CAC7C,MAAO,CACL,GAAI,EACJ,YAAa,2DACb,aAAc,EAEd,MAAM,gBACJ,EAC0B,CAC1B,IAAM,EAA6B,CAAC,EAEpC,IAAK,IAAM,KAAM,EAAI,SACnB,IAAK,IAAM,KAAQ,OAAO,OAAO,EAAG,MAAM,EAAG,CAC3C,IAAM,EAAW,MAAM,gBAAgB,CAAI,EAC3C,EAAS,KAAK,GAAG,EAAS,KAAK,CACjC,CAGF,IAAM,EAAkC,CAAC,EACzC,GAAI,EAAS,OAAS,EAAG,CACvB,IAAM,EAAU,6BAA6B,CAAQ,EACrD,EAAM,KAAK,CACT,KAAM,EAAI,aAAa,SACvB,SACF,CAAC,CACH,CAEA,MAAO,CAAE,OAAM,CACjB,CACF,CACF"}
|
|
@@ -1,24 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
//#region src/plugin/builtin/file-utils/generate-file-utils.ts
|
|
4
|
-
/**
|
|
5
|
-
* Generate unified file utility functions from collected metadata.
|
|
6
|
-
* @param namespaceData - Namespace data with file utility metadata
|
|
7
|
-
* @returns Generated file utility code
|
|
8
|
-
*/
|
|
9
|
-
function generateUnifiedFileUtils(namespaceData) {
|
|
10
|
-
if (namespaceData.length === 0) return "";
|
|
11
|
-
const typeNamespaceMap = /* @__PURE__ */ new Map();
|
|
12
|
-
const typeFieldsMap = /* @__PURE__ */ new Map();
|
|
13
|
-
for (const { namespace, types } of namespaceData) for (const type of types) {
|
|
14
|
-
typeNamespaceMap.set(type.name, namespace);
|
|
15
|
-
typeFieldsMap.set(type.name, type.fileFields);
|
|
16
|
-
}
|
|
17
|
-
if (typeNamespaceMap.size === 0) return "";
|
|
18
|
-
const interfaceFields = Array.from(typeFieldsMap.entries()).map(([typeName, fields]) => {
|
|
19
|
-
return ` ${typeName}: {\n fields: ${fields.map((field) => `"${field}"`).join(" | ")};\n };`;
|
|
20
|
-
}).join("\n");
|
|
21
|
-
const importStatement = multiline`
|
|
1
|
+
import{t as e}from"../../../multiline-EyzjEwn9.mjs";function generateUnifiedFileUtils(t){if(t.length===0)return``;let n=new Map,r=new Map;for(let{namespace:e,types:i}of t)for(let t of i)n.set(t.name,e),r.set(t.name,t.fileFields);if(n.size===0)return``;let i=Array.from(r.entries()).map(([e,t])=>` ${e}: {\n fields: ${t.map(e=>`"${e}"`).join(` | `)};\n };`).join(`
|
|
2
|
+
`),a=e`
|
|
22
3
|
import { file } from "@tailor-platform/sdk/runtime/file";
|
|
23
4
|
import type {
|
|
24
5
|
FileUploadOptions,
|
|
@@ -26,22 +7,19 @@ function generateUnifiedFileUtils(namespaceData) {
|
|
|
26
7
|
FileMetadata,
|
|
27
8
|
FileDownloadStreamResponse,
|
|
28
9
|
} from "@tailor-platform/sdk/runtime/file";
|
|
29
|
-
|
|
30
|
-
|
|
10
|
+
`+`
|
|
11
|
+
`,o=e`
|
|
31
12
|
export interface TypeWithFiles {
|
|
32
|
-
${
|
|
13
|
+
${i}
|
|
33
14
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
importStatement,
|
|
38
|
-
interfaceDefinition,
|
|
39
|
-
multiline`
|
|
15
|
+
`+`
|
|
16
|
+
`,s=Array.from(n.entries()).map(([e,t])=>` ${e}: "${t}"`).join(`,
|
|
17
|
+
`);return[a,o,e`
|
|
40
18
|
const namespaces: Record<keyof TypeWithFiles, string> = {
|
|
41
|
-
${
|
|
19
|
+
${s},
|
|
42
20
|
};
|
|
43
|
-
|
|
44
|
-
|
|
21
|
+
`+`
|
|
22
|
+
`,e`
|
|
45
23
|
export async function downloadFile<T extends keyof TypeWithFiles>(
|
|
46
24
|
type: T,
|
|
47
25
|
field: TypeWithFiles[T]["fields"],
|
|
@@ -49,8 +27,8 @@ function generateUnifiedFileUtils(namespaceData) {
|
|
|
49
27
|
) {
|
|
50
28
|
return await file.download(namespaces[type], type, field, recordId);
|
|
51
29
|
}
|
|
52
|
-
|
|
53
|
-
|
|
30
|
+
`+`
|
|
31
|
+
`,e`
|
|
54
32
|
export async function uploadFile<T extends keyof TypeWithFiles>(
|
|
55
33
|
type: T,
|
|
56
34
|
field: TypeWithFiles[T]["fields"],
|
|
@@ -60,8 +38,8 @@ function generateUnifiedFileUtils(namespaceData) {
|
|
|
60
38
|
): Promise<FileUploadResponse> {
|
|
61
39
|
return await file.upload(namespaces[type], type, field, recordId, data, options);
|
|
62
40
|
}
|
|
63
|
-
|
|
64
|
-
|
|
41
|
+
`+`
|
|
42
|
+
`,e`
|
|
65
43
|
export async function deleteFile<T extends keyof TypeWithFiles>(
|
|
66
44
|
type: T,
|
|
67
45
|
field: TypeWithFiles[T]["fields"],
|
|
@@ -69,8 +47,8 @@ function generateUnifiedFileUtils(namespaceData) {
|
|
|
69
47
|
): Promise<void> {
|
|
70
48
|
return await file.delete(namespaces[type], type, field, recordId);
|
|
71
49
|
}
|
|
72
|
-
|
|
73
|
-
|
|
50
|
+
`+`
|
|
51
|
+
`,e`
|
|
74
52
|
export async function getFileMetadata<T extends keyof TypeWithFiles>(
|
|
75
53
|
type: T,
|
|
76
54
|
field: TypeWithFiles[T]["fields"],
|
|
@@ -78,8 +56,8 @@ function generateUnifiedFileUtils(namespaceData) {
|
|
|
78
56
|
): Promise<FileMetadata> {
|
|
79
57
|
return await file.getMetadata(namespaces[type], type, field, recordId);
|
|
80
58
|
}
|
|
81
|
-
|
|
82
|
-
|
|
59
|
+
`+`
|
|
60
|
+
`,e`
|
|
83
61
|
export async function downloadFileStream<T extends keyof TypeWithFiles>(
|
|
84
62
|
type: T,
|
|
85
63
|
field: TypeWithFiles[T]["fields"],
|
|
@@ -87,67 +65,7 @@ function generateUnifiedFileUtils(namespaceData) {
|
|
|
87
65
|
): Promise<FileDownloadStreamResponse> {
|
|
88
66
|
return await file.downloadStream(namespaces[type], type, field, recordId);
|
|
89
67
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
//#endregion
|
|
95
|
-
//#region src/plugin/builtin/file-utils/process-file-type.ts
|
|
96
|
-
/**
|
|
97
|
-
* Process a TailorDB table and extract file field metadata.
|
|
98
|
-
* @param type - The parsed TailorDB table to process
|
|
99
|
-
* @returns File utility metadata for the table
|
|
100
|
-
*/
|
|
101
|
-
async function processFileType(type) {
|
|
102
|
-
const fileFields = [];
|
|
103
|
-
if (type.files) for (const fileFieldName of Object.keys(type.files)) fileFields.push(fileFieldName);
|
|
104
|
-
return {
|
|
105
|
-
name: type.name,
|
|
106
|
-
fileFields
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
//#endregion
|
|
111
|
-
//#region src/plugin/builtin/file-utils/index.ts
|
|
112
|
-
/** Unique identifier for the file utilities generator plugin. */
|
|
113
|
-
const FileUtilsGeneratorID = "@tailor-platform/file-utils";
|
|
114
|
-
/**
|
|
115
|
-
* Plugin that generates TypeWithFiles interface from TailorDB table definitions.
|
|
116
|
-
* @param options - Plugin options
|
|
117
|
-
* @param options.distPath - Output file path for generated file utilities
|
|
118
|
-
* @returns Plugin instance with onTailorDBReady hook
|
|
119
|
-
*/
|
|
120
|
-
function fileUtilsPlugin(options) {
|
|
121
|
-
return {
|
|
122
|
-
id: FileUtilsGeneratorID,
|
|
123
|
-
description: "Generates TypeWithFiles interface from TailorDB table definitions",
|
|
124
|
-
pluginConfig: options,
|
|
125
|
-
async onTailorDBReady(ctx) {
|
|
126
|
-
const namespaceData = [];
|
|
127
|
-
for (const ns of ctx.tailordb) {
|
|
128
|
-
const typesWithFiles = [];
|
|
129
|
-
for (const type of Object.values(ns.types)) {
|
|
130
|
-
const metadata = await processFileType(type);
|
|
131
|
-
if (metadata.fileFields.length > 0) typesWithFiles.push(metadata);
|
|
132
|
-
}
|
|
133
|
-
if (typesWithFiles.length > 0) namespaceData.push({
|
|
134
|
-
namespace: ns.namespace,
|
|
135
|
-
types: typesWithFiles
|
|
136
|
-
});
|
|
137
|
-
}
|
|
138
|
-
const files = [];
|
|
139
|
-
if (namespaceData.length > 0) {
|
|
140
|
-
const content = generateUnifiedFileUtils(namespaceData);
|
|
141
|
-
if (content) files.push({
|
|
142
|
-
path: ctx.pluginConfig.distPath,
|
|
143
|
-
content
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
|
-
return { files };
|
|
147
|
-
}
|
|
148
|
-
};
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
//#endregion
|
|
152
|
-
export { FileUtilsGeneratorID, fileUtilsPlugin };
|
|
68
|
+
`+`
|
|
69
|
+
`].join(`
|
|
70
|
+
`)}async function processFileType(e){let t=[];if(e.files)for(let n of Object.keys(e.files))t.push(n);return{name:e.name,fileFields:t}}const t=`@tailor-platform/file-utils`;function fileUtilsPlugin(e){return{id:t,description:`Generates TypeWithFiles interface from TailorDB table definitions`,pluginConfig:e,async onTailorDBReady(e){let t=[];for(let n of e.tailordb){let e=[];for(let t of Object.values(n.tables)){let n=await processFileType(t);n.fileFields.length>0&&e.push(n)}e.length>0&&t.push({namespace:n.namespace,types:e})}let n=[];if(t.length>0){let r=generateUnifiedFileUtils(t);r&&n.push({path:e.pluginConfig.distPath,content:r})}return{files:n}}}}export{t as FileUtilsGeneratorID,fileUtilsPlugin};
|
|
153
71
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../../../../src/plugin/builtin/file-utils/generate-file-utils.ts","../../../../src/plugin/builtin/file-utils/process-file-type.ts","../../../../src/plugin/builtin/file-utils/index.ts"],"sourcesContent":["import multiline from \"#/utils/multiline\";\nimport type { FileUtilMetadata } from \"./types\";\n\n/**\n * Generate unified file utility functions from collected metadata.\n * @param namespaceData - Namespace data with file utility metadata\n * @returns Generated file utility code\n */\nexport function generateUnifiedFileUtils(\n namespaceData: { namespace: string; types: FileUtilMetadata[] }[],\n): string {\n if (namespaceData.length === 0) {\n return \"\";\n }\n\n // Collect all
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../../../src/plugin/builtin/file-utils/generate-file-utils.ts","../../../../src/plugin/builtin/file-utils/process-file-type.ts","../../../../src/plugin/builtin/file-utils/index.ts"],"sourcesContent":["import multiline from \"#/utils/multiline\";\nimport type { FileUtilMetadata } from \"./types\";\n\n/**\n * Generate unified file utility functions from collected metadata.\n * @param namespaceData - Namespace data with file utility metadata\n * @returns Generated file utility code\n */\nexport function generateUnifiedFileUtils(\n namespaceData: { namespace: string; types: FileUtilMetadata[] }[],\n): string {\n if (namespaceData.length === 0) {\n return \"\";\n }\n\n // Collect all tables with their namespace\n const tableNamespaceMap = new Map<string, string>();\n const typeFieldsMap = new Map<string, string[]>();\n\n for (const { namespace, types } of namespaceData) {\n for (const type of types) {\n tableNamespaceMap.set(type.name, namespace);\n typeFieldsMap.set(type.name, type.fileFields);\n }\n }\n\n if (tableNamespaceMap.size === 0) {\n return \"\";\n }\n\n // Generate interface fields\n const interfaceFields = Array.from(typeFieldsMap.entries())\n .map(([tableName, fields]) => {\n const fieldNamesUnion = fields.map((field) => `\"${field}\"`).join(\" | \");\n return ` ${tableName}: {\\n fields: ${fieldNamesUnion};\\n };`;\n })\n .join(\"\\n\");\n\n const importStatement =\n multiline /* ts */ `\n import { file } from \"@tailor-platform/sdk/runtime/file\";\n import type {\n FileUploadOptions,\n FileUploadResponse,\n FileMetadata,\n FileDownloadStreamResponse,\n } from \"@tailor-platform/sdk/runtime/file\";\n ` + \"\\n\";\n\n const interfaceDefinition =\n multiline /* ts */ `\n export interface TypeWithFiles {\n ${interfaceFields}\n }\n ` + \"\\n\";\n\n // Generate namespaces object\n const namespaceEntries = Array.from(tableNamespaceMap.entries())\n .map(([tableName, namespace]) => ` ${tableName}: \"${namespace}\"`)\n .join(\",\\n\");\n\n const namespacesDefinition =\n multiline /* ts */ `\n const namespaces: Record<keyof TypeWithFiles, string> = {\n ${namespaceEntries},\n };\n ` + \"\\n\";\n\n // Generate downloadFile helper function\n const downloadFunction =\n multiline /* ts */ `\n export async function downloadFile<T extends keyof TypeWithFiles>(\n type: T,\n field: TypeWithFiles[T][\"fields\"],\n recordId: string,\n ) {\n return await file.download(namespaces[type], type, field, recordId);\n }\n ` + \"\\n\";\n\n // Generate uploadFile helper function\n const uploadFunction =\n multiline /* ts */ `\n export async function uploadFile<T extends keyof TypeWithFiles>(\n type: T,\n field: TypeWithFiles[T][\"fields\"],\n recordId: string,\n data: string | ArrayBuffer | Uint8Array<ArrayBufferLike> | number[],\n options?: FileUploadOptions,\n ): Promise<FileUploadResponse> {\n return await file.upload(namespaces[type], type, field, recordId, data, options);\n }\n ` + \"\\n\";\n\n // Generate deleteFile helper function\n const deleteFunction =\n multiline /* ts */ `\n export async function deleteFile<T extends keyof TypeWithFiles>(\n type: T,\n field: TypeWithFiles[T][\"fields\"],\n recordId: string,\n ): Promise<void> {\n return await file.delete(namespaces[type], type, field, recordId);\n }\n ` + \"\\n\";\n\n // Generate getFileMetadata helper function\n const getMetadataFunction =\n multiline /* ts */ `\n export async function getFileMetadata<T extends keyof TypeWithFiles>(\n type: T,\n field: TypeWithFiles[T][\"fields\"],\n recordId: string,\n ): Promise<FileMetadata> {\n return await file.getMetadata(namespaces[type], type, field, recordId);\n }\n ` + \"\\n\";\n\n // Generate downloadFileStream helper function\n const downloadStreamFunction =\n multiline /* ts */ `\n export async function downloadFileStream<T extends keyof TypeWithFiles>(\n type: T,\n field: TypeWithFiles[T][\"fields\"],\n recordId: string,\n ): Promise<FileDownloadStreamResponse> {\n return await file.downloadStream(namespaces[type], type, field, recordId);\n }\n ` + \"\\n\";\n\n return [\n importStatement,\n interfaceDefinition,\n namespacesDefinition,\n downloadFunction,\n uploadFunction,\n deleteFunction,\n getMetadataFunction,\n downloadStreamFunction,\n ].join(\"\\n\");\n}\n","import type { TailorDBType } from \"#/parser/service/tailordb/types\";\nimport type { FileUtilMetadata } from \"./types\";\n\n/**\n * Process a TailorDB table and extract file field metadata.\n * @param type - The parsed TailorDB table to process\n * @returns File utility metadata for the table\n */\nexport async function processFileType(type: TailorDBType): Promise<FileUtilMetadata> {\n const fileFields: string[] = [];\n\n if (type.files) {\n for (const fileFieldName of Object.keys(type.files)) {\n fileFields.push(fileFieldName);\n }\n }\n\n return {\n name: type.name,\n fileFields,\n };\n}\n","import { generateUnifiedFileUtils } from \"./generate-file-utils\";\nimport { processFileType } from \"./process-file-type\";\nimport type { Plugin, GeneratorResult, TailorDBReadyContext } from \"#/plugin/types\";\nimport type { FileUtilMetadata } from \"./types\";\n\n/** Unique identifier for the file utilities generator plugin. */\nexport const FileUtilsGeneratorID = \"@tailor-platform/file-utils\";\n\ntype FileUtilsPluginOptions = {\n distPath: string;\n};\n\n/**\n * Plugin that generates TypeWithFiles interface from TailorDB table definitions.\n * @param options - Plugin options\n * @param options.distPath - Output file path for generated file utilities\n * @returns Plugin instance with onTailorDBReady hook\n */\nexport function fileUtilsPlugin(\n options: FileUtilsPluginOptions,\n): Plugin<unknown, FileUtilsPluginOptions> {\n return {\n id: FileUtilsGeneratorID,\n description: \"Generates TypeWithFiles interface from TailorDB table definitions\",\n pluginConfig: options,\n\n async onTailorDBReady(\n ctx: TailorDBReadyContext<FileUtilsPluginOptions>,\n ): Promise<GeneratorResult> {\n const namespaceData: { namespace: string; types: FileUtilMetadata[] }[] = [];\n\n for (const ns of ctx.tailordb) {\n const typesWithFiles: FileUtilMetadata[] = [];\n\n for (const type of Object.values(ns.tables)) {\n const metadata = await processFileType(type);\n if (metadata.fileFields.length > 0) {\n typesWithFiles.push(metadata);\n }\n }\n\n if (typesWithFiles.length > 0) {\n namespaceData.push({\n namespace: ns.namespace,\n types: typesWithFiles,\n });\n }\n }\n\n const files: GeneratorResult[\"files\"] = [];\n if (namespaceData.length > 0) {\n const content = generateUnifiedFileUtils(namespaceData);\n if (content) {\n files.push({\n path: ctx.pluginConfig.distPath,\n content,\n });\n }\n }\n\n return { files };\n },\n };\n}\n"],"mappings":"oDAQA,SAAgB,yBACd,EACQ,CACR,GAAI,EAAc,SAAW,EAC3B,MAAO,GAIT,IAAM,EAAoB,IAAI,IACxB,EAAgB,IAAI,IAE1B,IAAK,GAAM,CAAE,YAAW,WAAW,EACjC,IAAK,IAAM,KAAQ,EACjB,EAAkB,IAAI,EAAK,KAAM,CAAS,EAC1C,EAAc,IAAI,EAAK,KAAM,EAAK,UAAU,EAIhD,GAAI,EAAkB,OAAS,EAC7B,MAAO,GAIT,IAAM,EAAkB,MAAM,KAAK,EAAc,QAAQ,CAAC,CAAC,CACxD,KAAK,CAAC,EAAW,KAET,KAAK,EAAU,mBADE,EAAO,IAAK,GAAU,IAAI,EAAM,EAAE,CAAC,CAAC,KAAK,KACV,EAAE,QAC1D,CAAC,CACD,KAAK;CAAI,EAEN,EACJ,CAAmB;;;;;;;;MAQf;EAEA,EACJ,CAAmB;;QAEf,EAAgB;;MAEhB;EAGA,EAAmB,MAAM,KAAK,EAAkB,QAAQ,CAAC,CAAC,CAC7D,KAAK,CAAC,EAAW,KAAe,KAAK,EAAU,KAAK,EAAU,EAAE,CAAC,CACjE,KAAK;CAAK,EAuEb,MAAO,CACL,EACA,EAtEA,CAAmB;;QAEf,EAAiB;;MAEjB;EAIJ,CAAmB;;;;;;;;MAQf;EAIJ,CAAmB;;;;;;;;;;MAUf;EAIJ,CAAmB;;;;;;;;MAQf;EAIJ,CAAmB;;;;;;;;MAQf;EAIJ,CAAmB;;;;;;;;MAQf;CAWN,CAAC,CAAC,KAAK;CAAI,CACb,CCpIA,eAAsB,gBAAgB,EAA+C,CACnF,IAAM,EAAuB,CAAC,EAE9B,GAAI,EAAK,MACP,IAAK,IAAM,KAAiB,OAAO,KAAK,EAAK,KAAK,EAChD,EAAW,KAAK,CAAa,EAIjC,MAAO,CACL,KAAM,EAAK,KACX,YACF,CACF,CCfA,MAAa,EAAuB,8BAYpC,SAAgB,gBACd,EACyC,CACzC,MAAO,CACL,GAAI,EACJ,YAAa,oEACb,aAAc,EAEd,MAAM,gBACJ,EAC0B,CAC1B,IAAM,EAAoE,CAAC,EAE3E,IAAK,IAAM,KAAM,EAAI,SAAU,CAC7B,IAAM,EAAqC,CAAC,EAE5C,IAAK,IAAM,KAAQ,OAAO,OAAO,EAAG,MAAM,EAAG,CAC3C,IAAM,EAAW,MAAM,gBAAgB,CAAI,EACvC,EAAS,WAAW,OAAS,GAC/B,EAAe,KAAK,CAAQ,CAEhC,CAEI,EAAe,OAAS,GAC1B,EAAc,KAAK,CACjB,UAAW,EAAG,UACd,MAAO,CACT,CAAC,CAEL,CAEA,IAAM,EAAkC,CAAC,EACzC,GAAI,EAAc,OAAS,EAAG,CAC5B,IAAM,EAAU,yBAAyB,CAAa,EAClD,GACF,EAAM,KAAK,CACT,KAAM,EAAI,aAAa,SACvB,SACF,CAAC,CAEL,CAEA,MAAO,CAAE,OAAM,CACjB,CACF,CACF"}
|
|
@@ -5,6 +5,13 @@ declare const KyselyGeneratorID = "@tailor-platform/kysely-type";
|
|
|
5
5
|
type KyselyTypePluginOptions = {
|
|
6
6
|
distPath: string;
|
|
7
7
|
};
|
|
8
|
+
declare module "@tailor-platform/sdk/plugin" {
|
|
9
|
+
interface PluginConfigRegistry {
|
|
10
|
+
"@tailor-platform/kysely-type": KyselyTypePluginOptions;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
/** Conventional output path used when `kyselyTypePlugin` has no `distPath` configured. */
|
|
14
|
+
declare const DEFAULT_KYSELY_TYPES_DIST_PATH = "./generated/tailordb.ts";
|
|
8
15
|
/**
|
|
9
16
|
* Plugin that generates Kysely type definitions for TailorDB tables.
|
|
10
17
|
* @param options - Plugin options
|
|
@@ -13,4 +20,4 @@ type KyselyTypePluginOptions = {
|
|
|
13
20
|
*/
|
|
14
21
|
declare function kyselyTypePlugin(options: KyselyTypePluginOptions): Plugin<unknown, KyselyTypePluginOptions>;
|
|
15
22
|
//#endregion
|
|
16
|
-
export { KyselyGeneratorID, kyselyTypePlugin };
|
|
23
|
+
export { DEFAULT_KYSELY_TYPES_DIST_PATH, KyselyGeneratorID, kyselyTypePlugin };
|
|
@@ -1,275 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
//#region src/plugin/builtin/kysely-type/type-processor.ts
|
|
4
|
-
/**
|
|
5
|
-
* Get the enum type definition.
|
|
6
|
-
* @param fieldConfig - The field configuration
|
|
7
|
-
* @returns The enum type as a string union
|
|
8
|
-
*/
|
|
9
|
-
function getEnumType(fieldConfig) {
|
|
10
|
-
const allowedValues = fieldConfig.allowedValues;
|
|
11
|
-
if (allowedValues && Array.isArray(allowedValues)) return allowedValues.map((v) => {
|
|
12
|
-
return `"${typeof v === "string" ? v : v.value}"`;
|
|
13
|
-
}).join(" | ");
|
|
14
|
-
return "string";
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Get the nested object type definition.
|
|
18
|
-
* @param fieldConfig - The field configuration
|
|
19
|
-
* @returns The nested type with used utility types
|
|
20
|
-
*/
|
|
21
|
-
function getNestedType(fieldConfig) {
|
|
22
|
-
const fields = fieldConfig.fields;
|
|
23
|
-
if (!fields || typeof fields !== "object") return {
|
|
24
|
-
type: "string",
|
|
25
|
-
usedUtilityTypes: {
|
|
26
|
-
Timestamp: false,
|
|
27
|
-
Serial: false
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
const fieldResults = Object.entries(fields).map(([fieldName, config]) => {
|
|
31
|
-
const result = generateFieldType(config);
|
|
32
|
-
return {
|
|
33
|
-
fieldType: `${fieldName}${config.required !== true ? "?" : ""}: ${result.type}`,
|
|
34
|
-
usedUtilityTypes: result.usedUtilityTypes
|
|
35
|
-
};
|
|
36
|
-
});
|
|
37
|
-
const aggregatedUtilityTypes = fieldResults.reduce((acc, result) => ({
|
|
38
|
-
Timestamp: acc.Timestamp || result.usedUtilityTypes.Timestamp,
|
|
39
|
-
Serial: acc.Serial || result.usedUtilityTypes.Serial
|
|
40
|
-
}), {
|
|
41
|
-
Timestamp: false,
|
|
42
|
-
Serial: false
|
|
43
|
-
});
|
|
44
|
-
const fieldTypes = fieldResults.map((r) => r.fieldType);
|
|
45
|
-
const obj = `{\n ${fieldTypes.join(";\n ")}${fieldTypes.length > 0 ? ";" : ""}\n}`;
|
|
46
|
-
const hasOptionalFields = Object.values(fields).some((config) => config.required !== true);
|
|
47
|
-
const hasGeneratedFields = Object.values(fields).some((config) => config.hooks?.create || config.default !== void 0);
|
|
48
|
-
if (aggregatedUtilityTypes.Timestamp || hasOptionalFields || hasGeneratedFields) return {
|
|
49
|
-
type: `ObjectColumnType<${obj}>`,
|
|
50
|
-
usedUtilityTypes: aggregatedUtilityTypes
|
|
51
|
-
};
|
|
52
|
-
return {
|
|
53
|
-
type: obj,
|
|
54
|
-
usedUtilityTypes: aggregatedUtilityTypes
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Get the base Kysely type for a field (without array/null modifiers).
|
|
59
|
-
* @param fieldConfig - The field configuration
|
|
60
|
-
* @returns The base type with used utility types
|
|
61
|
-
*/
|
|
62
|
-
function getBaseType(fieldConfig) {
|
|
63
|
-
const fieldType = fieldConfig.type;
|
|
64
|
-
const usedUtilityTypes = {
|
|
65
|
-
Timestamp: false,
|
|
66
|
-
Serial: false
|
|
67
|
-
};
|
|
68
|
-
let type;
|
|
69
|
-
switch (fieldType) {
|
|
70
|
-
case "uuid":
|
|
71
|
-
case "string":
|
|
72
|
-
case "decimal":
|
|
73
|
-
type = "string";
|
|
74
|
-
break;
|
|
75
|
-
case "integer":
|
|
76
|
-
case "float":
|
|
77
|
-
type = "number";
|
|
78
|
-
break;
|
|
79
|
-
case "date":
|
|
80
|
-
case "datetime":
|
|
81
|
-
usedUtilityTypes.Timestamp = true;
|
|
82
|
-
type = "Timestamp";
|
|
83
|
-
break;
|
|
84
|
-
case "bool":
|
|
85
|
-
case "boolean":
|
|
86
|
-
type = "boolean";
|
|
87
|
-
break;
|
|
88
|
-
case "enum":
|
|
89
|
-
type = getEnumType(fieldConfig);
|
|
90
|
-
break;
|
|
91
|
-
case "nested": return getNestedType(fieldConfig);
|
|
92
|
-
default: type = "string";
|
|
93
|
-
}
|
|
94
|
-
return {
|
|
95
|
-
type,
|
|
96
|
-
usedUtilityTypes
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
/**
|
|
100
|
-
* Generate the complete field type including array and null modifiers.
|
|
101
|
-
* @param fieldConfig - The field configuration
|
|
102
|
-
* @returns The complete field type with used utility types
|
|
103
|
-
*/
|
|
104
|
-
function generateFieldType(fieldConfig) {
|
|
105
|
-
const baseTypeResult = getBaseType(fieldConfig);
|
|
106
|
-
const usedUtilityTypes = { ...baseTypeResult.usedUtilityTypes };
|
|
107
|
-
const isArray = fieldConfig.array === true;
|
|
108
|
-
const isNullable = fieldConfig.required !== true;
|
|
109
|
-
const isColumnTypeBase = (/* @__PURE__ */ new Set(["Timestamp"])).has(baseTypeResult.type);
|
|
110
|
-
let finalType = baseTypeResult.type;
|
|
111
|
-
if (isArray) {
|
|
112
|
-
if (isColumnTypeBase || finalType.startsWith("ObjectColumnType<")) finalType = `ArrayColumnType<${baseTypeResult.type}>`;
|
|
113
|
-
else finalType = fieldConfig.type === "enum" ? `(${baseTypeResult.type})[]` : `${baseTypeResult.type}[]`;
|
|
114
|
-
}
|
|
115
|
-
if (isNullable) finalType = `${finalType} | null`;
|
|
116
|
-
if (fieldConfig.serial) {
|
|
117
|
-
usedUtilityTypes.Serial = true;
|
|
118
|
-
finalType = `Serial<${finalType}>`;
|
|
119
|
-
}
|
|
120
|
-
if (fieldConfig.hooks?.create || fieldConfig.default !== void 0) finalType = `Generated<${finalType}>`;
|
|
121
|
-
return {
|
|
122
|
-
type: finalType,
|
|
123
|
-
usedUtilityTypes
|
|
124
|
-
};
|
|
125
|
-
}
|
|
126
|
-
/**
|
|
127
|
-
* Generate the table interface.
|
|
128
|
-
* @param type - The parsed TailorDB table
|
|
129
|
-
* @returns The type definition and used utility types
|
|
130
|
-
*/
|
|
131
|
-
function generateTableInterface(type) {
|
|
132
|
-
const fieldResults = Object.entries(type.fields).filter(([fieldName]) => fieldName !== "id").map(([fieldName, parsedField]) => ({
|
|
133
|
-
fieldName,
|
|
134
|
-
...generateFieldType(parsedField.config)
|
|
135
|
-
}));
|
|
136
|
-
const fields = ["id: Generated<string>;", ...fieldResults.map((result) => `${result.fieldName}: ${result.type};`)];
|
|
137
|
-
const aggregatedUtilityTypes = fieldResults.reduce((acc, result) => ({
|
|
138
|
-
Timestamp: acc.Timestamp || result.usedUtilityTypes.Timestamp,
|
|
139
|
-
Serial: acc.Serial || result.usedUtilityTypes.Serial
|
|
140
|
-
}), {
|
|
141
|
-
Timestamp: false,
|
|
142
|
-
Serial: false
|
|
143
|
-
});
|
|
144
|
-
return {
|
|
145
|
-
typeDef: multiline`
|
|
146
|
-
${type.name}: {
|
|
147
|
-
${fields.join("\n")}
|
|
148
|
-
}
|
|
149
|
-
`,
|
|
150
|
-
usedUtilityTypes: aggregatedUtilityTypes
|
|
151
|
-
};
|
|
152
|
-
}
|
|
153
|
-
/**
|
|
154
|
-
* Convert a TailorDBType into KyselyTypeMetadata.
|
|
155
|
-
* @param type - Parsed TailorDB table
|
|
156
|
-
* @returns Generated Kysely type metadata
|
|
157
|
-
*/
|
|
158
|
-
async function processKyselyType(type) {
|
|
159
|
-
const result = generateTableInterface(type);
|
|
160
|
-
return {
|
|
161
|
-
name: type.name,
|
|
162
|
-
typeDef: result.typeDef,
|
|
163
|
-
usedUtilityTypes: result.usedUtilityTypes
|
|
164
|
-
};
|
|
165
|
-
}
|
|
166
|
-
/**
|
|
167
|
-
* Generate unified types file from multiple namespaces.
|
|
168
|
-
* @param namespaceData - Namespace metadata
|
|
169
|
-
* @returns Generated types file contents
|
|
170
|
-
*/
|
|
171
|
-
function generateUnifiedKyselyTypes(namespaceData) {
|
|
172
|
-
if (namespaceData.length === 0) return "";
|
|
173
|
-
const globalUsedUtilityTypes = namespaceData.reduce((acc, ns) => ({
|
|
174
|
-
Timestamp: acc.Timestamp || ns.usedUtilityTypes.Timestamp,
|
|
175
|
-
Serial: acc.Serial || ns.usedUtilityTypes.Serial
|
|
176
|
-
}), {
|
|
177
|
-
Timestamp: false,
|
|
178
|
-
Serial: false
|
|
179
|
-
});
|
|
180
|
-
const utilityTypeImports = ["type Generated"];
|
|
181
|
-
if (globalUsedUtilityTypes.Timestamp) utilityTypeImports.push("type Timestamp");
|
|
182
|
-
if (namespaceData.some((ns) => ns.types.some((t) => t.typeDef.includes("ObjectColumnType<")))) utilityTypeImports.push("type ObjectColumnType");
|
|
183
|
-
if (namespaceData.some((ns) => ns.types.some((t) => t.typeDef.includes("ArrayColumnType<")))) utilityTypeImports.push("type ArrayColumnType");
|
|
184
|
-
if (globalUsedUtilityTypes.Serial) utilityTypeImports.push("type Serial");
|
|
185
|
-
return [
|
|
186
|
-
multiline`
|
|
187
|
-
import {
|
|
188
|
-
createGetDB,
|
|
189
|
-
${utilityTypeImports.join(",\n")},
|
|
190
|
-
type NamespaceDB,
|
|
191
|
-
type NamespaceInsertable,
|
|
192
|
-
type NamespaceSelectable,
|
|
193
|
-
type NamespaceTable,
|
|
194
|
-
type NamespaceTableName,
|
|
195
|
-
type NamespaceTransaction,
|
|
196
|
-
type NamespaceUpdateable,
|
|
197
|
-
} from "@tailor-platform/sdk/kysely";
|
|
198
|
-
`,
|
|
199
|
-
`export interface Namespace {\n${namespaceData.map(({ namespace, types }) => {
|
|
200
|
-
return ` "${namespace}": {\n${types.map((type) => {
|
|
201
|
-
return type.typeDef.split("\n").map((line) => line.trim() ? ` ${line}` : "").join("\n");
|
|
202
|
-
}).join("\n\n")}\n }`;
|
|
203
|
-
}).join(",\n")}\n}`,
|
|
204
|
-
multiline`
|
|
205
|
-
export const getDB = createGetDB<Namespace>();
|
|
206
|
-
|
|
207
|
-
export type DB<N extends keyof Namespace = keyof Namespace> = NamespaceDB<Namespace, N>;
|
|
208
|
-
`,
|
|
209
|
-
multiline`
|
|
210
|
-
export type Transaction<K extends keyof Namespace | DB = keyof Namespace> =
|
|
211
|
-
NamespaceTransaction<Namespace, K>;
|
|
212
|
-
|
|
213
|
-
type TableName = NamespaceTableName<Namespace>;
|
|
214
|
-
export type Table<T extends TableName> = NamespaceTable<Namespace, T>;
|
|
215
|
-
|
|
216
|
-
export type Insertable<T extends TableName> = NamespaceInsertable<Namespace, T>;
|
|
217
|
-
export type Selectable<T extends TableName> = NamespaceSelectable<Namespace, T>;
|
|
218
|
-
export type Updateable<T extends TableName> = NamespaceUpdateable<Namespace, T>;
|
|
219
|
-
`
|
|
220
|
-
].join("\n\n") + "\n";
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
//#endregion
|
|
224
|
-
//#region src/plugin/builtin/kysely-type/index.ts
|
|
225
|
-
/** Unique identifier for the Kysely type generator plugin. */
|
|
226
|
-
const KyselyGeneratorID = "@tailor-platform/kysely-type";
|
|
227
|
-
/**
|
|
228
|
-
* Plugin that generates Kysely type definitions for TailorDB tables.
|
|
229
|
-
* @param options - Plugin options
|
|
230
|
-
* @param options.distPath - Output file path for generated types
|
|
231
|
-
* @returns Plugin instance with onTailorDBReady hook
|
|
232
|
-
*/
|
|
233
|
-
function kyselyTypePlugin(options) {
|
|
234
|
-
return {
|
|
235
|
-
id: KyselyGeneratorID,
|
|
236
|
-
description: "Generates Kysely type definitions for TailorDB tables",
|
|
237
|
-
pluginConfig: options,
|
|
238
|
-
async onTailorDBReady(ctx) {
|
|
239
|
-
const allNamespaceData = [];
|
|
240
|
-
for (const ns of ctx.tailordb) {
|
|
241
|
-
const typeMetadataList = [];
|
|
242
|
-
for (const type of Object.values(ns.types)) {
|
|
243
|
-
const metadata = await processKyselyType(type);
|
|
244
|
-
typeMetadataList.push(metadata);
|
|
245
|
-
}
|
|
246
|
-
if (typeMetadataList.length === 0) continue;
|
|
247
|
-
const usedUtilityTypes = typeMetadataList.reduce((acc, type) => ({
|
|
248
|
-
Timestamp: acc.Timestamp || type.usedUtilityTypes.Timestamp,
|
|
249
|
-
Serial: acc.Serial || type.usedUtilityTypes.Serial
|
|
250
|
-
}), {
|
|
251
|
-
Timestamp: false,
|
|
252
|
-
Serial: false
|
|
253
|
-
});
|
|
254
|
-
allNamespaceData.push({
|
|
255
|
-
namespace: ns.namespace,
|
|
256
|
-
types: typeMetadataList,
|
|
257
|
-
usedUtilityTypes
|
|
258
|
-
});
|
|
259
|
-
}
|
|
260
|
-
const files = [];
|
|
261
|
-
if (allNamespaceData.length > 0) {
|
|
262
|
-
const content = generateUnifiedKyselyTypes(allNamespaceData);
|
|
263
|
-
files.push({
|
|
264
|
-
path: ctx.pluginConfig.distPath,
|
|
265
|
-
content
|
|
266
|
-
});
|
|
267
|
-
}
|
|
268
|
-
return { files };
|
|
269
|
-
}
|
|
270
|
-
};
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
//#endregion
|
|
274
|
-
export { KyselyGeneratorID, kyselyTypePlugin };
|
|
275
|
-
//# sourceMappingURL=index.mjs.map
|
|
1
|
+
import{n as e,r as t,t as n}from"../../../kysely-type-BTi3BMtL.mjs";export{n as DEFAULT_KYSELY_TYPES_DIST_PATH,e as KyselyGeneratorID,t as kyselyTypePlugin};
|
|
@@ -32,6 +32,11 @@ type SeedPluginOptions = {
|
|
|
32
32
|
*/
|
|
33
33
|
disableIdpUserSync?: DisableIdpUserSyncDirections;
|
|
34
34
|
};
|
|
35
|
+
declare module "@tailor-platform/sdk/plugin" {
|
|
36
|
+
interface PluginConfigRegistry {
|
|
37
|
+
"@tailor-platform/seed": SeedPluginOptions;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
35
40
|
/**
|
|
36
41
|
* Plugin that generates seed data and schema files consumed by the
|
|
37
42
|
* `tailor seed` commands (@tailor-platform/sdk-plugin-seed).
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { TailorAnyDBType } from "../configure/services/tailordb/types.mjs";
|
|
2
|
-
//#region src/plugin/get-generated-
|
|
2
|
+
//#region src/plugin/get-generated-table.d.ts
|
|
3
3
|
/**
|
|
4
4
|
* Get a generated table from a plugin by loading the config and resolving everything automatically.
|
|
5
|
-
* For
|
|
5
|
+
* For table-attached plugins, calls onTableLoaded() with the source table.
|
|
6
6
|
* For namespace plugins, calls onNamespaceLoaded() with auto-resolved namespace.
|
|
7
7
|
* Results are cached per config path, plugin, namespace, and pluginConfig to avoid redundant processing.
|
|
8
8
|
* @param configPath - Path to tailor.config.ts (absolute or relative to cwd)
|
|
9
9
|
* @param pluginId - The plugin's unique identifier
|
|
10
|
-
* @param
|
|
10
|
+
* @param sourceTable - The source TailorDB table (null for namespace plugins)
|
|
11
11
|
* @param kind - The generated table kind (e.g., "request", "step")
|
|
12
12
|
* @returns The generated TailorDB table
|
|
13
13
|
*/
|
|
14
|
-
declare function
|
|
14
|
+
declare function getGeneratedTable(configPath: string, pluginId: string, sourceTable: TailorAnyDBType | null, kind: string): Promise<TailorAnyDBType>;
|
|
15
15
|
//#endregion
|
|
16
|
-
export {
|
|
16
|
+
export { getGeneratedTable };
|
package/dist/plugin/index.d.mts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { PluginConfigRegistry } from "./types.mjs";
|
|
1
2
|
import { PluginDBSchema, PluginExecutorFactory, PluginFunctionArgs, PluginRecord, PluginRecordCreatedArgs, PluginRecordDeletedArgs, PluginRecordUpdatedArgs, withPluginContext } from "./with-context.mjs";
|
|
2
|
-
import {
|
|
3
|
-
export { type PluginDBSchema, type PluginExecutorFactory, type PluginFunctionArgs, type PluginRecord, type PluginRecordCreatedArgs, type PluginRecordDeletedArgs, type PluginRecordUpdatedArgs,
|
|
3
|
+
import { getGeneratedTable } from "./get-generated-table.mjs";
|
|
4
|
+
export { type PluginConfigRegistry, type PluginDBSchema, type PluginExecutorFactory, type PluginFunctionArgs, type PluginRecord, type PluginRecordCreatedArgs, type PluginRecordDeletedArgs, type PluginRecordUpdatedArgs, getGeneratedTable, withPluginContext };
|