aiox-core 5.0.0 → 5.0.2
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/.aiox-core/data/entity-registry.yaml +5297 -1814
- package/.aiox-core/data/registry-update-log.jsonl +2 -0
- package/.aiox-core/development/templates/service-template/README.md.hbs +158 -158
- package/.aiox-core/development/templates/service-template/__tests__/index.test.ts.hbs +237 -237
- package/.aiox-core/development/templates/service-template/client.ts.hbs +403 -403
- package/.aiox-core/development/templates/service-template/errors.ts.hbs +182 -182
- package/.aiox-core/development/templates/service-template/index.ts.hbs +120 -120
- package/.aiox-core/development/templates/service-template/package.json.hbs +87 -87
- package/.aiox-core/development/templates/service-template/types.ts.hbs +145 -145
- package/.aiox-core/development/templates/squad-template/LICENSE +21 -21
- package/.aiox-core/infrastructure/scripts/tool-resolver.js +4 -4
- package/.aiox-core/infrastructure/templates/aiox-sync.yaml.template +182 -182
- package/.aiox-core/infrastructure/templates/coderabbit.yaml.template +279 -279
- package/.aiox-core/infrastructure/templates/github-workflows/ci.yml.template +169 -169
- package/.aiox-core/infrastructure/templates/github-workflows/pr-automation.yml.template +330 -330
- package/.aiox-core/infrastructure/templates/github-workflows/release.yml.template +196 -196
- package/.aiox-core/infrastructure/templates/gitignore/gitignore-aiox-base.tmpl +63 -63
- package/.aiox-core/infrastructure/templates/gitignore/gitignore-brownfield-merge.tmpl +18 -18
- package/.aiox-core/infrastructure/templates/gitignore/gitignore-node.tmpl +85 -85
- package/.aiox-core/infrastructure/templates/gitignore/gitignore-python.tmpl +145 -145
- package/.aiox-core/install-manifest.yaml +58 -58
- package/.aiox-core/local-config.yaml.template +71 -71
- package/.aiox-core/monitor/hooks/lib/__init__.py +1 -1
- package/.aiox-core/monitor/hooks/lib/enrich.py +58 -58
- package/.aiox-core/monitor/hooks/lib/send_event.py +47 -47
- package/.aiox-core/monitor/hooks/notification.py +29 -29
- package/.aiox-core/monitor/hooks/post_tool_use.py +45 -45
- package/.aiox-core/monitor/hooks/pre_compact.py +29 -29
- package/.aiox-core/monitor/hooks/pre_tool_use.py +40 -40
- package/.aiox-core/monitor/hooks/stop.py +29 -29
- package/.aiox-core/monitor/hooks/subagent_stop.py +29 -29
- package/.aiox-core/monitor/hooks/user_prompt_submit.py +38 -38
- package/.aiox-core/product/templates/adr.hbs +125 -125
- package/.aiox-core/product/templates/dbdr.hbs +241 -241
- package/.aiox-core/product/templates/engine/elicitation.js +2 -3
- package/.aiox-core/product/templates/epic.hbs +212 -212
- package/.aiox-core/product/templates/pmdr.hbs +186 -186
- package/.aiox-core/product/templates/prd-v2.0.hbs +216 -216
- package/.aiox-core/product/templates/prd.hbs +201 -201
- package/.aiox-core/product/templates/story.hbs +263 -263
- package/.aiox-core/product/templates/task.hbs +170 -170
- package/.aiox-core/product/templates/tmpl-comment-on-examples.sql +158 -158
- package/.aiox-core/product/templates/tmpl-migration-script.sql +91 -91
- package/.aiox-core/product/templates/tmpl-rls-granular-policies.sql +104 -104
- package/.aiox-core/product/templates/tmpl-rls-kiss-policy.sql +10 -10
- package/.aiox-core/product/templates/tmpl-rls-roles.sql +135 -135
- package/.aiox-core/product/templates/tmpl-rls-simple.sql +77 -77
- package/.aiox-core/product/templates/tmpl-rls-tenant.sql +152 -152
- package/.aiox-core/product/templates/tmpl-rollback-script.sql +77 -77
- package/.aiox-core/product/templates/tmpl-seed-data.sql +140 -140
- package/.aiox-core/product/templates/tmpl-smoke-test.sql +16 -16
- package/.aiox-core/product/templates/tmpl-staging-copy-merge.sql +139 -139
- package/.aiox-core/product/templates/tmpl-stored-proc.sql +140 -140
- package/.aiox-core/product/templates/tmpl-trigger.sql +152 -152
- package/.aiox-core/product/templates/tmpl-view-materialized.sql +133 -133
- package/.aiox-core/product/templates/tmpl-view.sql +177 -177
- package/.aiox-core/scripts/pm.sh +0 -0
- package/.claude/hooks/code-intel-pretool.cjs +107 -0
- package/.claude/hooks/enforce-architecture-first.py +196 -196
- package/.claude/hooks/mind-clone-governance.py +192 -192
- package/.claude/hooks/read-protection.py +151 -151
- package/.claude/hooks/slug-validation.py +176 -176
- package/.claude/hooks/sql-governance.py +182 -182
- package/.claude/hooks/write-path-validation.py +194 -194
- package/LICENSE +33 -33
- package/bin/aiox-graph.js +0 -0
- package/bin/aiox-minimal.js +0 -0
- package/bin/aiox.js +0 -0
- package/docs/guides/aios-workflows/README.md +247 -0
- package/docs/guides/aios-workflows/bob-orchestrator-workflow.md +1536 -0
- package/package.json +1 -1
- package/packages/aiox-install/bin/aiox-install.js +0 -0
- package/packages/aiox-install/bin/edmcp.js +0 -0
- package/packages/aiox-pro-cli/bin/aiox-pro.js +0 -0
- package/packages/installer/src/wizard/pro-setup.js +210 -123
- package/pro/README.md +66 -0
- package/pro/license/degradation.js +220 -0
- package/pro/license/errors.js +450 -0
- package/pro/license/feature-gate.js +354 -0
- package/pro/license/index.js +181 -0
- package/pro/license/license-api.js +679 -0
- package/pro/license/license-cache.js +523 -0
- package/pro/license/license-crypto.js +303 -0
- package/scripts/check-markdown-links.py +352 -352
- package/scripts/dashboard-parallel-dev.sh +0 -0
- package/scripts/dashboard-parallel-phase3.sh +0 -0
- package/scripts/dashboard-parallel-phase4.sh +0 -0
- package/scripts/glue/README.md +355 -0
- package/scripts/glue/compose-agent-prompt.cjs +362 -0
- package/scripts/install-monitor-hooks.sh +0 -0
- package/.aiox-core/lib/build.json +0 -1
|
@@ -1,237 +1,237 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Tests for {{pascalCase serviceName}} service.
|
|
3
|
-
* @module @aiox/{{kebabCase serviceName}}/tests
|
|
4
|
-
* @story {{storyId}}
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import {
|
|
8
|
-
create{{pascalCase serviceName}}Service,
|
|
9
|
-
{{pascalCase serviceName}}Error,
|
|
10
|
-
{{pascalCase serviceName}}ErrorCode,
|
|
11
|
-
} from '../index';
|
|
12
|
-
import type { {{pascalCase serviceName}}Config, {{pascalCase serviceName}}Service } from '../types';
|
|
13
|
-
|
|
14
|
-
describe('{{pascalCase serviceName}}Service', () => {
|
|
15
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
16
|
-
// Test Configuration
|
|
17
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
18
|
-
|
|
19
|
-
const validConfig: {{pascalCase serviceName}}Config = {
|
|
20
|
-
{{#each envVars}}
|
|
21
|
-
{{camelCase this.name}}: 'test-{{kebabCase this.name}}',
|
|
22
|
-
{{/each}}
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
26
|
-
// Factory Function Tests
|
|
27
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
28
|
-
|
|
29
|
-
describe('create{{pascalCase serviceName}}Service', () => {
|
|
30
|
-
it('should create a service instance with valid config', () => {
|
|
31
|
-
const service = create{{pascalCase serviceName}}Service(validConfig);
|
|
32
|
-
|
|
33
|
-
expect(service).toBeDefined();
|
|
34
|
-
expect(typeof service.execute).toBe('function');
|
|
35
|
-
expect(typeof service.getConfig).toBe('function');
|
|
36
|
-
expect(typeof service.healthCheck).toBe('function');
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
it('should throw on null config', () => {
|
|
40
|
-
expect(() => {
|
|
41
|
-
create{{pascalCase serviceName}}Service(null as unknown as {{pascalCase serviceName}}Config);
|
|
42
|
-
}).toThrow({{pascalCase serviceName}}Error);
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
it('should throw on undefined config', () => {
|
|
46
|
-
expect(() => {
|
|
47
|
-
create{{pascalCase serviceName}}Service(undefined as unknown as {{pascalCase serviceName}}Config);
|
|
48
|
-
}).toThrow({{pascalCase serviceName}}Error);
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
{{#each envVars}}
|
|
52
|
-
{{#if this.required}}
|
|
53
|
-
it('should throw when {{this.name}} is missing', () => {
|
|
54
|
-
const configWithoutField = { ...validConfig };
|
|
55
|
-
delete (configWithoutField as Record<string, unknown>).{{camelCase this.name}};
|
|
56
|
-
|
|
57
|
-
expect(() => {
|
|
58
|
-
create{{pascalCase serviceName}}Service(configWithoutField as {{pascalCase serviceName}}Config);
|
|
59
|
-
}).toThrow(expect.objectContaining({
|
|
60
|
-
code: {{pascalCase serviceName}}ErrorCode.CONFIGURATION_ERROR,
|
|
61
|
-
}));
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
{{/if}}
|
|
65
|
-
{{/each}}
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
69
|
-
// Configuration Tests
|
|
70
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
71
|
-
|
|
72
|
-
describe('getConfig', () => {
|
|
73
|
-
let service: {{pascalCase serviceName}}Service;
|
|
74
|
-
|
|
75
|
-
beforeEach(() => {
|
|
76
|
-
service = create{{pascalCase serviceName}}Service(validConfig);
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
it('should return configuration without sensitive values', () => {
|
|
80
|
-
const config = service.getConfig();
|
|
81
|
-
|
|
82
|
-
expect(config).toBeDefined();
|
|
83
|
-
expect(typeof config).toBe('object');
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
it('should not expose sensitive configuration', () => {
|
|
87
|
-
const config = service.getConfig();
|
|
88
|
-
|
|
89
|
-
// Verify sensitive fields are not exposed
|
|
90
|
-
{{#each envVars}}
|
|
91
|
-
{{#if this.sensitive}}
|
|
92
|
-
expect(config.{{camelCase this.name}}).toBeUndefined();
|
|
93
|
-
{{/if}}
|
|
94
|
-
{{/each}}
|
|
95
|
-
});
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
99
|
-
// Service Method Tests
|
|
100
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
101
|
-
|
|
102
|
-
describe('execute', () => {
|
|
103
|
-
let service: {{pascalCase serviceName}}Service;
|
|
104
|
-
|
|
105
|
-
beforeEach(() => {
|
|
106
|
-
service = create{{pascalCase serviceName}}Service(validConfig);
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
it('should throw NOT_IMPLEMENTED for unimplemented execute', async () => {
|
|
110
|
-
await expect(service.execute()).rejects.toThrow(expect.objectContaining({
|
|
111
|
-
code: {{pascalCase serviceName}}ErrorCode.NOT_IMPLEMENTED,
|
|
112
|
-
}));
|
|
113
|
-
});
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
describe('healthCheck', () => {
|
|
117
|
-
let service: {{pascalCase serviceName}}Service;
|
|
118
|
-
|
|
119
|
-
beforeEach(() => {
|
|
120
|
-
service = create{{pascalCase serviceName}}Service(validConfig);
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
it('should return boolean', async () => {
|
|
124
|
-
const result = await service.healthCheck();
|
|
125
|
-
|
|
126
|
-
expect(typeof result).toBe('boolean');
|
|
127
|
-
});
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
131
|
-
// Error Handling Tests
|
|
132
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
133
|
-
|
|
134
|
-
describe('{{pascalCase serviceName}}Error', () => {
|
|
135
|
-
it('should have correct name', () => {
|
|
136
|
-
const error = new {{pascalCase serviceName}}Error('Test error');
|
|
137
|
-
|
|
138
|
-
expect(error.name).toBe('{{pascalCase serviceName}}Error');
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
it('should have default error code', () => {
|
|
142
|
-
const error = new {{pascalCase serviceName}}Error('Test error');
|
|
143
|
-
|
|
144
|
-
expect(error.code).toBe({{pascalCase serviceName}}ErrorCode.UNKNOWN_ERROR);
|
|
145
|
-
});
|
|
146
|
-
|
|
147
|
-
it('should accept custom error code', () => {
|
|
148
|
-
const error = new {{pascalCase serviceName}}Error(
|
|
149
|
-
'Config error',
|
|
150
|
-
{{pascalCase serviceName}}ErrorCode.CONFIGURATION_ERROR
|
|
151
|
-
);
|
|
152
|
-
|
|
153
|
-
expect(error.code).toBe({{pascalCase serviceName}}ErrorCode.CONFIGURATION_ERROR);
|
|
154
|
-
});
|
|
155
|
-
|
|
156
|
-
it('should include error details', () => {
|
|
157
|
-
const details = { field: 'test', reason: 'invalid' };
|
|
158
|
-
const error = new {{pascalCase serviceName}}Error(
|
|
159
|
-
'Validation error',
|
|
160
|
-
{{pascalCase serviceName}}ErrorCode.CONFIGURATION_ERROR,
|
|
161
|
-
{ details }
|
|
162
|
-
);
|
|
163
|
-
|
|
164
|
-
expect(error.details).toEqual(details);
|
|
165
|
-
});
|
|
166
|
-
|
|
167
|
-
it('should preserve cause error', () => {
|
|
168
|
-
const cause = new Error('Original error');
|
|
169
|
-
const error = new {{pascalCase serviceName}}Error(
|
|
170
|
-
'Wrapped error',
|
|
171
|
-
{{pascalCase serviceName}}ErrorCode.NETWORK_ERROR,
|
|
172
|
-
{ cause }
|
|
173
|
-
);
|
|
174
|
-
|
|
175
|
-
expect(error.cause).toBe(cause);
|
|
176
|
-
});
|
|
177
|
-
|
|
178
|
-
it('should serialize to JSON correctly', () => {
|
|
179
|
-
const error = new {{pascalCase serviceName}}Error(
|
|
180
|
-
'Test error',
|
|
181
|
-
{{pascalCase serviceName}}ErrorCode.CONFIGURATION_ERROR,
|
|
182
|
-
{ details: { key: 'value' } }
|
|
183
|
-
);
|
|
184
|
-
|
|
185
|
-
const json = error.toJSON();
|
|
186
|
-
|
|
187
|
-
expect(json.name).toBe('{{pascalCase serviceName}}Error');
|
|
188
|
-
expect(json.code).toBe({{pascalCase serviceName}}ErrorCode.CONFIGURATION_ERROR);
|
|
189
|
-
expect(json.message).toBe('Test error');
|
|
190
|
-
expect(json.details).toEqual({ key: 'value' });
|
|
191
|
-
});
|
|
192
|
-
});
|
|
193
|
-
});
|
|
194
|
-
|
|
195
|
-
{{#if isApiIntegration}}
|
|
196
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
197
|
-
// API Client Tests (API Integrations Only)
|
|
198
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
199
|
-
|
|
200
|
-
describe('{{pascalCase serviceName}}Client', () => {
|
|
201
|
-
// Import client for API integration testing
|
|
202
|
-
const { {{pascalCase serviceName}}Client } = require('../client');
|
|
203
|
-
|
|
204
|
-
const clientConfig: {{pascalCase serviceName}}Config = {
|
|
205
|
-
...validConfig,
|
|
206
|
-
baseUrl: 'https://api.example.com',
|
|
207
|
-
timeout: 5000,
|
|
208
|
-
maxRetries: 2,
|
|
209
|
-
debug: false,
|
|
210
|
-
};
|
|
211
|
-
|
|
212
|
-
describe('constructor', () => {
|
|
213
|
-
it('should create client with config', () => {
|
|
214
|
-
const client = new {{pascalCase serviceName}}Client(clientConfig);
|
|
215
|
-
|
|
216
|
-
expect(client).toBeDefined();
|
|
217
|
-
});
|
|
218
|
-
|
|
219
|
-
it('should use default values for optional config', () => {
|
|
220
|
-
const client = new {{pascalCase serviceName}}Client(validConfig);
|
|
221
|
-
|
|
222
|
-
expect(client).toBeDefined();
|
|
223
|
-
});
|
|
224
|
-
});
|
|
225
|
-
|
|
226
|
-
describe('getRateLimit', () => {
|
|
227
|
-
it('should return null initially', () => {
|
|
228
|
-
const client = new {{pascalCase serviceName}}Client(clientConfig);
|
|
229
|
-
|
|
230
|
-
expect(client.getRateLimit()).toBeNull();
|
|
231
|
-
});
|
|
232
|
-
});
|
|
233
|
-
|
|
234
|
-
// Note: Additional client tests require mocking fetch/network
|
|
235
|
-
// These should be added based on specific API requirements
|
|
236
|
-
});
|
|
237
|
-
{{/if}}
|
|
1
|
+
/**
|
|
2
|
+
* Tests for {{pascalCase serviceName}} service.
|
|
3
|
+
* @module @aiox/{{kebabCase serviceName}}/tests
|
|
4
|
+
* @story {{storyId}}
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import {
|
|
8
|
+
create{{pascalCase serviceName}}Service,
|
|
9
|
+
{{pascalCase serviceName}}Error,
|
|
10
|
+
{{pascalCase serviceName}}ErrorCode,
|
|
11
|
+
} from '../index';
|
|
12
|
+
import type { {{pascalCase serviceName}}Config, {{pascalCase serviceName}}Service } from '../types';
|
|
13
|
+
|
|
14
|
+
describe('{{pascalCase serviceName}}Service', () => {
|
|
15
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
16
|
+
// Test Configuration
|
|
17
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
18
|
+
|
|
19
|
+
const validConfig: {{pascalCase serviceName}}Config = {
|
|
20
|
+
{{#each envVars}}
|
|
21
|
+
{{camelCase this.name}}: 'test-{{kebabCase this.name}}',
|
|
22
|
+
{{/each}}
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
26
|
+
// Factory Function Tests
|
|
27
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
28
|
+
|
|
29
|
+
describe('create{{pascalCase serviceName}}Service', () => {
|
|
30
|
+
it('should create a service instance with valid config', () => {
|
|
31
|
+
const service = create{{pascalCase serviceName}}Service(validConfig);
|
|
32
|
+
|
|
33
|
+
expect(service).toBeDefined();
|
|
34
|
+
expect(typeof service.execute).toBe('function');
|
|
35
|
+
expect(typeof service.getConfig).toBe('function');
|
|
36
|
+
expect(typeof service.healthCheck).toBe('function');
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it('should throw on null config', () => {
|
|
40
|
+
expect(() => {
|
|
41
|
+
create{{pascalCase serviceName}}Service(null as unknown as {{pascalCase serviceName}}Config);
|
|
42
|
+
}).toThrow({{pascalCase serviceName}}Error);
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it('should throw on undefined config', () => {
|
|
46
|
+
expect(() => {
|
|
47
|
+
create{{pascalCase serviceName}}Service(undefined as unknown as {{pascalCase serviceName}}Config);
|
|
48
|
+
}).toThrow({{pascalCase serviceName}}Error);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
{{#each envVars}}
|
|
52
|
+
{{#if this.required}}
|
|
53
|
+
it('should throw when {{this.name}} is missing', () => {
|
|
54
|
+
const configWithoutField = { ...validConfig };
|
|
55
|
+
delete (configWithoutField as Record<string, unknown>).{{camelCase this.name}};
|
|
56
|
+
|
|
57
|
+
expect(() => {
|
|
58
|
+
create{{pascalCase serviceName}}Service(configWithoutField as {{pascalCase serviceName}}Config);
|
|
59
|
+
}).toThrow(expect.objectContaining({
|
|
60
|
+
code: {{pascalCase serviceName}}ErrorCode.CONFIGURATION_ERROR,
|
|
61
|
+
}));
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
{{/if}}
|
|
65
|
+
{{/each}}
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
69
|
+
// Configuration Tests
|
|
70
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
71
|
+
|
|
72
|
+
describe('getConfig', () => {
|
|
73
|
+
let service: {{pascalCase serviceName}}Service;
|
|
74
|
+
|
|
75
|
+
beforeEach(() => {
|
|
76
|
+
service = create{{pascalCase serviceName}}Service(validConfig);
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
it('should return configuration without sensitive values', () => {
|
|
80
|
+
const config = service.getConfig();
|
|
81
|
+
|
|
82
|
+
expect(config).toBeDefined();
|
|
83
|
+
expect(typeof config).toBe('object');
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
it('should not expose sensitive configuration', () => {
|
|
87
|
+
const config = service.getConfig();
|
|
88
|
+
|
|
89
|
+
// Verify sensitive fields are not exposed
|
|
90
|
+
{{#each envVars}}
|
|
91
|
+
{{#if this.sensitive}}
|
|
92
|
+
expect(config.{{camelCase this.name}}).toBeUndefined();
|
|
93
|
+
{{/if}}
|
|
94
|
+
{{/each}}
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
99
|
+
// Service Method Tests
|
|
100
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
101
|
+
|
|
102
|
+
describe('execute', () => {
|
|
103
|
+
let service: {{pascalCase serviceName}}Service;
|
|
104
|
+
|
|
105
|
+
beforeEach(() => {
|
|
106
|
+
service = create{{pascalCase serviceName}}Service(validConfig);
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
it('should throw NOT_IMPLEMENTED for unimplemented execute', async () => {
|
|
110
|
+
await expect(service.execute()).rejects.toThrow(expect.objectContaining({
|
|
111
|
+
code: {{pascalCase serviceName}}ErrorCode.NOT_IMPLEMENTED,
|
|
112
|
+
}));
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
describe('healthCheck', () => {
|
|
117
|
+
let service: {{pascalCase serviceName}}Service;
|
|
118
|
+
|
|
119
|
+
beforeEach(() => {
|
|
120
|
+
service = create{{pascalCase serviceName}}Service(validConfig);
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
it('should return boolean', async () => {
|
|
124
|
+
const result = await service.healthCheck();
|
|
125
|
+
|
|
126
|
+
expect(typeof result).toBe('boolean');
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
131
|
+
// Error Handling Tests
|
|
132
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
133
|
+
|
|
134
|
+
describe('{{pascalCase serviceName}}Error', () => {
|
|
135
|
+
it('should have correct name', () => {
|
|
136
|
+
const error = new {{pascalCase serviceName}}Error('Test error');
|
|
137
|
+
|
|
138
|
+
expect(error.name).toBe('{{pascalCase serviceName}}Error');
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
it('should have default error code', () => {
|
|
142
|
+
const error = new {{pascalCase serviceName}}Error('Test error');
|
|
143
|
+
|
|
144
|
+
expect(error.code).toBe({{pascalCase serviceName}}ErrorCode.UNKNOWN_ERROR);
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
it('should accept custom error code', () => {
|
|
148
|
+
const error = new {{pascalCase serviceName}}Error(
|
|
149
|
+
'Config error',
|
|
150
|
+
{{pascalCase serviceName}}ErrorCode.CONFIGURATION_ERROR
|
|
151
|
+
);
|
|
152
|
+
|
|
153
|
+
expect(error.code).toBe({{pascalCase serviceName}}ErrorCode.CONFIGURATION_ERROR);
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
it('should include error details', () => {
|
|
157
|
+
const details = { field: 'test', reason: 'invalid' };
|
|
158
|
+
const error = new {{pascalCase serviceName}}Error(
|
|
159
|
+
'Validation error',
|
|
160
|
+
{{pascalCase serviceName}}ErrorCode.CONFIGURATION_ERROR,
|
|
161
|
+
{ details }
|
|
162
|
+
);
|
|
163
|
+
|
|
164
|
+
expect(error.details).toEqual(details);
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
it('should preserve cause error', () => {
|
|
168
|
+
const cause = new Error('Original error');
|
|
169
|
+
const error = new {{pascalCase serviceName}}Error(
|
|
170
|
+
'Wrapped error',
|
|
171
|
+
{{pascalCase serviceName}}ErrorCode.NETWORK_ERROR,
|
|
172
|
+
{ cause }
|
|
173
|
+
);
|
|
174
|
+
|
|
175
|
+
expect(error.cause).toBe(cause);
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
it('should serialize to JSON correctly', () => {
|
|
179
|
+
const error = new {{pascalCase serviceName}}Error(
|
|
180
|
+
'Test error',
|
|
181
|
+
{{pascalCase serviceName}}ErrorCode.CONFIGURATION_ERROR,
|
|
182
|
+
{ details: { key: 'value' } }
|
|
183
|
+
);
|
|
184
|
+
|
|
185
|
+
const json = error.toJSON();
|
|
186
|
+
|
|
187
|
+
expect(json.name).toBe('{{pascalCase serviceName}}Error');
|
|
188
|
+
expect(json.code).toBe({{pascalCase serviceName}}ErrorCode.CONFIGURATION_ERROR);
|
|
189
|
+
expect(json.message).toBe('Test error');
|
|
190
|
+
expect(json.details).toEqual({ key: 'value' });
|
|
191
|
+
});
|
|
192
|
+
});
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
{{#if isApiIntegration}}
|
|
196
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
197
|
+
// API Client Tests (API Integrations Only)
|
|
198
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
199
|
+
|
|
200
|
+
describe('{{pascalCase serviceName}}Client', () => {
|
|
201
|
+
// Import client for API integration testing
|
|
202
|
+
const { {{pascalCase serviceName}}Client } = require('../client');
|
|
203
|
+
|
|
204
|
+
const clientConfig: {{pascalCase serviceName}}Config = {
|
|
205
|
+
...validConfig,
|
|
206
|
+
baseUrl: 'https://api.example.com',
|
|
207
|
+
timeout: 5000,
|
|
208
|
+
maxRetries: 2,
|
|
209
|
+
debug: false,
|
|
210
|
+
};
|
|
211
|
+
|
|
212
|
+
describe('constructor', () => {
|
|
213
|
+
it('should create client with config', () => {
|
|
214
|
+
const client = new {{pascalCase serviceName}}Client(clientConfig);
|
|
215
|
+
|
|
216
|
+
expect(client).toBeDefined();
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
it('should use default values for optional config', () => {
|
|
220
|
+
const client = new {{pascalCase serviceName}}Client(validConfig);
|
|
221
|
+
|
|
222
|
+
expect(client).toBeDefined();
|
|
223
|
+
});
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
describe('getRateLimit', () => {
|
|
227
|
+
it('should return null initially', () => {
|
|
228
|
+
const client = new {{pascalCase serviceName}}Client(clientConfig);
|
|
229
|
+
|
|
230
|
+
expect(client.getRateLimit()).toBeNull();
|
|
231
|
+
});
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
// Note: Additional client tests require mocking fetch/network
|
|
235
|
+
// These should be added based on specific API requirements
|
|
236
|
+
});
|
|
237
|
+
{{/if}}
|