Convert a flow file to Code using a template
Project description
CHANGES.md
2026-01-19
Fixed - Prevent invalid datetime import in schema.ts generation
- Fixed
templates/liwe3-cloudflare/gen_schema.pyto filter out built-in types from custom type imports- Added
BUILTIN_TYPESset containing all primitive types:str,string,text,int,num,number,float,double,real,bool,boolean,date,datetime,json,obj,object,file,upload - When a field type is incorrectly marked as custom but is actually a built-in type, it is now skipped
- Prevents invalid imports like
import type { datetime } from './types'which don't exist in SQLite - The
datetimetype in SQLite is handled asintegerwith.$type<Date>()annotation, not as a separate import
- Added
2026-01-18
Enhanced - Made created/updated timestamp fields optional in DB schema generation
- Modified
lib/json_to_drizzle.pyandlib/json_to_sql.pyto makecreatedandupdatedtimestamp fields optional instead of automatically added- Removed automatic addition of
createdandupdatedfields to all database types - These fields are now only included when explicitly defined by the user in the flow JSON
- When user defines these fields, they still receive proper auto-update rules:
- Drizzle ORM:
.default( sqlCURRENT_TIMESTAMP) - SQL:
DEFAULT CURRENT_TIMESTAMP(andON UPDATE CURRENT_TIMESTAMPforupdatedfield in MySQL/MariaDB)
- Drizzle ORM:
- This gives users more control over which tables have timestamp tracking
- Backward compatible: existing flow files with
created/updatedfields will continue to work with auto-update behavior
- Removed automatic addition of
2026-01-16
Fixed - liwe3-cloudflare-svelte index.ts f2c block formatting
- Fixed truncated newlines in
f2c_start/f2c_endblocks in generatedindex.ts- The
f2c_endmarker was appearing on the same line as the last line of custom content - Root cause: extracted snippets have trailing whitespace stripped by
template_base.py - Solution: ensure snippet content ends with a newline before writing the
f2c_endmarker - Updated
templates/liwe3-cloudflare-svelte/gen_index.pyto handle this properly
- The
2025-10-28
Enhanced - Added LiWESysParams to Generated Methods
-
Added optional
sysparameter of typeLiWESysParamsto all generated method functions inliwe3-cloudflaretemplate- Updated
templates/liwe3-cloudflare/texts.pyto importLiWESysParamsfrom@backend/liwe3/corein bothMETHOD_UTILS_FILEandMETHOD_FILE_START - Modified
METHOD_FUNCTION_STARTto includesys?: LiWESysParamsas the third optional parameter - This parameter allows passing system-level configuration and context to all generated methods
- Example signature:
export const pet = async ( app: LiWEApp, params: PetParams, sys?: LiWESysParams ): Promise<LiWEResponse<PetResult>>
- Updated
-
Updated
templates/liwe3-nodejs-ng/texts.pyto importLiWESysParamsin methods file- Added
LiWESysParamsto the imports inMETHODS_FILE_START - Modified both
EP_STARTandFUNCTION_STARTtemplates to includesys?: LiWESysParamsparameter - Maintains consistency across all backend templates
- Added
2025-10-27
Enhanced - Cloudflare Template Utils File
- Added f2c code preservation markers to
utils.tsfile generation in theliwe3-cloudflaretemplate- Users can now add custom imports, utilities, and helper functions that will be preserved between regenerations
- Follows the same pattern as method files with
/* f2c_start utils */and/* f2c_end utils */markers - Updated
templates/liwe3-cloudflare/texts.pyto include the snippet placeholder - Updated
templates/liwe3-cloudflare/gen_methods.pyto use snippet extraction mechanism - Default placeholder comment: "Add custom imports or utilities here"
2025-10-04
Added - Cloudflare Workers Template
- Created new
liwe3-cloudflaretemplate for generating Cloudflare Workers compatible code- Based on
liwe3-nodejs-ngtemplate architecture - Uses Hono framework for HTTP routing
- Implements Zod schema validation
- Supports Drizzle ORM for database operations
- Generates complete module structure with tests configuration
- Based on
Template Structure
templates/liwe3-cloudflare/template.py- Main template class extending TemplateBasetemplates/liwe3-cloudflare/texts.py- Template strings for all generated filestemplates/liwe3-cloudflare/gen_index.py- Generates module index with Hono endpointstemplates/liwe3-cloudflare/gen_perms.py- Generates permissions definitionstemplates/liwe3-cloudflare/gen_methods.py- Generates individual method files with Zod validationtemplates/liwe3-cloudflare/gen_schema.py- Generates Drizzle ORM table schemastemplates/liwe3-cloudflare/gen_sql.py- Generates SQLite SQL schema filestemplates/liwe3-cloudflare/gen_config.py- Generates configuration files
Generated Files
-
src/index.ts- Module initialization with Hono endpoint registration- Different templates for GET, POST, PUT, PATCH, DELETE methods
- Error handling for body parsing
- Query parameter handling for GET requests
-
src/perms.ts- Module permissions array- SystemPermission type definitions
- JSDoc documentation
- Proper quote escaping in descriptions
-
src/methods/- Individual method files- Zod schema definitions with validation
- Type inference for parameters and results
- Full JSDoc documentation
- f2c preservation blocks for custom code
- Parameter extraction and validation
-
src/methods/index.ts- Re-exports all methods and types -
src/methods/utils.ts- Common imports (LiWE core, Drizzle ORM, Zod) -
src/methods.ts- Backward compatibility wrapper -
src/schema.ts- Drizzle ORM table definitions- Generated only for types with
coll_tablefield - Includes indexes (unique, multi, array, fulltext)
- JSDoc comments for tables and fields
- Type inference exports
- Generated only for types with
-
sql/{module_name}.sql- SQLite schema file- Table definitions with field comments
- Index creation statements
- Generated only for types with
coll_tablefield
-
package.json- Module package configuration- Workspace dependencies
- TypeScript and Vitest setup
- Build and test scripts
-
tsconfig.json- TypeScript compiler configuration- ES2022 target with ESNext modules
- Bundler module resolution
- Declaration file generation
-
vitest.config.ts- Vitest testing framework configuration- Path aliases for core imports
- Test file patterns
- Coverage reporting
Key Features
-
Zod Integration: Uses
lib/json_to_zod.pyfor schema generation- Custom type resolution from module flow definitions
- Array and optional field support
- String length validation (min/max)
-
Drizzle Integration: Uses
lib/json_to_drizzle.pyfor ORM schemas- Field index flags converted to string format
- Handles missing attributes gracefully
- Type inference support
-
SQL Generation: Uses
lib/json_to_sql.pyfor schema files- SQLite dialect support
- Inline field documentation
- Index creation
-
File Naming: Endpoint paths converted to file names
/user/add→user-add.ts- Path parts joined with dashes
-
Code Preservation: f2c_start/f2c_end blocks for custom code retention
Added - Core Libraries
-
Created
lib/json_to_drizzle.pymodule to convert LiWE Flow JSON type definitions to Drizzle ORM schemas- Maps flow field types to native Drizzle types (boolean, date, timestamp, text, integer, etc.)
- Generates JSDoc comments for tables, fields, and indexes
- Auto-pluralizes table names to lowercase
- Supports all index types (unique, multi, array, fulltext)
- Includes type inference exports
-
Created
tools/json2drizzle.pyCLI tool to convert JSON files to Drizzle schemas- Reads JSON type definition from file
- Outputs formatted Drizzle schema to stdout
- Includes error handling and help documentation
-
Added comprehensive test suite in
tests/test_json_to_drizzle.py- 34 unit tests covering all functionality
- Tests helper functions, main conversion, and edge cases
- Uses
data/user-type.jsonas test fixture
-
Created
CLAUDE.mdwith comprehensive project documentation for Claude Code instances- Core architecture overview
- Template system documentation
- Common commands and workflow
- Flow file format specification
- Key implementation details and conventions
Changed
- Type mappings now use native Drizzle types instead of SQLite-specific conversions
boolean→boolean()(wasinteger())date→date()(wastext())datetime→timestamp()(wastext())- This allows easier database switching and lets Drizzle handle type conversion
Fixed
- Quote escaping in permission descriptions (e.g., "user's tag")
- Custom type resolution in Zod schemas now uses actual type/enum names
- Field attribute handling for
sizeinstead ofmax_length - Index flag conversion from boolean attributes to string format
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file flow2code-0.3.1.tar.gz.
File metadata
- Download URL: flow2code-0.3.1.tar.gz
- Upload date:
- Size: 267.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5979b14383fe13657b5c321c1c9d1656528690b5babf51a2f5c87120127e605c
|
|
| MD5 |
8c3720bbb38502a01a87aa7895271c74
|
|
| BLAKE2b-256 |
d313d339e61d49bc07bc863f100ecb087a132a6fe679e689334e8ef76fd57ed4
|
File details
Details for the file flow2code-0.3.1-py3-none-any.whl.
File metadata
- Download URL: flow2code-0.3.1-py3-none-any.whl
- Upload date:
- Size: 430.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
72627d0305fd65ec14158eee81188e2f65bea3d60a0e322e60809970a9cbb1de
|
|
| MD5 |
c2a79fe0020cd821b46d1818262b0ae8
|
|
| BLAKE2b-256 |
698b49a0c077dc5d3f84b217016fbc79ba5dbe746470d88f2ee9da4e6e796492
|