Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -261,11 +261,10 @@ export async function sourceRefusals(
replacedKeys
)
const renamedKeys = new Map([...blockRenames].map(([key, storedKey]) => [storedKey, key]))
const storedKeyOf = new Map([...renamedKeys].map(([storedKey, key]) => [key, storedKey]))
const storedCode = (key: string) => {
const storedBlock =
getOwn(compiled.stored.blocks, key) ??
getOwn(compiled.stored.blocks, storedKeyOf.get(key) ?? key)
getOwn(compiled.stored.blocks, blockRenames.get(key) ?? key)
return storedBlock && getOwn(storedBlock.params, 'code')
}
const compileFindings = withoutRenameSettledFindings(compiled, renamedKeys, () =>
Expand Down
3 changes: 1 addition & 2 deletions apps/sim/lib/workflows/code/compile-source.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import {
type BlockKey,
type CanonicalWorkflow,
type CompileInput,
type CompileResult,
compileWorkflow,
lockIdentRenames,
setOwn,
type WorkflowLockV1,
} from '@sim/workflow-code'

type CompileInput = Parameters<typeof compileWorkflow>[0]

/** `stored` with each renamed block under its new key, its children and edges following it. */
function rekeyStored(
stored: CanonicalWorkflow,
Expand Down
18 changes: 11 additions & 7 deletions knip.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -173,26 +173,30 @@
"entry": ["src/index.ts", "src/runtime.ts", "scripts/*.ts"]
},
"packages/sim-setup": { "includeEntryExports": false },
// The SDK's main entry is `core.d.ts`, the authoring surface workflow files outside this
// monorepo import (the CLI writes it next to them as `CORE_DTS`), so no workspace imports its
// exports. `test/examples`, `test/negative` and `test/core` are type-check fixtures whose
// Entry exports stay checked, so a `./codegen` export nothing in the monorepo imports fails.
// Exempt: `core.d.ts` and `workspace/*.d.ts`, the authoring surface workflow files outside
// this monorepo import (the CLI writes them next to those files as `CORE_DTS` and
// `WORKSPACE_SDK_DTS`), so no workspace imports them. `test/examples`, `test/negative` and `test/core` are type-check fixtures whose
// default export is the workflow: nothing imports them, because `test/typecheck-project.ts`
// globs them into a tsconfig that a test runs tsgo against. `cookbook/examples/*.ts` are
// the examples the CLI writes as text (`COOKBOOK_EXAMPLES`), type-checked by apps/sim's real-catalog test;
// `cookbook/workspace/**` is the example workspace directory it writes as `WORKSPACE_COOKBOOK`
// (its `tools/*.js` is custom tool code, which runs in a sandbox, not as a module).
"packages/workflow-sdk": {
"includeEntryExports": false,
"entry": [
"src/runtime.ts",
"src/codegen/index.ts",
"scripts/*.ts",
"cookbook/examples/*.ts",
"cookbook/workspace/**/*.{ts,js}",
"test/core/*.ts",
"test/examples/*.ts",
"test/negative/*.ts"
]
],
"ignoreIssues": {
"src/core.d.ts": ["exports", "types"],
"src/workspace/*.d.ts": ["exports", "types"],
"cookbook/**": ["exports"],
"test/{core,examples,negative}/*.ts": ["exports"]
}
},
// This shared config is consumed by apps that own the Next dependency.
"packages/tsconfig": { "ignoreUnresolved": ["next"] }
Expand Down
3 changes: 1 addition & 2 deletions packages/sim-cli/src/commands/protocol/stored-edges.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
type CanonicalBlock,
type ChildResultNode,
type ChildResults,
type CompileInput,
type CompileResult,
calledWorkflowKeys,
compiledResultNode,
Expand Down Expand Up @@ -35,8 +36,6 @@ export function blockDigest(block: CanonicalBlock): string {
return digest(stableStringify(block))
}

type CompileInput = Parameters<typeof compileWorkflow>[0]

