@elevasis/core 0.49.0 → 0.50.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -3
- package/src/operations/public-agent-chat/__tests__/api-schemas.test.ts +104 -0
- package/src/operations/public-agent-chat/api-schemas.ts +22 -1
- package/src/operations/public-agent-chat/index.ts +3 -1
- package/src/platform/constants/versions.ts +1 -1
- package/src/platform/registry/__tests__/resource-registry.integration.test.ts +1010 -1013
- package/src/platform/registry/serialization.ts +296 -295
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elevasis/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.50.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Minimal shared constants across Elevasis monorepo",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -45,8 +45,8 @@
|
|
|
45
45
|
"rollup-plugin-dts": "^6.3.0",
|
|
46
46
|
"tsup": "^8.0.0",
|
|
47
47
|
"typescript": "5.9.2",
|
|
48
|
-
"@repo/
|
|
49
|
-
"@repo/
|
|
48
|
+
"@repo/eslint-config": "0.0.0",
|
|
49
|
+
"@repo/typescript-config": "0.0.0"
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
52
|
"@anthropic-ai/sdk": "^0.62.0",
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest'
|
|
2
|
+
import {
|
|
3
|
+
PublicAgentChatAuthorizeSchema,
|
|
4
|
+
PublicAgentChatBrandingSchema,
|
|
5
|
+
PublicAgentChatCreateSessionSchema,
|
|
6
|
+
PublicAgentChatSlugParamSchema
|
|
7
|
+
} from '../api-schemas'
|
|
8
|
+
|
|
9
|
+
describe('PublicAgentChatBrandingSchema', () => {
|
|
10
|
+
it('accepts an empty object (every key is optional)', () => {
|
|
11
|
+
expect(PublicAgentChatBrandingSchema.safeParse({}).success).toBe(true)
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
it('accepts a fully-populated branding payload', () => {
|
|
15
|
+
const result = PublicAgentChatBrandingSchema.safeParse({
|
|
16
|
+
title: 'Voice Capture Interview',
|
|
17
|
+
subtitle: 'Help us capture your authentic voice',
|
|
18
|
+
displayName: 'Byron',
|
|
19
|
+
agentName: 'byron-voice-capture-agent',
|
|
20
|
+
name: 'Byron',
|
|
21
|
+
description: 'A short, guided interview',
|
|
22
|
+
intro: 'This is a short, guided interview.',
|
|
23
|
+
instructions: ['Answer the way you would really say it', 'It takes about 15 minutes'],
|
|
24
|
+
ctaLabel: 'Start the interview',
|
|
25
|
+
greeting: 'Hi, welcome — thanks for taking the time.',
|
|
26
|
+
agentOpens: true
|
|
27
|
+
})
|
|
28
|
+
expect(result.success).toBe(true)
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
it('accepts partial payloads carrying only intro or only greeting', () => {
|
|
32
|
+
expect(PublicAgentChatBrandingSchema.safeParse({ intro: 'Just an intro' }).success).toBe(true)
|
|
33
|
+
expect(PublicAgentChatBrandingSchema.safeParse({ greeting: 'Just a greeting' }).success).toBe(true)
|
|
34
|
+
expect(PublicAgentChatBrandingSchema.safeParse({ instructions: ['one', 'two'] }).success).toBe(true)
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
it('rejects unknown keys (.strict — mass-assignment guard)', () => {
|
|
38
|
+
expect(PublicAgentChatBrandingSchema.safeParse({ intro: 'hi', unexpected: 'nope' }).success).toBe(false)
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
it('rejects a non-string entry inside instructions', () => {
|
|
42
|
+
expect(PublicAgentChatBrandingSchema.safeParse({ instructions: ['ok', 42] }).success).toBe(false)
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
it('rejects a non-array instructions value', () => {
|
|
46
|
+
expect(PublicAgentChatBrandingSchema.safeParse({ instructions: 'not-an-array' }).success).toBe(false)
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
it('rejects a non-boolean agentOpens', () => {
|
|
50
|
+
expect(PublicAgentChatBrandingSchema.safeParse({ agentOpens: 'yes' }).success).toBe(false)
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
it('rejects a non-string scalar branding field', () => {
|
|
54
|
+
expect(PublicAgentChatBrandingSchema.safeParse({ title: 123 }).success).toBe(false)
|
|
55
|
+
})
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
// The branding schema ships alongside these siblings, which previously had no
|
|
59
|
+
// coverage. Guard the validators the Feature 1 code path actually exercises.
|
|
60
|
+
describe('PublicAgentChatAuthorizeSchema', () => {
|
|
61
|
+
it('accepts an empty object (code and visitorId both optional)', () => {
|
|
62
|
+
expect(PublicAgentChatAuthorizeSchema.safeParse({}).success).toBe(true)
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
it('accepts a code and visitorId', () => {
|
|
66
|
+
expect(PublicAgentChatAuthorizeSchema.safeParse({ code: 'secret', visitorId: 'visitor-1' }).success).toBe(true)
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
it('rejects an empty code string', () => {
|
|
70
|
+
expect(PublicAgentChatAuthorizeSchema.safeParse({ code: '' }).success).toBe(false)
|
|
71
|
+
})
|
|
72
|
+
|
|
73
|
+
it('rejects unknown keys (.strict)', () => {
|
|
74
|
+
expect(PublicAgentChatAuthorizeSchema.safeParse({ password: 'x' }).success).toBe(false)
|
|
75
|
+
})
|
|
76
|
+
})
|
|
77
|
+
|
|
78
|
+
describe('PublicAgentChatSlugParamSchema', () => {
|
|
79
|
+
it('accepts a valid slug', () => {
|
|
80
|
+
expect(PublicAgentChatSlugParamSchema.safeParse({ slug: 'candidate-voice-agent-coded' }).success).toBe(true)
|
|
81
|
+
})
|
|
82
|
+
|
|
83
|
+
it('rejects a slug with path-traversal / illegal characters', () => {
|
|
84
|
+
expect(PublicAgentChatSlugParamSchema.safeParse({ slug: 'bad/slug' }).success).toBe(false)
|
|
85
|
+
})
|
|
86
|
+
|
|
87
|
+
it('rejects an empty slug', () => {
|
|
88
|
+
expect(PublicAgentChatSlugParamSchema.safeParse({ slug: '' }).success).toBe(false)
|
|
89
|
+
})
|
|
90
|
+
})
|
|
91
|
+
|
|
92
|
+
describe('PublicAgentChatCreateSessionSchema', () => {
|
|
93
|
+
it('accepts an empty object (all fields optional)', () => {
|
|
94
|
+
expect(PublicAgentChatCreateSessionSchema.safeParse({}).success).toBe(true)
|
|
95
|
+
})
|
|
96
|
+
|
|
97
|
+
it('rejects a capabilityToken shorter than 32 chars', () => {
|
|
98
|
+
expect(PublicAgentChatCreateSessionSchema.safeParse({ capabilityToken: 'too-short' }).success).toBe(false)
|
|
99
|
+
})
|
|
100
|
+
|
|
101
|
+
it('rejects unknown keys (.strict)', () => {
|
|
102
|
+
expect(PublicAgentChatCreateSessionSchema.safeParse({ rogue: true }).success).toBe(false)
|
|
103
|
+
})
|
|
104
|
+
})
|
|
@@ -3,7 +3,11 @@ import { UuidSchema } from '../../platform/utils/validation'
|
|
|
3
3
|
|
|
4
4
|
export const PublicAgentChatSlugParamSchema = z
|
|
5
5
|
.object({
|
|
6
|
-
slug: z
|
|
6
|
+
slug: z
|
|
7
|
+
.string()
|
|
8
|
+
.min(1)
|
|
9
|
+
.max(120)
|
|
10
|
+
.regex(/^[a-zA-Z0-9._-]+$/)
|
|
7
11
|
})
|
|
8
12
|
.strict()
|
|
9
13
|
|
|
@@ -33,8 +37,25 @@ export const PublicAgentChatCapabilityQuerySchema = z
|
|
|
33
37
|
})
|
|
34
38
|
.strict()
|
|
35
39
|
|
|
40
|
+
export const PublicAgentChatBrandingSchema = z
|
|
41
|
+
.object({
|
|
42
|
+
title: z.string().optional(),
|
|
43
|
+
subtitle: z.string().optional(),
|
|
44
|
+
displayName: z.string().optional(),
|
|
45
|
+
agentName: z.string().optional(),
|
|
46
|
+
name: z.string().optional(),
|
|
47
|
+
description: z.string().optional(),
|
|
48
|
+
intro: z.string().optional(),
|
|
49
|
+
instructions: z.array(z.string()).optional(),
|
|
50
|
+
ctaLabel: z.string().optional(),
|
|
51
|
+
greeting: z.string().optional(),
|
|
52
|
+
agentOpens: z.boolean().optional()
|
|
53
|
+
})
|
|
54
|
+
.strict()
|
|
55
|
+
|
|
36
56
|
export type PublicAgentChatSlugParams = z.infer<typeof PublicAgentChatSlugParamSchema>
|
|
37
57
|
export type PublicAgentChatSessionParams = z.infer<typeof PublicAgentChatSessionParamSchema>
|
|
38
58
|
export type PublicAgentChatAuthorizeInput = z.infer<typeof PublicAgentChatAuthorizeSchema>
|
|
39
59
|
export type PublicAgentChatCreateSessionInput = z.infer<typeof PublicAgentChatCreateSessionSchema>
|
|
40
60
|
export type PublicAgentChatCapabilityQuery = z.infer<typeof PublicAgentChatCapabilityQuerySchema>
|
|
61
|
+
export type PublicAgentChatBranding = z.infer<typeof PublicAgentChatBrandingSchema>
|
|
@@ -4,9 +4,11 @@ export {
|
|
|
4
4
|
PublicAgentChatAuthorizeSchema,
|
|
5
5
|
PublicAgentChatCreateSessionSchema,
|
|
6
6
|
PublicAgentChatCapabilityQuerySchema,
|
|
7
|
+
PublicAgentChatBrandingSchema,
|
|
7
8
|
type PublicAgentChatSlugParams,
|
|
8
9
|
type PublicAgentChatSessionParams,
|
|
9
10
|
type PublicAgentChatAuthorizeInput,
|
|
10
11
|
type PublicAgentChatCreateSessionInput,
|
|
11
|
-
type PublicAgentChatCapabilityQuery
|
|
12
|
+
type PublicAgentChatCapabilityQuery,
|
|
13
|
+
type PublicAgentChatBranding
|
|
12
14
|
} from './api-schemas'
|