Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
939291a
Add v1 of transformer redesign
kingston Oct 18, 2025
c3c280d
Rename relation helper
kingston Oct 19, 2025
fb992dd
Try v2 of nested helpers
kingston Oct 20, 2025
57bd2f9
Remove uniques
kingston Oct 20, 2025
027b8f4
Try out first iteration with user-data-service
kingston Oct 21, 2025
792f012
Add file tests
kingston Oct 21, 2025
9915ac5
Fix up naming of function
kingston Oct 22, 2025
e2f7fdb
Catch scenario where no proper where is returned
kingston Oct 23, 2025
314cd47
Clean up nested definitions by auto-adding connects
kingston Oct 26, 2025
d9f28c1
Fix type error with define operations
kingston Oct 27, 2025
24768aa
Merge branch 'main' into kingston/eng-786-exploration-data-transforme…
kingston Oct 27, 2025
0afb77c
Remove unused files
kingston Oct 27, 2025
5b906c8
Update jsdocs for data-operaitons
kingston Oct 27, 2025
7391b29
Add data-utils generator to the fastify backend
kingston Oct 27, 2025
c316a3a
Incorporate file-field into generator
kingston Oct 27, 2025
d1aaf66
Fix imports
kingston Oct 27, 2025
950a16e
Fix up file category and remove index.ts
kingston Oct 28, 2025
913e939
Export imports schema by default
kingston Oct 30, 2025
1d5cfdd
Add support for generation of scalar fields
kingston Oct 30, 2025
421a9cf
Regenerate todo-with-auth0
kingston Oct 30, 2025
91c4d6c
Add case utilities
kingston Oct 31, 2025
2322b61
Add changeset for utils
kingston Oct 31, 2025
c968bfb
Add initial implementation of data-create service generator
kingston Oct 31, 2025
6fd0caa
Fix test errors
kingston Oct 31, 2025
c816d71
Fix up define operation typings for create operation
kingston Oct 31, 2025
8eda4b6
Add buildData relation helpers
kingston Nov 4, 2025
f6eaefa
Add support for nested field generators
kingston Nov 9, 2025
6a67ff6
Fix up ordering and trigger regeneration
kingston Nov 9, 2025
e1209b4
Merge branch 'main' into kingston/eng-786-exploration-data-transforme…
kingston Nov 9, 2025
3598f9a
Add support for file model
kingston Nov 9, 2025
5075880
Add update and delete operations to data service
kingston Nov 9, 2025
b931d83
Fix fields with defaults
kingston Nov 9, 2025
7ac7b2b
Fix test typings
kingston Nov 9, 2025
5901536
Fix up field generation
kingston Nov 9, 2025
882d3eb
Strip out prisma password transformer
kingston Nov 9, 2025
c785a7c
Make compileField required
kingston Nov 9, 2025
bf45e02
Switch mutations to use new data service
kingston Nov 9, 2025
a04b447
Support new format for mutations
kingston Nov 12, 2025
42e3d1f
Re-generate graphql
kingston Nov 12, 2025
5780eb3
Regenerate blog-with-auth
kingston Nov 12, 2025
d037a54
Clean up deleted files
kingston Nov 12, 2025
cb4fd4e
Fix up getWhereUnique functions
kingston Nov 12, 2025
cc5fa54
Set max workers to 1
kingston Nov 18, 2025
e7d3433
Implement callbacks to operations for better tracing
kingston Nov 19, 2025
912f49b
Fix linting errors and add changeset
kingston Nov 19, 2025
23d1061
Strip out old data handling code
kingston Nov 19, 2025
c360904
Update blog with auth and tests
kingston Nov 19, 2025
1590199
Fix define operations delete operation
kingston Nov 19, 2025
46c280d
Fix knip issues
kingston Nov 19, 2025
e224dec
Fix up knip
kingston Nov 19, 2025
0eabfb0
Respond to PR feedback
kingston Nov 19, 2025
54c8d54
Fix e2e error and linting
kingston Nov 19, 2025
37708c5
Fix result of delete operation
kingston Nov 19, 2025
47feaa1
Fix types for ModelQuery where there is no include
kingston Nov 19, 2025
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
Prev Previous commit
Next Next commit
Add support for generation of scalar fields
  • Loading branch information
kingston committed Oct 30, 2025
commit 1d5cfdd41a85a0108bdabd2484a2d1ef2d94e125
12 changes: 12 additions & 0 deletions packages/core-generators/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,18 @@
"./extractors": {
"types": "./dist/renderers/extractors.d.ts",
"default": "./dist/renderers/extractors.js"
},
"./test-helpers": {
"types": "./dist/test-helpers/index.d.ts",
"default": "./dist/test-helpers/index.js"
},
"./test-helpers/setup": {
"types": "./dist/test-helpers/setup.d.ts",
"default": "./dist/test-helpers/setup.js"
},
"./test-helpers/vitest-types": {
"types": "./dist/test-helpers/vitest-types.d.ts",
"default": "./dist/test-helpers/vitest-types.js"
}
},
"main": "dist/index.js",
Expand Down
42 changes: 42 additions & 0 deletions packages/core-generators/src/test-helpers/import-map-helpers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import type {
InferTsImportMapFromSchema,
TsImportMapSchemaEntry,
} from '../renderers/typescript/import-maps/types.js';

import { createTsImportMap } from '../renderers/typescript/import-maps/ts-import-map.js';

