Skip to content

Conversation

@eluce2
Copy link
Collaborator

@eluce2 eluce2 commented Dec 18, 2025

Note

Adds npx @proofkit/typegen ui web UI for configuring/running typegen with (beta) OData support, introduces per‑table metadata/typegen flow, and updates fmodata client to fetch targeted/reduced metadata, list tables, and improve schema/comment handling.

  • Typegen (CLI/UI):
    • New UI: npx @proofkit/typegen@latest ui launches a web UI to edit/save config, test connections, pick OData tables/fields, and run typegen.
    • Exports: New subpath @proofkit/typegen/webui-server for the UI server; Vite config and path aliases wired.
  • Typegen (OData pipeline):
    • Per-table metadata: Download and parse metadata per table (with optional reduced annotations) and generate types only for selected tables.
    • Config changes: Switch to explicit tables list; add reduceMetadata and alwaysOverrideFieldNames; field-level exclude/type overrides; updated JSON schema/types.
    • Codegen: Preserves user customizations and aliased imports; adds comments/entity IDs; writes removed fields as commented notes; formatting applied.
    • Server API: New endpoints: /api/config, /api/run, /api/list-tables, /api/table-metadata, /api/test-connection, etc.
    • Tests: Add tests for preserving customizations and end-to-end typegen.
  • fmodata client:
    • Metadata: Database.getMetadata supports tableName and reduceAnnotations; new listTableNames().
    • Schema handling: Use partial field schema, exclude container fields, support comments via FieldBuilder.comment() and table comments; propagate through validation/expand/processing.
    • Entity/query: Simplify schema access with getTableSchema; adjust validation types to Partial<Record<...>>.
    • Cleanup: Remove experimental script; version bump to 0.1.0-alpha.20.

Written by Cursor Bugbot for commit 254538c. This will update automatically on new commits. Configure here.

@vercel
Copy link

vercel bot commented Dec 18, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
proofkit-docs Ready Ready Preview Dec 19, 2025 5:51pm

@eluce2 eluce2 marked this pull request as ready for review December 18, 2025 23:21
@eluce2 eluce2 mentioned this pull request Dec 18, 2025
Copy link
Collaborator Author

eluce2 commented Dec 18, 2025

@cursor review

This was referenced Dec 18, 2025
Closed
Copy link
Collaborator Author

eluce2 commented Dec 18, 2025

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

@eluce2 eluce2 mentioned this pull request Dec 18, 2025
@pkg-pr-new
Copy link

pkg-pr-new bot commented Dec 18, 2025

Open in StackBlitz

@proofkit/better-auth

pnpm add https://pkg.pr.new/proofgeist/proofkit/@proofkit/better-auth@80

@proofkit/cli

pnpm add https://pkg.pr.new/proofgeist/proofkit/@proofkit/cli@80

create-proofkit

pnpm add https://pkg.pr.new/proofgeist/proofkit/create-proofkit@80

@proofkit/fmdapi

pnpm add https://pkg.pr.new/proofgeist/proofkit/@proofkit/fmdapi@80

@proofkit/fmodata

pnpm add https://pkg.pr.new/proofgeist/proofkit/@proofkit/fmodata@80

@proofkit/typegen

pnpm add https://pkg.pr.new/proofgeist/proofkit/@proofkit/typegen@80

@proofkit/webviewer

pnpm add https://pkg.pr.new/proofgeist/proofkit/@proofkit/webviewer@80

commit: 254538c

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Schema extraction logic incompatible with new storage format

The schema storage format changed from a Zod object schema (with ~standard.schema.shape structure) to a plain Partial<Record<keyof TFields, StandardSchemaV1>> in table.ts. However, the extraction logic in entity-set.ts and response-processor.ts still tries to access tableSchema["~standard"]?.schema.shape, which doesn't exist on plain objects. This causes schema to always be undefined, silently disabling all field validation.

packages/fmodata/src/client/entity-set.ts#L126-L137

