Home / File/ action-input-schema.ts — astro Source File

action-input-schema.ts — astro Source File

Architecture documentation for action-input-schema.ts, a typescript file in the astro codebase. 5 imports, 0 dependents.

Entity Profile

Dependency Diagram

graph LR
  5c91ac57_9fab_6af6_9ad2_920e0f9a8b6c["action-input-schema.ts"]
  e6a2dc9f_6948_1e06_e648_bf517c8e5501["../../../dist/actions/runtime/server.js"]
  5c91ac57_9fab_6af6_9ad2_920e0f9a8b6c --> e6a2dc9f_6948_1e06_e648_bf517c8e5501
  b452f73b_f98f_aa44_9234_6b4bf8f5bf18["../../dist/actions/runtime/types.js"]
  5c91ac57_9fab_6af6_9ad2_920e0f9a8b6c --> b452f73b_f98f_aa44_9234_6b4bf8f5bf18
  c6e6d952_1368_2c1c_2f3a_ad92a305600b["../../dist/zod.js"]
  5c91ac57_9fab_6af6_9ad2_920e0f9a8b6c --> c6e6d952_1368_2c1c_2f3a_ad92a305600b
  6b0635f9_51ea_77aa_767b_7857878e98a6["node:test"]
  5c91ac57_9fab_6af6_9ad2_920e0f9a8b6c --> 6b0635f9_51ea_77aa_767b_7857878e98a6
  687364c6_0b6b_44e7_012a_aa483da82c1b["expect-type"]
  5c91ac57_9fab_6af6_9ad2_920e0f9a8b6c --> 687364c6_0b6b_44e7_012a_aa483da82c1b
  style 5c91ac57_9fab_6af6_9ad2_920e0f9a8b6c fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import { describe, it } from 'node:test';
import { expectTypeOf } from 'expect-type';
import { defineAction } from '../../dist/actions/runtime/server.js';
import type { ActionInputSchema } from '../../dist/actions/runtime/types.js';
import { z } from '../../dist/zod.js';

describe('ActionInputSchema', () => {
	const acceptVariants = ['form', 'json', undefined] as const;

	for (const accept of acceptVariants) {
		describe(`accept = ${typeof accept === 'string' ? `'${accept}'` : accept}`, () => {
			it('Infers action input schema', async () => {
				const inputSchema = z.object({
					name: z.string(),
					age: z.number(),
				});

				const _action = defineAction({
					accept,
					input: inputSchema,
					handler: () => undefined,
				});

				expectTypeOf<ActionInputSchema<typeof _action>>().toEqualTypeOf<typeof inputSchema>();
			});

			it('Infers action input value', async () => {
				const schema = z.object({
					name: z.string(),
					age: z.number(),
				});
				const _action = defineAction({
					accept,
					input: schema,
					handler: () => undefined,
				});
				expectTypeOf<z.input<ActionInputSchema<typeof _action>>>().toEqualTypeOf<{
					name: string;
					age: number;
				}>();
			});

			it('Infers action input schema when input is omitted', async () => {
				const _action = defineAction({
					accept,
					handler: () => undefined,
				});
				expectTypeOf<ActionInputSchema<typeof _action>>().toBeNever;
			});
		});
	}
});

Dependencies

  • ../../../dist/actions/runtime/server.js
  • ../../dist/actions/runtime/types.js
  • ../../dist/zod.js
  • expect-type
  • node:test

Frequently Asked Questions

What does action-input-schema.ts do?
action-input-schema.ts is a source file in the astro codebase, written in typescript. It belongs to the IntegrationAdapters domain.
What does action-input-schema.ts depend on?
action-input-schema.ts imports 5 module(s): ../../../dist/actions/runtime/server.js, ../../dist/actions/runtime/types.js, ../../dist/zod.js, expect-type, node:test.
Where is action-input-schema.ts in the architecture?
action-input-schema.ts is located at packages/astro/test/types/action-input-schema.ts (domain: IntegrationAdapters, directory: packages/astro/test/types).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free