Skip to content

Commit 14d984b

Browse files
authored
Merge pull request #411 from objectstack-ai/copilot/fix-step-eight-error
2 parents 221b135 + cc70bb6 commit 14d984b

4 files changed

Lines changed: 65 additions & 9 deletions

File tree

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
---
2+
title: View
3+
description: View protocol schemas
4+
---
5+
6+
# View
7+
8+
<Callout type="info">
9+
**Source:** `packages/spec/src/api/view.zod.ts`
10+
</Callout>
11+
12+
## TypeScript Usage
13+
14+
```typescript
15+
import { HttpMethodSchema } from '@objectstack/spec/api';
16+
import type { HttpMethod } from '@objectstack/spec/api';
17+
18+
// Validate data
19+
const result = HttpMethodSchema.parse(data);
20+
```
21+
22+
---
23+
24+
## HttpMethod
25+
26+
### Allowed Values
27+
28+
* `GET`
29+
* `POST`
30+
* `PUT`
31+
* `DELETE`
32+
* `PATCH`
33+
* `HEAD`
34+
* `OPTIONS`
35+
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"$ref": "#/definitions/HttpMethod",
3+
"definitions": {
4+
"HttpMethod": {
5+
"type": "string",
6+
"enum": [
7+
"GET",
8+
"POST",
9+
"PUT",
10+
"DELETE",
11+
"PATCH",
12+
"HEAD",
13+
"OPTIONS"
14+
]
15+
}
16+
},
17+
"$schema": "http://json-schema.org/draft-07/schema#"
18+
}

packages/spec/src/api/router.zod.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import { z } from 'zod';
22
import { CorsConfigSchema, StaticMountSchema, HttpMethod } from '../shared/http.zod';
33

4+
// Re-export HttpMethod for convenience
5+
export { HttpMethod };
6+
47
/**
58
* Route Category Enum
69
* Classifies routes for middleware application and security policies.

packages/spec/src/data/external-lookup.test.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { describe, it, expect } from 'vitest';
22
import {
33
ExternalDataSourceSchema,
4-
FieldMappingSchema,
4+
ExternalFieldMappingSchema,
55
ExternalLookupSchema,
66
type ExternalLookup,
77
type ExternalDataSource,
8-
type FieldMapping,
8+
type ExternalFieldMapping,
99
} from './external-lookup.zod';
1010

1111
describe('ExternalDataSourceSchema', () => {
@@ -118,16 +118,16 @@ describe('ExternalDataSourceSchema', () => {
118118
});
119119
});
120120

121-
describe('FieldMappingSchema', () => {
121+
describe('ExternalFieldMappingSchema', () => {
122122
it('should validate complete field mapping', () => {
123-
const validMapping: FieldMapping = {
123+
const validMapping: ExternalFieldMapping = {
124124
source: 'AccountName',
125125
target: 'name',
126126
type: 'text',
127127
readonly: true,
128128
};
129129

130-
expect(() => FieldMappingSchema.parse(validMapping)).not.toThrow();
130+
expect(() => ExternalFieldMappingSchema.parse(validMapping)).not.toThrow();
131131
});
132132

133133
it('should accept minimal field mapping', () => {
@@ -137,7 +137,7 @@ describe('FieldMappingSchema', () => {
137137
type: 'text',
138138
};
139139

140-
expect(() => FieldMappingSchema.parse(minimalMapping)).not.toThrow();
140+
expect(() => ExternalFieldMappingSchema.parse(minimalMapping)).not.toThrow();
141141
});
142142

143143
it('should default readonly to true', () => {
@@ -147,7 +147,7 @@ describe('FieldMappingSchema', () => {
147147
type: 'text',
148148
};
149149

150-
const parsed = FieldMappingSchema.parse(mapping);
150+
const parsed = ExternalFieldMappingSchema.parse(mapping);
151151
expect(parsed.readonly).toBe(true);
152152
});
153153

@@ -159,7 +159,7 @@ describe('FieldMappingSchema', () => {
159159
readonly: false,
160160
};
161161

162-
expect(() => FieldMappingSchema.parse(writableMapping)).not.toThrow();
162+
expect(() => ExternalFieldMappingSchema.parse(writableMapping)).not.toThrow();
163163
});
164164

165165
it('should accept various field types', () => {
@@ -172,7 +172,7 @@ describe('FieldMappingSchema', () => {
172172
type,
173173
};
174174

175-
expect(() => FieldMappingSchema.parse(mapping)).not.toThrow();
175+
expect(() => ExternalFieldMappingSchema.parse(mapping)).not.toThrow();
176176
});
177177
});
178178
});

0 commit comments

Comments
 (0)