Initial commit: Add project files
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
import { api } from '@/shared/api/client'
|
||||
import { responseSchema, type RequestDto, type ResponseDto } from './schema'
|
||||
export async function execute(request: RequestDto): Promise<ResponseDto> {
|
||||
const response = await api.post('/api/v1/__MODULE__/__FEATURE__', request, { headers: { 'Idempotency-Key': request.idempotencyKey } })
|
||||
return responseSchema.parse(response.data)
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
<script setup lang="ts">import { CrudDetailPage } from '@/shared/ui/screen-types'</script>
|
||||
<template><CrudDetailPage title="__FEATURE__" status="IMPLEMENTATION_REQUIRED"><p>__SLICE_ID__ Slice packet. Replace this placeholder only after the Slice Ready Gate is approved.</p></CrudDetailPage></template>
|
||||
@@ -0,0 +1,4 @@
|
||||
import { useMutation, useQueryClient } from '@tanstack/vue-query'
|
||||
import { execute } from './api'
|
||||
export const queryKeys = { root: ['__MODULE__','__FEATURE__'] as const }
|
||||
export function useExecuteMutation() { const client=useQueryClient(); return useMutation({ mutationFn: execute, onSuccess: async()=>client.invalidateQueries({queryKey:queryKeys.root}) }) }
|
||||
@@ -0,0 +1,5 @@
|
||||
import { z } from 'zod'
|
||||
export const requestSchema = z.object({ idempotencyKey: z.string().min(1).max(100), scopeId: z.string().min(1), asOf: z.string().datetime() })
|
||||
export const responseSchema = z.object({ id: z.string().uuid(), status: z.string(), evidenceHash: z.string().min(16), asOf: z.string().datetime() })
|
||||
export type RequestDto = z.infer<typeof requestSchema>
|
||||
export type ResponseDto = z.infer<typeof responseSchema>
|
||||
@@ -0,0 +1,3 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { requestSchema } from '../schema'
|
||||
describe('__SLICE_ID__ request contract',()=>{it('rejects missing idempotency evidence',()=>{expect(requestSchema.safeParse({scopeId:'x',asOf:new Date().toISOString()}).success).toBe(false)})})
|
||||
Reference in New Issue
Block a user