diff --git a/.changeset/smooth-moles-sin.md b/.changeset/smooth-moles-sin.md deleted file mode 100644 index 48585f6..0000000 --- a/.changeset/smooth-moles-sin.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@proofgeist/fmdapi": patch ---- - -add new option to clean out old files prior to running codegen, so removed schemas don't remain in your codebase diff --git a/CHANGELOG.md b/CHANGELOG.md index 5b99fb6..609995f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # @proofgeist/fmdapi +## 4.1.1 + +### Patch Changes + +- Allow array of config to support multiple servers in a single config file +- f5751fb: add new option to clean out old files prior to running codegen, so removed schemas don't remain in your codebase + ## 4.1.0 ### Minor Changes diff --git a/package.json b/package.json index c70fdbe..c70ed97 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@proofgeist/fmdapi", - "version": "4.1.0", + "version": "4.1.1", "description": "FileMaker Data API client", "main": "dist/index.js", "repository": "git@github.com:proofgeist/fm-dapi.git", diff --git a/src/cli.ts b/src/cli.ts index 8d5fc30..ba88b8f 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -83,7 +83,7 @@ async function runCodegen({ configLocation }: ConfigArgs) { ); } - await generateTypedClients(config, configLocation).catch((err: unknown) => { + await generateTypedClients(config).catch((err: unknown) => { console.error(err); return process.exit(1); }); diff --git a/src/utils/typegen/index.ts b/src/utils/typegen/index.ts index 5f69ecc..eadf8e7 100644 --- a/src/utils/typegen/index.ts +++ b/src/utils/typegen/index.ts @@ -3,6 +3,7 @@ import { type BuildSchemaArgs, type ClientObjectProps, type GenerateSchemaOptions, + type GenerateSchemaOptionsSingle, } from "./types.js"; import chalk from "chalk"; import { @@ -20,9 +21,18 @@ import { buildSchema } from "./buildSchema.js"; import { getLayoutMetadata } from "./getLayoutMetadata.js"; import { buildLayoutClient } from "./buildLayoutClient.js"; -export const generateTypedClients = async ( - options: GenerateSchemaOptions, - configLocation?: string, +export const generateTypedClients = async (options: GenerateSchemaOptions) => { + if (Array.isArray(options)) { + for (const option of options) { + await generateTypedClientsSingle(option); + } + } else { + await generateTypedClientsSingle(options); + } +}; + +const generateTypedClientsSingle = async ( + options: GenerateSchemaOptionsSingle, ) => { const { envNames, @@ -138,7 +148,6 @@ export const generateTypedClients = async ( valueLists, type: useZod ? "zod" : "ts", strictNumbers: item.strictNumbers, - configLocation, webviewerScriptName: options.webviewerScriptName, envNames: { auth: isOttoAuth(auth) diff --git a/src/utils/typegen/types.ts b/src/utils/typegen/types.ts index 66d934b..81d3a8c 100644 --- a/src/utils/typegen/types.ts +++ b/src/utils/typegen/types.ts @@ -6,7 +6,7 @@ export type ClientObjectProps = OttoAdapterOptions | FetchAdapterOptions; export type ValueListsOptions = "strict" | "allowEmpty" | "ignore"; -export type GenerateSchemaOptions = { +export type GenerateSchemaOptionsSingle = { envNames?: Partial>; schemas: Array<{ layout: string; @@ -63,6 +63,10 @@ export type GenerateSchemaOptions = { clearOldFiles?: boolean; }; +export type GenerateSchemaOptions = + | GenerateSchemaOptionsSingle + | GenerateSchemaOptionsSingle[]; + export type TSchema = { name: string; type: "string" | "fmnumber" | "valueList"; @@ -78,6 +82,5 @@ export type BuildSchemaArgs = { envNames: Omit; layoutName: string; strictNumbers?: boolean; - configLocation?: string; webviewerScriptName?: string; -} & Pick; +} & Pick;