/**
* Creates a test import map with consistent module specifiers for testing
*
* Each import will use the pattern `<name>/<importKey>`, making it easy to
* identify which test module an import comes from
*
* @param importSchema - The import map schema to use
* @param name - Base name for the module (e.g., 'data-utils')
* @returns A mock import provider for testing
*
* @example
* ```typescript
* const schema = createTsImportMapSchema({
* scalarField: {},
* relationHelpers: {},
* });
*
* const imports = createTestTsImportMap(schema, 'data-utils');
* // Creates imports:
* // scalarField -> 'data-utils/scalarField'
* // relationHelpers -> 'data-utils/relationHelpers'
* ```
*/
export function createTestTsImportMap<
T extends Record<string, TsImportMapSchemaEntry>,
>(importSchema: T, name: string): InferTsImportMapFromSchema<T> {
// Build the imports object based on the schema
const imports: Record<string, string> = {};

for (const key of Object.keys(importSchema)) {
imports[key] = `${name}/${key}`;
}

return createTsImportMap(importSchema, imports as Record<keyof T, string>);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
import { describe, expect, it } from 'vitest';

import { createTsImportMapSchema } from '../renderers/typescript/import-maps/ts-import-map.js';
import { createTestTsImportMap } from './import-map-helpers.js';

describe('createTestTsImportMap', () => {
it('creates import map with name-based module specifiers', () => {
const schema = createTsImportMapSchema({
scalarField: {},
relationHelpers: {},
});

const importMap = createTestTsImportMap(schema, 'data-utils');

// Check that the import map has the expected keys
expect(importMap).toHaveProperty('scalarField');
expect(importMap).toHaveProperty('relationHelpers');

// Check that imports use name-based module specifiers
expect(importMap.scalarField.moduleSpecifier).toBe(
'data-utils/scalarField',
);
expect(importMap.relationHelpers.moduleSpecifier).toBe(
'data-utils/relationHelpers',
);
});

it('creates consistent module specifiers for all keys', () => {
const schema = createTsImportMapSchema({
scalarField: {},
relationHelpers: {},
$Enums: {},
});

const importMap = createTestTsImportMap(schema, 'test-module');

expect(importMap.scalarField.moduleSpecifier).toBe(
'test-module/scalarField',
);
expect(importMap.$Enums.moduleSpecifier).toBe('test-module/$Enums');
expect(importMap.relationHelpers.moduleSpecifier).toBe(
'test-module/relationHelpers',
);
});

it('creates fragments that can be used in code generation', () => {
const schema = createTsImportMapSchema({
scalarField: {},
});

const importMap = createTestTsImportMap(schema, 'data-utils');

const fragment = importMap.scalarField.fragment();

expect(fragment.contents).toBe('scalarField');
expect(fragment.imports).toHaveLength(1);
expect(fragment.imports?.[0].moduleSpecifier).toBe(
'data-utils/scalarField',
);
expect(fragment.imports?.[0].namedImports).toEqual([
{ name: 'scalarField' },
]);
});

it('handles type-only imports correctly', () => {
const schema = createTsImportMapSchema({
MyType: { isTypeOnly: true },
});

const importMap = createTestTsImportMap(schema, 'types');

const fragment = importMap.MyType.typeFragment();

expect(fragment.imports).toHaveLength(1);
expect(fragment.imports?.[0].isTypeOnly).toBe(true);
expect(fragment.imports?.[0].moduleSpecifier).toBe('types/MyType');
});

it('handles wildcard exports', () => {
const schema = createTsImportMapSchema({
'*': {},
});

const importMap = createTestTsImportMap(schema, 'wildcard-module');

expect(importMap['*'].moduleSpecifier).toBe('wildcard-module/*');
});

it('handles exported aliases', () => {
const schema = createTsImportMapSchema({
defaultExport: { exportedAs: 'default' },
});

const importMap = createTestTsImportMap(schema, 'my-module');

const declaration = importMap.defaultExport.declaration();

expect(declaration.defaultImport).toBe('defaultExport');
expect(declaration.moduleSpecifier).toBe('my-module/defaultExport');
});
});
43 changes: 43 additions & 0 deletions packages/core-generators/src/test-helpers/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/**
* Test helpers for @baseplate-dev/core-generators
*
* This module provides utilities for testing code generators, including:
* - Custom Vitest matchers for TypeScript fragments
* - Utilities for creating mock import providers
* - Fragment comparison functions
*
* @example
* ```typescript
* import { createTestTsImportMap, extendFragmentMatchers } from '@baseplate-dev/core-generators/test-helpers';
*
* // Extend Vitest matchers (call once in setup)
* extendFragmentMatchers();
*
* // Create mock import providers for testing
* const imports = createTestTsImportMap(schema);
*
* // Use custom matchers in tests
* expect(fragment).toMatchTsFragment(expectedFragment);
* expect(fragment).toIncludeImport('z', 'zod');
* ```
*
* @packageDocumentation
*/

// Export import map helpers
export { createTestTsImportMap } from './import-map-helpers.js';

// Export matcher functions and types
export {
extendFragmentMatchers,
fragmentMatchers,
type ToIncludeImportOptions,
type ToMatchTsFragmentOptions,
} from './matchers.js';

// Export utility functions
export {
areFragmentsEqual,
type CompareFragmentsOptions,
normalizeFragment,
} from './utils.js';
Loading