@aerostack/core 0.8.4 → 0.8.6
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/README.md +85 -3
- package/dist/__tests__/client.test.d.ts +1 -0
- package/dist/__tests__/client.test.js +1240 -0
- package/dist/__tests__/registry.test.d.ts +1 -0
- package/dist/__tests__/registry.test.js +264 -0
- package/package.json +1 -1
- package/src/__tests__/client.test.ts +1475 -0
- package/src/__tests__/registry.test.ts +310 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const vitest_1 = require("vitest");
|
|
4
|
+
const registry_1 = require("../schemas/registry");
|
|
5
|
+
(0, vitest_1.describe)('RegistryConfigSchema', () => {
|
|
6
|
+
const validConfig = {
|
|
7
|
+
name: 'my-component',
|
|
8
|
+
version: '1.0.0',
|
|
9
|
+
description: 'A test component for validation',
|
|
10
|
+
type: 'feature',
|
|
11
|
+
};
|
|
12
|
+
// ─── Valid Configs ────────────────────────────────────────────
|
|
13
|
+
(0, vitest_1.describe)('valid configurations', () => {
|
|
14
|
+
(0, vitest_1.it)('should accept minimal valid config', () => {
|
|
15
|
+
const result = registry_1.RegistryConfigSchema.safeParse(validConfig);
|
|
16
|
+
(0, vitest_1.expect)(result.success).toBe(true);
|
|
17
|
+
});
|
|
18
|
+
(0, vitest_1.it)('should accept config with all optional fields', () => {
|
|
19
|
+
const result = registry_1.RegistryConfigSchema.safeParse({
|
|
20
|
+
...validConfig,
|
|
21
|
+
$schema: 'https://example.com/schema.json',
|
|
22
|
+
author: 'Test Author',
|
|
23
|
+
dependencies: ['react', 'react-dom'],
|
|
24
|
+
registryDependencies: ['button', 'input'],
|
|
25
|
+
files: [{ source: 'src/component.tsx', target: 'components/component.tsx' }],
|
|
26
|
+
configuration: {
|
|
27
|
+
api_route: '/api/component',
|
|
28
|
+
env: ['API_KEY', 'SECRET'],
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
(0, vitest_1.expect)(result.success).toBe(true);
|
|
32
|
+
});
|
|
33
|
+
(0, vitest_1.it)('should accept type "feature"', () => {
|
|
34
|
+
const result = registry_1.RegistryConfigSchema.safeParse({ ...validConfig, type: 'feature' });
|
|
35
|
+
(0, vitest_1.expect)(result.success).toBe(true);
|
|
36
|
+
});
|
|
37
|
+
(0, vitest_1.it)('should accept type "utility"', () => {
|
|
38
|
+
const result = registry_1.RegistryConfigSchema.safeParse({ ...validConfig, type: 'utility' });
|
|
39
|
+
(0, vitest_1.expect)(result.success).toBe(true);
|
|
40
|
+
});
|
|
41
|
+
(0, vitest_1.it)('should accept type "hook"', () => {
|
|
42
|
+
const result = registry_1.RegistryConfigSchema.safeParse({ ...validConfig, type: 'hook' });
|
|
43
|
+
(0, vitest_1.expect)(result.success).toBe(true);
|
|
44
|
+
});
|
|
45
|
+
(0, vitest_1.it)('should default dependencies to empty array', () => {
|
|
46
|
+
const result = registry_1.RegistryConfigSchema.parse(validConfig);
|
|
47
|
+
(0, vitest_1.expect)(result.dependencies).toEqual([]);
|
|
48
|
+
});
|
|
49
|
+
(0, vitest_1.it)('should default registryDependencies to empty array', () => {
|
|
50
|
+
const result = registry_1.RegistryConfigSchema.parse(validConfig);
|
|
51
|
+
(0, vitest_1.expect)(result.registryDependencies).toEqual([]);
|
|
52
|
+
});
|
|
53
|
+
(0, vitest_1.it)('should default files to empty array', () => {
|
|
54
|
+
const result = registry_1.RegistryConfigSchema.parse(validConfig);
|
|
55
|
+
(0, vitest_1.expect)(result.files).toEqual([]);
|
|
56
|
+
});
|
|
57
|
+
(0, vitest_1.it)('should default configuration.env to empty array', () => {
|
|
58
|
+
const result = registry_1.RegistryConfigSchema.parse(validConfig);
|
|
59
|
+
(0, vitest_1.expect)(result.configuration?.env).toEqual([]);
|
|
60
|
+
});
|
|
61
|
+
(0, vitest_1.it)('should accept name with hyphens', () => {
|
|
62
|
+
const result = registry_1.RegistryConfigSchema.safeParse({
|
|
63
|
+
...validConfig,
|
|
64
|
+
name: 'my-cool-component',
|
|
65
|
+
});
|
|
66
|
+
(0, vitest_1.expect)(result.success).toBe(true);
|
|
67
|
+
});
|
|
68
|
+
(0, vitest_1.it)('should accept name with numbers', () => {
|
|
69
|
+
const result = registry_1.RegistryConfigSchema.safeParse({
|
|
70
|
+
...validConfig,
|
|
71
|
+
name: 'component123',
|
|
72
|
+
});
|
|
73
|
+
(0, vitest_1.expect)(result.success).toBe(true);
|
|
74
|
+
});
|
|
75
|
+
(0, vitest_1.it)('should accept 2-character name', () => {
|
|
76
|
+
const result = registry_1.RegistryConfigSchema.safeParse({
|
|
77
|
+
...validConfig,
|
|
78
|
+
name: 'ab',
|
|
79
|
+
});
|
|
80
|
+
(0, vitest_1.expect)(result.success).toBe(true);
|
|
81
|
+
});
|
|
82
|
+
(0, vitest_1.it)('should accept 50-character name', () => {
|
|
83
|
+
const result = registry_1.RegistryConfigSchema.safeParse({
|
|
84
|
+
...validConfig,
|
|
85
|
+
name: 'a'.repeat(50),
|
|
86
|
+
});
|
|
87
|
+
(0, vitest_1.expect)(result.success).toBe(true);
|
|
88
|
+
});
|
|
89
|
+
(0, vitest_1.it)('should accept semver versions', () => {
|
|
90
|
+
for (const ver of ['0.0.1', '1.0.0', '10.20.30', '999.999.999']) {
|
|
91
|
+
const result = registry_1.RegistryConfigSchema.safeParse({ ...validConfig, version: ver });
|
|
92
|
+
(0, vitest_1.expect)(result.success).toBe(true);
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
(0, vitest_1.it)('should accept description with exactly 10 characters', () => {
|
|
96
|
+
const result = registry_1.RegistryConfigSchema.safeParse({
|
|
97
|
+
...validConfig,
|
|
98
|
+
description: '1234567890',
|
|
99
|
+
});
|
|
100
|
+
(0, vitest_1.expect)(result.success).toBe(true);
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
// ─── Invalid Configs - Name ───────────────────────────────────
|
|
104
|
+
(0, vitest_1.describe)('invalid name', () => {
|
|
105
|
+
(0, vitest_1.it)('should reject name shorter than 2 characters', () => {
|
|
106
|
+
const result = registry_1.RegistryConfigSchema.safeParse({ ...validConfig, name: 'a' });
|
|
107
|
+
(0, vitest_1.expect)(result.success).toBe(false);
|
|
108
|
+
});
|
|
109
|
+
(0, vitest_1.it)('should reject empty name', () => {
|
|
110
|
+
const result = registry_1.RegistryConfigSchema.safeParse({ ...validConfig, name: '' });
|
|
111
|
+
(0, vitest_1.expect)(result.success).toBe(false);
|
|
112
|
+
});
|
|
113
|
+
(0, vitest_1.it)('should reject name longer than 50 characters', () => {
|
|
114
|
+
const result = registry_1.RegistryConfigSchema.safeParse({
|
|
115
|
+
...validConfig,
|
|
116
|
+
name: 'a'.repeat(51),
|
|
117
|
+
});
|
|
118
|
+
(0, vitest_1.expect)(result.success).toBe(false);
|
|
119
|
+
});
|
|
120
|
+
(0, vitest_1.it)('should reject name with uppercase letters', () => {
|
|
121
|
+
const result = registry_1.RegistryConfigSchema.safeParse({
|
|
122
|
+
...validConfig,
|
|
123
|
+
name: 'MyComponent',
|
|
124
|
+
});
|
|
125
|
+
(0, vitest_1.expect)(result.success).toBe(false);
|
|
126
|
+
});
|
|
127
|
+
(0, vitest_1.it)('should reject name with spaces', () => {
|
|
128
|
+
const result = registry_1.RegistryConfigSchema.safeParse({
|
|
129
|
+
...validConfig,
|
|
130
|
+
name: 'my component',
|
|
131
|
+
});
|
|
132
|
+
(0, vitest_1.expect)(result.success).toBe(false);
|
|
133
|
+
});
|
|
134
|
+
(0, vitest_1.it)('should reject name with underscores', () => {
|
|
135
|
+
const result = registry_1.RegistryConfigSchema.safeParse({
|
|
136
|
+
...validConfig,
|
|
137
|
+
name: 'my_component',
|
|
138
|
+
});
|
|
139
|
+
(0, vitest_1.expect)(result.success).toBe(false);
|
|
140
|
+
});
|
|
141
|
+
(0, vitest_1.it)('should reject name with special characters', () => {
|
|
142
|
+
for (const name of ['my@component', 'my.component', 'my/component', 'my+component']) {
|
|
143
|
+
const result = registry_1.RegistryConfigSchema.safeParse({ ...validConfig, name });
|
|
144
|
+
(0, vitest_1.expect)(result.success).toBe(false);
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
});
|
|
148
|
+
// ─── Invalid Configs - Version ────────────────────────────────
|
|
149
|
+
(0, vitest_1.describe)('invalid version', () => {
|
|
150
|
+
(0, vitest_1.it)('should reject non-semver versions', () => {
|
|
151
|
+
for (const version of ['1.0', '1', 'v1.0.0', '1.0.0-beta', '1.0.0.0']) {
|
|
152
|
+
const result = registry_1.RegistryConfigSchema.safeParse({ ...validConfig, version });
|
|
153
|
+
(0, vitest_1.expect)(result.success).toBe(false);
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
(0, vitest_1.it)('should reject empty version', () => {
|
|
157
|
+
const result = registry_1.RegistryConfigSchema.safeParse({ ...validConfig, version: '' });
|
|
158
|
+
(0, vitest_1.expect)(result.success).toBe(false);
|
|
159
|
+
});
|
|
160
|
+
});
|
|
161
|
+
// ─── Invalid Configs - Description ────────────────────────────
|
|
162
|
+
(0, vitest_1.describe)('invalid description', () => {
|
|
163
|
+
(0, vitest_1.it)('should reject description shorter than 10 characters', () => {
|
|
164
|
+
const result = registry_1.RegistryConfigSchema.safeParse({
|
|
165
|
+
...validConfig,
|
|
166
|
+
description: 'Short',
|
|
167
|
+
});
|
|
168
|
+
(0, vitest_1.expect)(result.success).toBe(false);
|
|
169
|
+
});
|
|
170
|
+
(0, vitest_1.it)('should reject empty description', () => {
|
|
171
|
+
const result = registry_1.RegistryConfigSchema.safeParse({ ...validConfig, description: '' });
|
|
172
|
+
(0, vitest_1.expect)(result.success).toBe(false);
|
|
173
|
+
});
|
|
174
|
+
});
|
|
175
|
+
// ─── Invalid Configs - Type ───────────────────────────────────
|
|
176
|
+
(0, vitest_1.describe)('invalid type', () => {
|
|
177
|
+
(0, vitest_1.it)('should reject invalid type values', () => {
|
|
178
|
+
for (const type of ['component', 'page', 'widget', 'plugin', '']) {
|
|
179
|
+
const result = registry_1.RegistryConfigSchema.safeParse({ ...validConfig, type });
|
|
180
|
+
(0, vitest_1.expect)(result.success).toBe(false);
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
});
|
|
184
|
+
// ─── Invalid Configs - $schema ────────────────────────────────
|
|
185
|
+
(0, vitest_1.describe)('invalid $schema', () => {
|
|
186
|
+
(0, vitest_1.it)('should reject non-URL $schema', () => {
|
|
187
|
+
const result = registry_1.RegistryConfigSchema.safeParse({
|
|
188
|
+
...validConfig,
|
|
189
|
+
$schema: 'not-a-url',
|
|
190
|
+
});
|
|
191
|
+
(0, vitest_1.expect)(result.success).toBe(false);
|
|
192
|
+
});
|
|
193
|
+
});
|
|
194
|
+
// ─── Missing Required Fields ──────────────────────────────────
|
|
195
|
+
(0, vitest_1.describe)('missing required fields', () => {
|
|
196
|
+
(0, vitest_1.it)('should reject config without name', () => {
|
|
197
|
+
const { name, ...config } = validConfig;
|
|
198
|
+
const result = registry_1.RegistryConfigSchema.safeParse(config);
|
|
199
|
+
(0, vitest_1.expect)(result.success).toBe(false);
|
|
200
|
+
});
|
|
201
|
+
(0, vitest_1.it)('should reject config without version', () => {
|
|
202
|
+
const { version, ...config } = validConfig;
|
|
203
|
+
const result = registry_1.RegistryConfigSchema.safeParse(config);
|
|
204
|
+
(0, vitest_1.expect)(result.success).toBe(false);
|
|
205
|
+
});
|
|
206
|
+
(0, vitest_1.it)('should reject config without description', () => {
|
|
207
|
+
const { description, ...config } = validConfig;
|
|
208
|
+
const result = registry_1.RegistryConfigSchema.safeParse(config);
|
|
209
|
+
(0, vitest_1.expect)(result.success).toBe(false);
|
|
210
|
+
});
|
|
211
|
+
(0, vitest_1.it)('should reject config without type', () => {
|
|
212
|
+
const { type, ...config } = validConfig;
|
|
213
|
+
const result = registry_1.RegistryConfigSchema.safeParse(config);
|
|
214
|
+
(0, vitest_1.expect)(result.success).toBe(false);
|
|
215
|
+
});
|
|
216
|
+
(0, vitest_1.it)('should reject empty object', () => {
|
|
217
|
+
const result = registry_1.RegistryConfigSchema.safeParse({});
|
|
218
|
+
(0, vitest_1.expect)(result.success).toBe(false);
|
|
219
|
+
});
|
|
220
|
+
(0, vitest_1.it)('should reject null', () => {
|
|
221
|
+
const result = registry_1.RegistryConfigSchema.safeParse(null);
|
|
222
|
+
(0, vitest_1.expect)(result.success).toBe(false);
|
|
223
|
+
});
|
|
224
|
+
(0, vitest_1.it)('should reject undefined', () => {
|
|
225
|
+
const result = registry_1.RegistryConfigSchema.safeParse(undefined);
|
|
226
|
+
(0, vitest_1.expect)(result.success).toBe(false);
|
|
227
|
+
});
|
|
228
|
+
});
|
|
229
|
+
// ─── validateRegistryConfig ───────────────────────────────────
|
|
230
|
+
(0, vitest_1.describe)('validateRegistryConfig', () => {
|
|
231
|
+
(0, vitest_1.it)('should return parsed config for valid input', () => {
|
|
232
|
+
const result = (0, registry_1.validateRegistryConfig)(validConfig);
|
|
233
|
+
(0, vitest_1.expect)(result.name).toBe('my-component');
|
|
234
|
+
(0, vitest_1.expect)(result.version).toBe('1.0.0');
|
|
235
|
+
(0, vitest_1.expect)(result.type).toBe('feature');
|
|
236
|
+
});
|
|
237
|
+
(0, vitest_1.it)('should throw ZodError for invalid input', () => {
|
|
238
|
+
(0, vitest_1.expect)(() => (0, registry_1.validateRegistryConfig)({})).toThrow();
|
|
239
|
+
});
|
|
240
|
+
(0, vitest_1.it)('should throw for null input', () => {
|
|
241
|
+
(0, vitest_1.expect)(() => (0, registry_1.validateRegistryConfig)(null)).toThrow();
|
|
242
|
+
});
|
|
243
|
+
});
|
|
244
|
+
// ─── safeValidateRegistryConfig ───────────────────────────────
|
|
245
|
+
(0, vitest_1.describe)('safeValidateRegistryConfig', () => {
|
|
246
|
+
(0, vitest_1.it)('should return success:true for valid input', () => {
|
|
247
|
+
const result = (0, registry_1.safeValidateRegistryConfig)(validConfig);
|
|
248
|
+
(0, vitest_1.expect)(result.success).toBe(true);
|
|
249
|
+
});
|
|
250
|
+
(0, vitest_1.it)('should return success:false for invalid input', () => {
|
|
251
|
+
const result = (0, registry_1.safeValidateRegistryConfig)({});
|
|
252
|
+
(0, vitest_1.expect)(result.success).toBe(false);
|
|
253
|
+
});
|
|
254
|
+
(0, vitest_1.it)('should not throw for invalid input', () => {
|
|
255
|
+
(0, vitest_1.expect)(() => (0, registry_1.safeValidateRegistryConfig)(null)).not.toThrow();
|
|
256
|
+
});
|
|
257
|
+
});
|
|
258
|
+
// ─── Schema Version ──────────────────────────────────────────
|
|
259
|
+
(0, vitest_1.describe)('schema versioning', () => {
|
|
260
|
+
(0, vitest_1.it)('RegistryConfigSchema should be same as RegistryConfigSchemaV1', () => {
|
|
261
|
+
(0, vitest_1.expect)(registry_1.RegistryConfigSchema).toBe(registry_1.RegistryConfigSchemaV1);
|
|
262
|
+
});
|
|
263
|
+
});
|
|
264
|
+
});
|