/**
* `compiled`, the compile of `input`, as `childResults` type it: the same compile when none types
* a call it makes, else `input` compiled again with them.
Expand Down
7 changes: 4 additions & 3 deletions packages/workflow-sdk/src/codegen/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,6 @@ interface SdkTypesOptions {
blockTypes?: ReadonlySet<string>
}

export type GenerateSdkTypesFn = (catalog: BlockCatalog, options?: SdkTypesOptions) => SdkTypeFile[]

/** Names `core.d.ts` exports that generated files may reference; imported only when used. */
const CORE_TYPE_NAMES = [
'AnyRef',
Expand Down Expand Up @@ -798,7 +796,10 @@ function generateSdkIndex(
* Generates the declaration files and `INDEX.md` for a catalog, sorted by path: every block, or
* only `options.blockTypes` (a directory's own copy, whose `index.d.ts` imports just those).
*/
export const generateSdkTypes: GenerateSdkTypesFn = (catalog, options = {}) => {
export function generateSdkTypes(
catalog: BlockCatalog,
options: SdkTypesOptions = {}
): SdkTypeFile[] {
const byType = new Map<string, BuilderEntry[]>()
for (const entry of builderEntries(catalog)) {
if (options.blockTypes && !options.blockTypes.has(entry.builder.type)) continue
Expand Down
5 changes: 0 additions & 5 deletions packages/workflow-sdk/src/codegen/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
export { COOKBOOK_EXAMPLES } from './cookbook-text.generated'
export { CORE_DTS } from './core-text.generated'
export {
type GenerateSdkTypesFn,
generateSdkTypes,
type SdkTypeFile,
sdkIndexHeader,
Expand All @@ -17,8 +16,6 @@ export {
SDK_MODELS_FILE,
} from './layout'
export {
type BuilderLookup,
type BuilderReference,
builderSnippet,
compactBuilder,
describeBuilder,
Expand All @@ -28,10 +25,8 @@ export {
} from './reference'
export { SOURCE_COMPILER_OPTIONS, SOURCE_TYPESCRIPT_VERSION } from './tsconfig'
export {
type GenerateWorkspaceTypesFn,
generateWorkspaceTypes,
type WorkspaceManifest,
type WorkspaceManifestColumn,
} from './workspace'
export { WORKSPACE_COOKBOOK } from './workspace-cookbook-text.generated'
export { WORKSPACE_SDK_DTS } from './workspace-text.generated'
4 changes: 2 additions & 2 deletions packages/workflow-sdk/src/codegen/reference.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import { isLegacyBuilder } from './layout'
import { builderEntry, TOOL_NAMESPACE } from './names'

/** A builder as `sim workflows source params` reports it. */
export interface BuilderReference {
interface BuilderReference {
/** The dotted builder path (`slack.sendMessage`). */
key: string
blockType: string
Expand Down Expand Up @@ -71,7 +71,7 @@ interface BuilderSummary {
}

/** What a builder lookup found. */
export type BuilderLookup =
type BuilderLookup =
| { kind: 'builder'; reference: BuilderReference }
| { kind: 'namespace'; namespace: string; builders: BuilderSummary[] }
| { kind: 'core'; name: string; declaration: string }
Expand Down
6 changes: 2 additions & 4 deletions packages/workflow-sdk/src/codegen/workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { arrayOf, union } from './emit'
import type { SdkTypeFile } from './generate'

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

export type GenerateWorkspaceTypesFn = (manifest: WorkspaceManifest) => SdkTypeFile

/** The `@sim/workflow-sdk` types `workspace.d.ts` may name, in import order. */
const SDK_TYPES = ['Json', 'SimFile'] as const
/** The `@sim/workflow-sdk/workspace` helpers `workspace.d.ts` may name, in import order. */
Expand Down Expand Up @@ -192,7 +190,7 @@ function declarationModules(manifest: WorkspaceManifest): WorkspaceDeclarationMo
}

/** Generates `workspace.d.ts`. Deterministic: keys are sorted. */
export const generateWorkspaceTypes: GenerateWorkspaceTypesFn = (manifest) => {
export function generateWorkspaceTypes(manifest: WorkspaceManifest): SdkTypeFile {
const used: UsedNames = { sdk: new Set(), workspace: new Set() }
const declared = [...new Set(manifest.tableDeclarations ?? [])].sort(compareStrings)
const declaredTables = declared.map(
Expand Down
Loading