Skip to content

Commit 1bf58c9

Browse files
authored
chore(workflow-sdk): drop unused codegen exports and alias indirection (#10549)
- codegen barrel: drop GenerateSdkTypesFn, GenerateWorkspaceTypesFn, BuilderLookup, BuilderReference and WorkspaceManifestColumn; generateSdkTypes and generateWorkspaceTypes become plain function declarations - knip: check workflow-sdk entry exports (exempting only the authoring .d.ts surface and fixtures), so an unused ./codegen export now fails check:unused-exports - compile-source.ts and stored-edges.ts import CompileInput instead of re-deriving it - refusals.ts reads blockRenames directly instead of inverting it twice
1 parent 8d592d6 commit 1bf58c9

8 files changed

Lines changed: 22 additions & 27 deletions

File tree

‎apps/sim/lib/workflows/application/source-pipeline/evaluate/refusals.ts‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,11 +261,10 @@ export async function sourceRefusals(
261261
replacedKeys
262262
)
263263
const renamedKeys = new Map([...blockRenames].map(([key, storedKey]) => [storedKey, key]))
264-
const storedKeyOf = new Map([...renamedKeys].map(([storedKey, key]) => [key, storedKey]))
265264
const storedCode = (key: string) => {
266265
const storedBlock =
267266
getOwn(compiled.stored.blocks, key) ??
268-
getOwn(compiled.stored.blocks, storedKeyOf.get(key) ?? key)
267+
getOwn(compiled.stored.blocks, blockRenames.get(key) ?? key)
269268
return storedBlock && getOwn(storedBlock.params, 'code')
270269
}
271270
const compileFindings = withoutRenameSettledFindings(compiled, renamedKeys, () =>

‎apps/sim/lib/workflows/code/compile-source.ts‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
import {
22
type BlockKey,
33
type CanonicalWorkflow,
4+
type CompileInput,
45
type CompileResult,
56
compileWorkflow,
67
lockIdentRenames,
78
setOwn,
89
type WorkflowLockV1,
910
} from '@sim/workflow-code'
1011

11-
type CompileInput = Parameters<typeof compileWorkflow>[0]
12-
1312
/** `stored` with each renamed block under its new key, its children and edges following it. */
1413
function rekeyStored(
1514
stored: CanonicalWorkflow,

‎knip.jsonc‎

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -173,26 +173,30 @@
173173
"entry": ["src/index.ts", "src/runtime.ts", "scripts/*.ts"]
174174
},
175175
"packages/sim-setup": { "includeEntryExports": false },
176-
// The SDK's main entry is `core.d.ts`, the authoring surface workflow files outside this
177-
// monorepo import (the CLI writes it next to them as `CORE_DTS`), so no workspace imports its
178-
// exports. `test/examples`, `test/negative` and `test/core` are type-check fixtures whose
176+
// Entry exports stay checked, so a `./codegen` export nothing in the monorepo imports fails.
177+
// Exempt: `core.d.ts` and `workspace/*.d.ts`, the authoring surface workflow files outside
178+
// this monorepo import (the CLI writes them next to those files as `CORE_DTS` and
179+
// `WORKSPACE_SDK_DTS`), so no workspace imports them. `test/examples`, `test/negative` and `test/core` are type-check fixtures whose
179180
// default export is the workflow: nothing imports them, because `test/typecheck-project.ts`
180181
// globs them into a tsconfig that a test runs tsgo against. `cookbook/examples/*.ts` are
181182
// the examples the CLI writes as text (`COOKBOOK_EXAMPLES`), type-checked by apps/sim's real-catalog test;
182183
// `cookbook/workspace/**` is the example workspace directory it writes as `WORKSPACE_COOKBOOK`
183184
// (its `tools/*.js` is custom tool code, which runs in a sandbox, not as a module).
184185
"packages/workflow-sdk": {
185-
"includeEntryExports": false,
186186
"entry": [
187-
"src/runtime.ts",
188-
"src/codegen/index.ts",
189187
"scripts/*.ts",
190188
"cookbook/examples/*.ts",
191189
"cookbook/workspace/**/*.{ts,js}",
192190
"test/core/*.ts",
193191
"test/examples/*.ts",
194192
"test/negative/*.ts"
195-
]
193+
],
194+
"ignoreIssues": {
195+
"src/core.d.ts": ["exports", "types"],
196+
"src/workspace/*.d.ts": ["exports", "types"],
197+
"cookbook/**": ["exports"],
198+
"test/{core,examples,negative}/*.ts": ["exports"]
199+
}
196200
},
197201
// This shared config is consumed by apps that own the Next dependency.
198202
"packages/tsconfig": { "ignoreUnresolved": ["next"] }

‎packages/sim-cli/src/commands/protocol/stored-edges.ts‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
type CanonicalBlock,
55
type ChildResultNode,
66
type ChildResults,
7+
type CompileInput,
78
type CompileResult,
89
calledWorkflowKeys,
910
compiledResultNode,
@@ -35,8 +36,6 @@ export function blockDigest(block: CanonicalBlock): string {
3536
return digest(stableStringify(block))
3637
}
3738

38-
type CompileInput = Parameters<typeof compileWorkflow>[0]
39-
4039
/**
4140
* `compiled`, the compile of `input`, as `childResults` type it: the same compile when none types
4241
* a call it makes, else `input` compiled again with them.

‎packages/workflow-sdk/src/codegen/generate.ts‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,6 @@ interface SdkTypesOptions {
6868
blockTypes?: ReadonlySet<string>
6969
}
7070

71-
export type GenerateSdkTypesFn = (catalog: BlockCatalog, options?: SdkTypesOptions) => SdkTypeFile[]
72-
7371
/** Names `core.d.ts` exports that generated files may reference; imported only when used. */
7472
const CORE_TYPE_NAMES = [
7573
'AnyRef',
@@ -798,7 +796,10 @@ function generateSdkIndex(
798796
* Generates the declaration files and `INDEX.md` for a catalog, sorted by path: every block, or
799797
* only `options.blockTypes` (a directory's own copy, whose `index.d.ts` imports just those).
800798
*/
801-
export const generateSdkTypes: GenerateSdkTypesFn = (catalog, options = {}) => {
799+
export function generateSdkTypes(
800+
catalog: BlockCatalog,
801+
options: SdkTypesOptions = {}
802+
): SdkTypeFile[] {
802803
const byType = new Map<string, BuilderEntry[]>()
803804
for (const entry of builderEntries(catalog)) {
804805
if (options.blockTypes && !options.blockTypes.has(entry.builder.type)) continue

‎packages/workflow-sdk/src/codegen/index.ts‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
export { COOKBOOK_EXAMPLES } from './cookbook-text.generated'
22
export { CORE_DTS } from './core-text.generated'
33
export {
4-
type GenerateSdkTypesFn,
54
generateSdkTypes,
65
type SdkTypeFile,
76
sdkIndexHeader,
@@ -17,8 +16,6 @@ export {
1716
SDK_MODELS_FILE,
1817
} from './layout'
1918
export {
20-
type BuilderLookup,
21-
type BuilderReference,
2219
builderSnippet,
2320
compactBuilder,
2421
describeBuilder,
@@ -28,10 +25,8 @@ export {
2825
} from './reference'
2926
export { SOURCE_COMPILER_OPTIONS, SOURCE_TYPESCRIPT_VERSION } from './tsconfig'
3027
export {
31-
type GenerateWorkspaceTypesFn,
3228
generateWorkspaceTypes,
3329
type WorkspaceManifest,
34-
type WorkspaceManifestColumn,
3530
} from './workspace'
3631
export { WORKSPACE_COOKBOOK } from './workspace-cookbook-text.generated'
3732
export { WORKSPACE_SDK_DTS } from './workspace-text.generated'

‎packages/workflow-sdk/src/codegen/reference.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import { isLegacyBuilder } from './layout'
2727
import { builderEntry, TOOL_NAMESPACE } from './names'
2828

2929
/** A builder as `sim workflows source params` reports it. */
30-
export interface BuilderReference {
30+
interface BuilderReference {
3131
/** The dotted builder path (`slack.sendMessage`). */
3232
key: string
3333
blockType: string
@@ -71,7 +71,7 @@ interface BuilderSummary {
7171
}
7272

7373
/** What a builder lookup found. */
74-
export type BuilderLookup =
74+
type BuilderLookup =
7575
| { kind: 'builder'; reference: BuilderReference }
7676
| { kind: 'namespace'; namespace: string; builders: BuilderSummary[] }
7777
| { kind: 'core'; name: string; declaration: string }

‎packages/workflow-sdk/src/codegen/workspace.ts‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { arrayOf, union } from './emit'
1313
import type { SdkTypeFile } from './generate'
1414

1515
/** A table column, as the table's schema declares it (apps/sim/lib/table/column-types). */
16-
export interface WorkspaceManifestColumn {
16+
interface WorkspaceManifestColumn {
1717
/** The column type id: `string`, `number`, `currency`, `boolean`, `date`, `json`, `select`, ... */
1818
type: string
1919
/** Option names of a `select` column, as table blocks read and write them. */
@@ -90,8 +90,6 @@ export interface WorkspaceManifest {
9090
env?: string[]
9191
}
9292

93-
export type GenerateWorkspaceTypesFn = (manifest: WorkspaceManifest) => SdkTypeFile
94-
9593
/** The `@sim/workflow-sdk` types `workspace.d.ts` may name, in import order. */
9694
const SDK_TYPES = ['Json', 'SimFile'] as const
9795
/** The `@sim/workflow-sdk/workspace` helpers `workspace.d.ts` may name, in import order. */
@@ -194,7 +192,7 @@ function declarationModules(manifest: WorkspaceManifest): WorkspaceDeclarationMo
194192
}
195193

196194
/** Generates `workspace.d.ts`. Deterministic: keys are sorted. */
197-
export const generateWorkspaceTypes: GenerateWorkspaceTypesFn = (manifest) => {
195+
export function generateWorkspaceTypes(manifest: WorkspaceManifest): SdkTypeFile {
198196
const used: UsedNames = { sdk: new Set(), workspace: new Set() }
199197
const declared = [...new Set(manifest.tableDeclarations ?? [])].sort(compareStrings)
200198
const declaredTables = declared.map(

0 commit comments

Comments
 (0)