Skip to content
Closed
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
2 changes: 1 addition & 1 deletion pkgs/cli/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
"options": {
"commands": [
"rm -rf supabase/",
"npx -y supabase@latest init --with-vscode-settings --with-intellij-settings",
"npx -y supabase@latest init --force --with-vscode-settings --with-intellij-settings",
"node dist/index.js compile examples/analyze_website.ts --deno-json examples/deno.json --supabase-path supabase",
"./scripts/assert-flow-compiled"
],
Expand Down
18 changes: 8 additions & 10 deletions pkgs/client/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@
"local": true,
"cache": false,
"options": {
"cwd": "{workspaceRoot}",
"cwd": "{projectRoot}",
"commands": [
"scripts/supabase-start-locked.sh {projectRoot}"
"../../scripts/supabase-start-locked.sh ."
],
"parallel": false
}
Expand All @@ -75,8 +75,8 @@
"local": true,
"cache": false,
"options": {
"cwd": "{workspaceRoot}",
"commands": ["scripts/supabase-start-locked.sh {projectRoot}"],
"cwd": "{projectRoot}",
"commands": ["../../scripts/supabase-start-locked.sh ."],
"parallel": false
}
},
Expand Down Expand Up @@ -129,10 +129,10 @@
"cache": false,
"dependsOn": ["supabase:prepare"],
"options": {
"cwd": "{workspaceRoot}",
"cwd": "{projectRoot}",
"commands": [
"scripts/supabase-start-locked.sh {projectRoot}",
"cd {projectRoot} && supabase db reset"
"../../scripts/supabase-start-locked.sh .",
"supabase db reset"
],
"parallel": false
}
Expand Down Expand Up @@ -202,9 +202,7 @@
},
"test:types:vitest": {
"executor": "nx:run-commands",
"cache": true,
"dependsOn": ["build"],
"inputs": ["default", "^production"],
"dependsOn": ["^build"],
"options": {
"cwd": "{projectRoot}",
"command": "pnpm vitest --typecheck.only --run --config vitest.typecheck.config.ts"
Expand Down
3 changes: 2 additions & 1 deletion pkgs/client/tsconfig.typecheck.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@
"include": [
"__tests__/**/*.test-d.ts",
"__tests__/**/*.spec-d.ts"
]
],
"exclude": ["dist", "node_modules"]
}
1 change: 1 addition & 0 deletions pkgs/client/vitest.typecheck.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export default defineConfig({
// NO setupFiles or globalSetup - type tests don't need runtime setup
typecheck: {
enabled: true,
tsconfig: './tsconfig.typecheck.json',
},
reporters: ['default'],
},
Expand Down
70 changes: 34 additions & 36 deletions pkgs/core/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@
],
"outputs": ["{projectRoot}/atlas/.supabase-baseline-schema.sql"],
"options": {
"cwd": "{workspaceRoot}",
"cwd": "{projectRoot}",
"commands": [
"scripts/supabase-start-locked.sh {projectRoot}",
"cd {projectRoot} && scripts/atlas-dump-realtime-schema"
"../../scripts/supabase-start-locked.sh .",
"scripts/atlas-dump-realtime-schema"
],
"parallel": false
},
Expand Down Expand Up @@ -63,11 +63,11 @@
"inputs": ["migrations"],
"outputs": ["{projectRoot}/.nx-inputs/verify-migrations.txt"],
"options": {
"cwd": "{workspaceRoot}",
"cwd": "{projectRoot}",
"commands": [
"scripts/supabase-start-locked.sh {projectRoot}",
"cd {projectRoot} && mkdir -p .nx-inputs",
"cd {projectRoot} && supabase db reset > .nx-inputs/verify-migrations.txt 2>&1 || (cat .nx-inputs/verify-migrations.txt && exit 1)"
"../../scripts/supabase-start-locked.sh .",
"mkdir -p .nx-inputs",
"supabase db reset > .nx-inputs/verify-migrations.txt 2>&1 || (cat .nx-inputs/verify-migrations.txt && exit 1)"
],
"parallel": false
},
Expand Down Expand Up @@ -141,9 +141,9 @@
"local": true,
"cache": false,
"options": {
"cwd": "{workspaceRoot}",
"cwd": "{projectRoot}",
"commands": [
"scripts/supabase-start-locked.sh {projectRoot}"
"../../scripts/supabase-start-locked.sh ."
],
"parallel": false
}
Expand All @@ -153,8 +153,8 @@
"local": true,
"cache": false,
"options": {
"cwd": "{workspaceRoot}",
"commands": ["scripts/supabase-start-locked.sh {projectRoot}"],
"cwd": "{projectRoot}",
"commands": ["../../scripts/supabase-start-locked.sh ."],
"parallel": false
}
},
Expand Down Expand Up @@ -193,10 +193,10 @@
"local": true,
"cache": false,
"options": {
"cwd": "{workspaceRoot}",
"cwd": "{projectRoot}",
"commands": [
"scripts/supabase-start-locked.sh {projectRoot}",
"cd {projectRoot} && supabase db reset"
"../../scripts/supabase-start-locked.sh .",
"supabase db reset"
],
"parallel": false
}
Expand All @@ -213,10 +213,10 @@
"inputs": ["schemas", "migrations", "pgtapTests"],
"cache": true,
"options": {
"cwd": "{workspaceRoot}",
"cwd": "{projectRoot}",
"commands": [
"scripts/supabase-start-locked.sh {projectRoot}",
"cd {projectRoot} && scripts/run-test-with-colors"
"../../scripts/supabase-start-locked.sh .",
"scripts/run-test-with-colors"
],
"parallel": false
}
Expand All @@ -237,15 +237,15 @@
"inputs": ["migrations"],
"outputs": ["{projectRoot}/src/database-types.ts"],
"options": {
"cwd": "{projectRoot}",
"commands": [
"scripts/supabase-start-locked.sh {projectRoot}",
"cd {projectRoot} && echo 'Generating database types...'",
"cd {projectRoot} && supabase gen types --local --schema pgflow --schema pgmq > src/database-types.ts",
"cd {projectRoot} && echo 'Verifying generated types...'",
"cd {projectRoot} && grep -q 'pgflow' src/database-types.ts || (echo 'ERROR: Generated types file does not contain pgflow schema!' && exit 1)",
"cd {projectRoot} && [ -s src/database-types.ts ] || (echo 'ERROR: Generated types file is empty!' && exit 1)"
"../../scripts/supabase-start-locked.sh .",
"echo 'Generating database types...'",
"supabase gen types --local --schema pgflow --schema pgmq > src/database-types.ts",
"echo 'Verifying generated types...'",
"grep -q 'pgflow' src/database-types.ts || (echo 'ERROR: Generated types file does not contain pgflow schema!' && exit 1)",
"[ -s src/database-types.ts ] || (echo 'ERROR: Generated types file is empty!' && exit 1)"
],
"cwd": "{workspaceRoot}",
"parallel": false
},
"cache": true
Expand All @@ -256,28 +256,26 @@
"inputs": ["migrations", "databaseTypes"],
"outputs": ["{projectRoot}/.nx-inputs/verify-gen-types.txt"],
"options": {
"cwd": "{workspaceRoot}",
"cwd": "{projectRoot}",
"commands": [
"scripts/supabase-start-locked.sh {projectRoot}",
"cd {projectRoot} && mkdir -p .nx-inputs",
"cd {projectRoot} && echo 'Verifying database types are up-to-date...'",
"cd {projectRoot} && cp src/database-types.ts .nx-inputs/database-types.ts.backup",
"cd {projectRoot} && supabase gen types --local --schema pgflow --schema pgmq > .nx-inputs/database-types.ts.new",
"cd {projectRoot} && diff .nx-inputs/database-types.ts.backup .nx-inputs/database-types.ts.new > .nx-inputs/verify-gen-types.txt 2>&1 || (echo 'ERROR: Database types are out of date! Run \"nx gen-types core\" to update them.' && echo '=============================================' && echo 'Diff between current and generated types:' && echo '=============================================' && diff -u .nx-inputs/database-types.ts.backup .nx-inputs/database-types.ts.new || true && echo '=============================================' && exit 1)",
"cd {projectRoot} && echo 'Database types are up-to-date' > .nx-inputs/verify-gen-types.txt"
"../../scripts/supabase-start-locked.sh .",
"mkdir -p .nx-inputs",
"echo 'Verifying database types are up-to-date...'",
"cp src/database-types.ts .nx-inputs/database-types.ts.backup",
"supabase gen types --local --schema pgflow --schema pgmq > .nx-inputs/database-types.ts.new",
"diff .nx-inputs/database-types.ts.backup .nx-inputs/database-types.ts.new > .nx-inputs/verify-gen-types.txt 2>&1 || (echo 'ERROR: Database types are out of date! Run \"nx gen-types core\" to update them.' && echo '=============================================' && echo 'Diff between current and generated types:' && echo '=============================================' && diff -u .nx-inputs/database-types.ts.backup .nx-inputs/database-types.ts.new || true && echo '=============================================' && exit 1)",
"echo 'Database types are up-to-date' > .nx-inputs/verify-gen-types.txt"
],
"parallel": false
},
"cache": true
},
"test:types:vitest": {
"executor": "nx:run-commands",
"cache": true,
"dependsOn": ["build"],
"inputs": ["default", "^production"],
"dependsOn": ["^build"],
"options": {
"cwd": "{projectRoot}",
"command": "pnpm vitest --typecheck.only --run"
"command": "pnpm vitest --typecheck.only --run --config vitest.typecheck.config.ts"
}
},
"test:types:strict": {
Expand Down
3 changes: 2 additions & 1 deletion pkgs/core/tsconfig.typecheck.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@
"include": [
"__tests__/**/*.test-d.ts",
"__tests__/**/*.spec-d.ts"
]
],
"exclude": ["dist", "node_modules"]
}
2 changes: 1 addition & 1 deletion pkgs/core/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default defineConfig({
globals: true,
environment: 'jsdom',
include: [
'__tests__/**/*.{test,spec,test-d,spec-d}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}',
'__tests__/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}',
],
reporters: ['default'],
coverage: {
Expand Down
22 changes: 22 additions & 0 deletions pkgs/core/vitest.typecheck.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/// <reference types='vitest' />
import { defineConfig } from 'vitest/config';

// Separate config for type tests - NO global setup needed
export default defineConfig({
root: __dirname,
cacheDir: '../../node_modules/.vite/pkgs/core',
test: {
watch: false,
globals: true,
environment: 'node',
include: [
'__tests__/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'
],
// NO setupFiles or globalSetup - type tests don't need runtime setup
typecheck: {
enabled: true,
tsconfig: './tsconfig.typecheck.json',
},
reporters: ['default'],
},
});
33 changes: 4 additions & 29 deletions pkgs/dsl/__tests__/types/array-method.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,27 +20,6 @@ describe('.array() method type constraints', () => {
});

it('should reject handlers that return non-arrays', () => {
const flow = new Flow<Record<string, never>>({ slug: 'test' });

// Test that these handlers are NOT assignable to array handler type
type ArrayHandler = (input: { run: Record<string, never> }, context: any) => Array<any> | Promise<Array<any>>;

const invalidNumber = () => 42;
expectTypeOf(invalidNumber).not.toMatchTypeOf<ArrayHandler>();

const invalidString = () => 'not an array';
expectTypeOf(invalidString).not.toMatchTypeOf<ArrayHandler>();

const invalidObject = () => ({ not: 'array' });
expectTypeOf(invalidObject).not.toMatchTypeOf<ArrayHandler>();

const invalidNull = () => null;
expectTypeOf(invalidNull).not.toMatchTypeOf<ArrayHandler>();

const invalidUndefined = () => undefined;
expectTypeOf(invalidUndefined).not.toMatchTypeOf<ArrayHandler>();

// Keep the runtime tests with @ts-expect-error for actual type enforcement
new Flow<Record<string, never>>({ slug: 'test2' })
// @ts-expect-error - should reject number return
.array({ slug: 'invalid_number' }, () => 42)
Expand Down Expand Up @@ -117,14 +96,10 @@ describe('.array() method type constraints', () => {

describe('dependency validation', () => {
it('should enforce compile-time dependency validation', () => {
const testFlow = new Flow<string>({ slug: 'test' })
.array({ slug: 'items' }, () => [1, 2, 3]);

// Type assertion to verify compile-time error
type TestType = Parameters<typeof testFlow.array>[0]['dependsOn'];
// @ts-expect-error - should only allow 'items' as a valid dependency
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const invalidDeps: TestType = ['nonExistentStep'];
new Flow<string>({ slug: 'test' })
.array({ slug: 'items' }, () => [1, 2, 3])
// @ts-expect-error - should reject non-existent dependency
.array({ slug: 'invalid', dependsOn: ['nonExistentStep'] }, () => []);
});

it('should not allow access to non-dependencies', () => {
Expand Down
6 changes: 3 additions & 3 deletions pkgs/dsl/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@
},
"test:types:vitest": {
"executor": "nx:run-commands",
"dependsOn": ["build"],
"dependsOn": [],
"options": {
"cwd": "{projectRoot}",
"command": "pnpm vitest --typecheck.only --run"
"command": "pnpm vitest --typecheck.only --run --config vitest.typecheck.config.ts"
}
},
"test:types:strict": {
"executor": "nx:run-commands",
"dependsOn": ["build"],
"dependsOn": [],
"options": {
"cwd": "{projectRoot}",
"command": "bash ../../scripts/typecheck-ts2578.sh"
Expand Down
4 changes: 3 additions & 1 deletion pkgs/dsl/tsconfig.typecheck.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
"__tests__/**/*.spec-d.ts"
],
"exclude": [
"__tests__/**/__health__.test-d.ts"
"__tests__/**/__health__.test-d.ts",
"dist",
"node_modules"
]
}
2 changes: 1 addition & 1 deletion pkgs/dsl/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default defineConfig({
globals: true,
environment: 'jsdom',
include: [
'__tests__/**/*.{test,spec,test-d,spec-d}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}',
'__tests__/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}',
],
reporters: ['default'],
coverage: {
Expand Down
22 changes: 22 additions & 0 deletions pkgs/dsl/vitest.typecheck.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/// <reference types='vitest' />
import { defineConfig } from 'vitest/config';

// Separate config for type tests - NO global setup needed
export default defineConfig({
root: __dirname,
cacheDir: '../../node_modules/.vite/pkgs/dsl',
test: {
watch: false,
globals: true,
environment: 'node',
include: [
'__tests__/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'
],
// NO setupFiles or globalSetup - type tests don't need runtime setup
typecheck: {
enabled: true,
tsconfig: './tsconfig.typecheck.json',
},
reporters: ['default'],
},
});
Loading