if (tableSchema) {
// Extract schema from StandardSchemaV1
const zodSchema = tableSchema["~standard"]?.schema;
if (
zodSchema &&
typeof zodSchema === "object" &&
"shape" in zodSchema
) {
schema = zodSchema.shape as Record<string, StandardSchemaV1>;
}
}

packages/fmodata/src/client/entity-set.ts#L231-L242

if (tableSchema) {
// Extract schema from StandardSchemaV1
const zodSchema = tableSchema["~standard"]?.schema;
if (
zodSchema &&
typeof zodSchema === "object" &&
"shape" in zodSchema
) {
schema = zodSchema.shape as Record<string, StandardSchemaV1>;
}
}

packages/fmodata/src/client/query/response-processor.ts#L198-L205

if (occurrence) {
const tableSchema = (occurrence as any)[FMTableClass.Symbol.Schema];
if (tableSchema) {
const zodSchema = tableSchema["~standard"]?.schema;
if (zodSchema && typeof zodSchema === "object" && "shape" in zodSchema) {
schema = zodSchema.shape as Partial<Record<string, StandardSchemaV1>>;
}
}

Fix in Cursor Fix in Web


…tion testing

- Introduced a new state to control loading of tables based on configuration.
- Added connection testing logic to display appropriate messages for connection errors.
- Updated useListTables hook to accept an enabled parameter for conditional querying.
- Improved loading and error handling UI to provide better user feedback.
…ction

- Added support for `reduceMetadata` option in the typegen configuration for `fmdapi_test` table, allowing for field-specific overrides.
- Updated the `ConfigEditor` component to include a toggle for reducing metadata annotations.
- Improved `MetadataFieldsDialog` to manage variable name and reduce metadata settings for individual tables.
- Refactored `generateODataTablesSingle` to utilize the new `reduceMetadata` configuration.
- Deleted unused OData schema files: contacts, customer, related, user_customer, users, fmdapi_test, isolated_contacts, and their corresponding index entries.
- Updated typegen configuration to include `alwaysOverrideFieldNames` option, allowing for more flexible field name management during schema generation.
- Improved handling of existing fields in `generateODataTypes` to preserve user customizations and manage field name updates based on metadata.
This commit refactors the logic for preserving user-defined chained calls in generated types. It also updates dependencies in pnpm-lock.yaml and adds a new test file for preserving user customizations.

Co-authored-by: eric.luce <eric.luce@proofgeist.com>
@cursor
Copy link

cursor bot commented Dec 19, 2025

Cursor Agent can help with this pull request. Just @cursor in comments and I'll start working on changes in this branch.
Learn more about Cursor Agents

expect(regenerated).toContain(`textField as tf`);
expect(regenerated).toContain(`z as zod`);
// Verify the code still uses the aliases
expect(regenerated).toContain(`tf().entityId("F1")`);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Test expects behavior that implementation doesn't provide

Test 3 asserts that tf().entityId("F1") appears in the regenerated output, expecting the field builder alias from the existing file to be preserved. However, mapODataTypeToFieldBuilder always generates canonical function names like textField(), not aliases. The regenerated code will contain textField().entityId("F1")... instead of tf().entityId("F1"). This test will fail because the implementation preserves user method customizations (like .inputValidator()) but not field builder aliases.

Additional Locations (1)

Fix in Cursor Fix in Web

await fs.writeFile(
existingFilePath,
[
`import { fmTableOccurrence, textField } from "@proofkit/fmdapi";`,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Test fixtures use wrong package name causing invalid output

All three tests create fixture files with imports from @proofkit/fmdapi, but the generator produces required imports from @proofkit/fmodata. The import merging logic keeps both since they're different modules, resulting in regenerated files with duplicate identifier declarations (fmTableOccurrence, textField). This produces invalid TypeScript that would fail compilation. The tests pass only because they check for substring presence rather than TypeScript validity.

Additional Locations (2)

Fix in Cursor Fix in Web

@eluce2 eluce2 closed this Dec 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants