@wilnertech/halopsa-mcp-server 1.0.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.
Files changed (76) hide show
  1. package/.env.example +19 -0
  2. package/LICENSE +21 -0
  3. package/README.md +270 -0
  4. package/dist/api/client.d.ts +85 -0
  5. package/dist/api/client.d.ts.map +1 -0
  6. package/dist/api/client.js +297 -0
  7. package/dist/api/client.js.map +1 -0
  8. package/dist/api/errors.d.ts +60 -0
  9. package/dist/api/errors.d.ts.map +1 -0
  10. package/dist/api/errors.js +188 -0
  11. package/dist/api/errors.js.map +1 -0
  12. package/dist/cache/memory-cache.d.ts +89 -0
  13. package/dist/cache/memory-cache.d.ts.map +1 -0
  14. package/dist/cache/memory-cache.js +175 -0
  15. package/dist/cache/memory-cache.js.map +1 -0
  16. package/dist/cache/prewarm.d.ts +12 -0
  17. package/dist/cache/prewarm.d.ts.map +1 -0
  18. package/dist/cache/prewarm.js +55 -0
  19. package/dist/cache/prewarm.js.map +1 -0
  20. package/dist/index.d.ts +12 -0
  21. package/dist/index.d.ts.map +1 -0
  22. package/dist/index.js +141 -0
  23. package/dist/index.js.map +1 -0
  24. package/dist/schemas/common.d.ts +212 -0
  25. package/dist/schemas/common.d.ts.map +1 -0
  26. package/dist/schemas/common.js +127 -0
  27. package/dist/schemas/common.js.map +1 -0
  28. package/dist/tools/assets.d.ts +482 -0
  29. package/dist/tools/assets.d.ts.map +1 -0
  30. package/dist/tools/assets.js +732 -0
  31. package/dist/tools/assets.js.map +1 -0
  32. package/dist/tools/batch-operations.d.ts +125 -0
  33. package/dist/tools/batch-operations.d.ts.map +1 -0
  34. package/dist/tools/batch-operations.js +207 -0
  35. package/dist/tools/batch-operations.js.map +1 -0
  36. package/dist/tools/clients.d.ts +145 -0
  37. package/dist/tools/clients.d.ts.map +1 -0
  38. package/dist/tools/clients.js +148 -0
  39. package/dist/tools/clients.js.map +1 -0
  40. package/dist/tools/reference-data.d.ts +118 -0
  41. package/dist/tools/reference-data.d.ts.map +1 -0
  42. package/dist/tools/reference-data.js +103 -0
  43. package/dist/tools/reference-data.js.map +1 -0
  44. package/dist/tools/registrations.d.ts +7 -0
  45. package/dist/tools/registrations.d.ts.map +1 -0
  46. package/dist/tools/registrations.js +61 -0
  47. package/dist/tools/registrations.js.map +1 -0
  48. package/dist/tools/registry.d.ts +67 -0
  49. package/dist/tools/registry.d.ts.map +1 -0
  50. package/dist/tools/registry.js +71 -0
  51. package/dist/tools/registry.js.map +1 -0
  52. package/dist/tools/sites.d.ts +188 -0
  53. package/dist/tools/sites.d.ts.map +1 -0
  54. package/dist/tools/sites.js +258 -0
  55. package/dist/tools/sites.js.map +1 -0
  56. package/dist/tools/users.d.ts +317 -0
  57. package/dist/tools/users.d.ts.map +1 -0
  58. package/dist/tools/users.js +489 -0
  59. package/dist/tools/users.js.map +1 -0
  60. package/dist/types/halopsa.d.ts +212 -0
  61. package/dist/types/halopsa.d.ts.map +1 -0
  62. package/dist/types/halopsa.js +8 -0
  63. package/dist/types/halopsa.js.map +1 -0
  64. package/dist/utils/formatter.d.ts +18 -0
  65. package/dist/utils/formatter.d.ts.map +1 -0
  66. package/dist/utils/formatter.js +178 -0
  67. package/dist/utils/formatter.js.map +1 -0
  68. package/dist/utils/similarity.d.ts +25 -0
  69. package/dist/utils/similarity.d.ts.map +1 -0
  70. package/dist/utils/similarity.js +90 -0
  71. package/dist/utils/similarity.js.map +1 -0
  72. package/dist/utils/zod-to-schema.d.ts +29 -0
  73. package/dist/utils/zod-to-schema.d.ts.map +1 -0
  74. package/dist/utils/zod-to-schema.js +182 -0
  75. package/dist/utils/zod-to-schema.js.map +1 -0
  76. package/package.json +61 -0
package/dist/index.js ADDED
@@ -0,0 +1,141 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * HaloPSA MCP Server v1.0
4
+ * Provides direct API access to HaloPSA for Claude Code with token optimization
5
+ *
6
+ * CRITICAL: HaloPSA is WilnerTech's billing backbone
7
+ * - Asset/user counts determine client charges
8
+ * - Accuracy is essential for revenue protection
9
+ * - Deduplication prevents billing errors
10
+ */
11
+ import { Server } from '@modelcontextprotocol/sdk/server/index.js';
12
+ import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
13
+ import { CallToolRequestSchema, ListToolsRequestSchema, InitializeRequestSchema, } from '@modelcontextprotocol/sdk/types.js';
14
+ import { HaloPSAAPIClient } from './api/client.js';
15
+ import { globalCache } from './cache/memory-cache.js';
16
+ import { ToolRegistry } from './tools/registry.js';
17
+ import { registerAllTools } from './tools/registrations.js';
18
+ import { prewarmCache } from './cache/prewarm.js';
19
+ // =============================================================================
20
+ // Environment Variable Validation
21
+ // =============================================================================
22
+ const HALOPSA_CLIENT_ID = process.env.HALOPSA_CLIENT_ID;
23
+ const HALOPSA_CLIENT_SECRET = process.env.HALOPSA_CLIENT_SECRET;
24
+ const HALOPSA_BASE_URL = process.env.HALOPSA_BASE_URL || 'https://support.wilnertech.com';
25
+ if (!HALOPSA_CLIENT_ID) {
26
+ console.error('Error: HALOPSA_CLIENT_ID environment variable is required');
27
+ process.exit(1);
28
+ }
29
+ if (!HALOPSA_CLIENT_SECRET) {
30
+ console.error('Error: HALOPSA_CLIENT_SECRET environment variable is required');
31
+ process.exit(1);
32
+ }
33
+ // =============================================================================
34
+ // Initialize API Client + Tool Registry
35
+ // =============================================================================
36
+ const client = new HaloPSAAPIClient({
37
+ clientId: HALOPSA_CLIENT_ID,
38
+ clientSecret: HALOPSA_CLIENT_SECRET,
39
+ baseUrl: HALOPSA_BASE_URL,
40
+ });
41
+ const registry = new ToolRegistry();
42
+ registerAllTools(registry);
43
+ // =============================================================================
44
+ // Create MCP Server
45
+ // =============================================================================
46
+ const server = new Server({
47
+ name: 'halopsa-mcp-server',
48
+ version: '1.0.0',
49
+ }, {
50
+ capabilities: {
51
+ tools: {},
52
+ },
53
+ });
54
+ // =============================================================================
55
+ // Register Initialization Handler
56
+ // =============================================================================
57
+ server.setRequestHandler(InitializeRequestSchema, async () => {
58
+ return {
59
+ protocolVersion: '2024-11-05',
60
+ capabilities: {
61
+ tools: {},
62
+ },
63
+ serverInfo: {
64
+ name: 'halopsa-mcp-server',
65
+ version: '1.0.0',
66
+ },
67
+ };
68
+ });
69
+ // =============================================================================
70
+ // Register Tool List Handler
71
+ // =============================================================================
72
+ server.setRequestHandler(ListToolsRequestSchema, async () => {
73
+ return { tools: registry.getToolSchemas() };
74
+ });
75
+ // =============================================================================
76
+ // Register Tool Execution Handler
77
+ // =============================================================================
78
+ server.setRequestHandler(CallToolRequestSchema, async (request) => {
79
+ const { name, arguments: args } = request.params;
80
+ try {
81
+ const result = await registry.dispatch(client, name, (args ?? {}));
82
+ return {
83
+ content: [
84
+ {
85
+ type: 'text',
86
+ text: result,
87
+ },
88
+ ],
89
+ };
90
+ }
91
+ catch (error) {
92
+ if (error instanceof Error) {
93
+ return {
94
+ content: [
95
+ {
96
+ type: 'text',
97
+ text: `Error executing tool ${name}: ${error.message}`,
98
+ },
99
+ ],
100
+ isError: true,
101
+ };
102
+ }
103
+ return {
104
+ content: [
105
+ {
106
+ type: 'text',
107
+ text: `Unknown error executing tool ${name}`,
108
+ },
109
+ ],
110
+ isError: true,
111
+ };
112
+ }
113
+ });
114
+ // =============================================================================
115
+ // Graceful Shutdown Handlers
116
+ // =============================================================================
117
+ process.on('SIGINT', () => {
118
+ globalCache.stopCleanupTimer();
119
+ process.exit(0);
120
+ });
121
+ process.on('SIGTERM', () => {
122
+ globalCache.stopCleanupTimer();
123
+ process.exit(0);
124
+ });
125
+ // =============================================================================
126
+ // Start Server
127
+ // =============================================================================
128
+ async function main() {
129
+ const transport = new StdioServerTransport();
130
+ await server.connect(transport);
131
+ // Cache prewarm — fire-and-forget (don't await, don't block server startup)
132
+ prewarmCache(client).catch((error) => {
133
+ console.error('Cache prewarm error:', error);
134
+ });
135
+ console.error(`HaloPSA MCP Server v1.0 running on stdio (${registry.size} tools registered)`);
136
+ }
137
+ main().catch((error) => {
138
+ console.error('Fatal error in main():', error);
139
+ process.exit(1);
140
+ });
141
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA;;;;;;;;GAQG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EACL,qBAAqB,EACrB,sBAAsB,EACtB,uBAAuB,GACxB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,gFAAgF;AAChF,kCAAkC;AAClC,gFAAgF;AAEhF,MAAM,iBAAiB,GAAG,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC;AACxD,MAAM,qBAAqB,GAAG,OAAO,CAAC,GAAG,CAAC,qBAAqB,CAAC;AAChE,MAAM,gBAAgB,GAAG,OAAO,CAAC,GAAG,CAAC,gBAAgB,IAAI,gCAAgC,CAAC;AAE1F,IAAI,CAAC,iBAAiB,EAAE,CAAC;IACvB,OAAO,CAAC,KAAK,CAAC,2DAA2D,CAAC,CAAC;IAC3E,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AAED,IAAI,CAAC,qBAAqB,EAAE,CAAC;IAC3B,OAAO,CAAC,KAAK,CAAC,+DAA+D,CAAC,CAAC;IAC/E,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AAED,gFAAgF;AAChF,wCAAwC;AACxC,gFAAgF;AAEhF,MAAM,MAAM,GAAG,I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AE;QACnC,OAAO,CAAC,KAAK,CAAC,sBAAsB,EAAE,KAAK,CAAC,CAAC;IAC/C,CAAC,CAAC,CAAC;IAEH,OAAO,CAAC,KAAK,CAAC,6CAA6C,QAAQ,CAAC,IAAI,oBAAoB,CAAC,CAAC;AAChG,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACrB,OAAO,CAAC,KAAK,CAAC,wBAAwB,EAAE,KAAK,CAAC,CAAC;IAC/C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
@@ -0,0 +1,212 @@
1
+ /**
2
+ * Common Zod schemas shared across HaloPSA MCP Server tools
3
+ * Centralizes reusable validation schemas for consistency and maintainability
4
+ */
5
+ import { z } from 'zod';
6
+ /**
7
+ * Format options schema for token optimization
8
+ * Used by all tools that return formatted responses
9
+ */
10
+ export declare const FormatOptionsSchema: z.ZodOptional<z.ZodObject<{
11
+ format: z.ZodOptional<z.ZodEnum<["compact", "standard", "detailed"]>>;
12
+ fields: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
13
+ omit_empty: z.ZodOptional<z.ZodBoolean>;
14
+ }, "strip", z.ZodTypeAny, {
15
+ format?: "compact" | "standard" | "detailed" | undefined;
16
+ fields?: string[] | undefined;
17
+ omit_empty?: boolean | undefined;
18
+ }, {
19
+ format?: "compact" | "standard" | "detailed" | undefined;
20
+ fields?: string[] | undefined;
21
+ omit_empty?: boolean | undefined;
22
+ }>>;
23
+ /**
24
+ * Type alias for format options
25
+ */
26
+ export type FormatOptionsInput = z.infer<typeof FormatOptionsSchema>;
27
+ /**
28
+ * Pagination schema for list operations
29
+ */
30
+ export declare const PaginationSchema: z.ZodObject<{
31
+ count: z.ZodOptional<z.ZodNumber>;
32
+ page_no: z.ZodOptional<z.ZodNumber>;
33
+ }, "strip", z.ZodTypeAny, {
34
+ count?: number | undefined;
35
+ page_no?: number | undefined;
36
+ }, {
37
+ count?: number | undefined;
38
+ page_no?: number | undefined;
39
+ }>;
40
+ /**
41
+ * Type alias for pagination options
42
+ */
43
+ export type PaginationInput = z.infer<typeof PaginationSchema>;
44
+ /**
45
+ * Confidence score result schema for deduplication operations
46
+ */
47
+ export declare const ConfidenceResultSchema: z.ZodObject<{
48
+ match: z.ZodNullable<z.ZodAny>;
49
+ confidence: z.ZodNumber;
50
+ matchField: z.ZodString;
51
+ action: z.ZodEnum<["Update", "CreateNew", "ManualReview"]>;
52
+ warning: z.ZodOptional<z.ZodString>;
53
+ matches: z.ZodOptional<z.ZodArray<z.ZodAny, "many">>;
54
+ }, "strip", z.ZodTypeAny, {
55
+ confidence: number;
56
+ matchField: string;
57
+ action: "Update" | "CreateNew" | "ManualReview";
58
+ match?: any;
59
+ warning?: string | undefined;
60
+ matches?: any[] | undefined;
61
+ }, {
62
+ confidence: number;
63
+ matchField: string;
64
+ action: "Update" | "CreateNew" | "ManualReview";
65
+ match?: any;
66
+ warning?: string | undefined;
67
+ matches?: any[] | undefined;
68
+ }>;
69
+ /**
70
+ * Type alias for confidence result
71
+ */
72
+ export type ConfidenceResult = z.infer<typeof ConfidenceResultSchema>;
73
+ /**
74
+ * Duplicate group schema for scan results
75
+ */
76
+ export declare const DuplicateGroupSchema: z.ZodObject<{
77
+ type: z.ZodEnum<["asset", "user", "site"]>;
78
+ matchField: z.ZodString;
79
+ matchValue: z.ZodString;
80
+ confidence: z.ZodEnum<["High", "Medium"]>;
81
+ entity_count: z.ZodNumber;
82
+ entities: z.ZodArray<z.ZodObject<{
83
+ id: z.ZodNumber;
84
+ name: z.ZodString;
85
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
86
+ id: z.ZodNumber;
87
+ name: z.ZodString;
88
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
89
+ id: z.ZodNumber;
90
+ name: z.ZodString;
91
+ }, z.ZodTypeAny, "passthrough">>, "many">;
92
+ }, "strip", z.ZodTypeAny, {
93
+ type: "asset" | "user" | "site";
94
+ confidence: "High" | "Medium";
95
+ matchField: string;
96
+ matchValue: string;
97
+ entity_count: number;
98
+ entities: z.objectOutputType<{
99
+ id: z.ZodNumber;
100
+ name: z.ZodString;
101
+ }, z.ZodTypeAny, "passthrough">[];
102
+ }, {
103
+ type: "asset" | "user" | "site";
104
+ confidence: "High" | "Medium";
105
+ matchField: string;
106
+ matchValue: string;
107
+ entity_count: number;
108
+ entities: z.objectInputType<{
109
+ id: z.ZodNumber;
110
+ name: z.ZodString;
111
+ }, z.ZodTypeAny, "passthrough">[];
112
+ }>;
113
+ /**
114
+ * Type alias for duplicate group
115
+ */
116
+ export type DuplicateGroup = z.infer<typeof DuplicateGroupSchema>;
117
+ /**
118
+ * Asset custom field schema
119
+ */
120
+ export declare const AssetFieldSchema: z.ZodObject<{
121
+ id: z.ZodNumber;
122
+ name: z.ZodString;
123
+ value: z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>;
124
+ }, "strip", z.ZodTypeAny, {
125
+ value: string | number | boolean | null;
126
+ name: string;
127
+ id: number;
128
+ }, {
129
+ value: string | number | boolean | null;
130
+ name: string;
131
+ id: number;
132
+ }>;
133
+ /**
134
+ * Type alias for asset field
135
+ */
136
+ export type AssetField = z.infer<typeof AssetFieldSchema>;
137
+ /**
138
+ * User custom field schema
139
+ */
140
+ export declare const UserCustomFieldSchema: z.ZodObject<{
141
+ id: z.ZodNumber;
142
+ name: z.ZodString;
143
+ value: z.ZodString;
144
+ }, "strip", z.ZodTypeAny, {
145
+ value: string;
146
+ name: string;
147
+ id: number;
148
+ }, {
149
+ value: string;
150
+ name: string;
151
+ id: number;
152
+ }>;
153
+ /**
154
+ * Type alias for user custom field
155
+ */
156
+ export type UserCustomField = z.infer<typeof UserCustomFieldSchema>;
157
+ /**
158
+ * Address schema for sites
159
+ */
160
+ export declare const AddressSchema: z.ZodObject<{
161
+ addressline1: z.ZodOptional<z.ZodString>;
162
+ addressline2: z.ZodOptional<z.ZodString>;
163
+ city: z.ZodOptional<z.ZodString>;
164
+ state: z.ZodOptional<z.ZodString>;
165
+ postalcode: z.ZodOptional<z.ZodString>;
166
+ country: z.ZodOptional<z.ZodString>;
167
+ }, "strip", z.ZodTypeAny, {
168
+ addressline1?: string | undefined;
169
+ addressline2?: string | undefined;
170
+ city?: string | undefined;
171
+ state?: string | undefined;
172
+ postalcode?: string | undefined;
173
+ country?: string | undefined;
174
+ }, {
175
+ addressline1?: string | undefined;
176
+ addressline2?: string | undefined;
177
+ city?: string | undefined;
178
+ state?: string | undefined;
179
+ postalcode?: string | undefined;
180
+ country?: string | undefined;
181
+ }>;
182
+ /**
183
+ * Type alias for address
184
+ */
185
+ export type Address = z.infer<typeof AddressSchema>;
186
+ /**
187
+ * Status ID constants for assets
188
+ * CRITICAL: status_id=1 (Active) determines billing eligibility
189
+ */
190
+ export declare const AssetStatusId: {
191
+ readonly Active: 1;
192
+ readonly Inactive: 2;
193
+ readonly Retired: 3;
194
+ readonly Deleted: 4;
195
+ };
196
+ /**
197
+ * Confidence thresholds for deduplication
198
+ * Based on WilnerTech deduplication requirements
199
+ */
200
+ export declare const ConfidenceThresholds: {
201
+ readonly ASSET_SERIAL_EXACT: 1;
202
+ readonly ASSET_HOSTNAME_ONLY: 0.85;
203
+ readonly USER_EMAIL_EXACT: 1;
204
+ readonly USER_UPN_MATCH: 0.95;
205
+ readonly USER_USERNAME_ONLY: 0.7;
206
+ readonly SITE_NAME_EXACT: 1;
207
+ readonly SITE_FUZZY_WITH_ADDRESS: 0.95;
208
+ readonly SITE_FUZZY_ONLY: 0.85;
209
+ readonly AUTO_UPDATE: 0.95;
210
+ readonly MANUAL_REVIEW: 0.7;
211
+ };
212
+ //# sourceMappingURL=common.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../src/schemas/common.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;GAG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oBAAoB;;;;;;;;;;;CAkBvB,CAAC"}
@@ -0,0 +1,127 @@
1
+ /**
2
+ * Common Zod schemas shared across HaloPSA MCP Server tools
3
+ * Centralizes reusable validation schemas for consistency and maintainability
4
+ */
5
+ import { z } from 'zod';
6
+ /**
7
+ * Format options schema for token optimization
8
+ * Used by all tools that return formatted responses
9
+ */
10
+ export const FormatOptionsSchema = z.object({
11
+ format: z.enum(['compact', 'standard', 'detailed']).optional()
12
+ .describe('Output format: compact (minimal), standard (default), detailed (pretty-printed)'),
13
+ fields: z.array(z.string()).optional()
14
+ .describe('Specific fields to include in response'),
15
+ omit_empty: z.boolean().optional()
16
+ .describe('Remove null/empty fields from response'),
17
+ }).optional();
18
+ /**
19
+ * Pagination schema for list operations
20
+ */
21
+ export const PaginationSchema = z.object({
22
+ count: z.number().int().min(1).max(100).optional()
23
+ .describe('Number of results per page (max 100, default 50)'),
24
+ page_no: z.number().int().min(1).optional()
25
+ .describe('Page number (1-indexed, default 1)'),
26
+ });
27
+ /**
28
+ * Confidence score result schema for deduplication operations
29
+ */
30
+ export const ConfidenceResultSchema = z.object({
31
+ match: z.any().nullable()
32
+ .describe('Matched entity or null if no match'),
33
+ confidence: z.number().min(0).max(1)
34
+ .describe('Confidence score (0.0 to 1.0)'),
35
+ matchField: z.string()
36
+ .describe('Field used for matching'),
37
+ action: z.enum(['Update', 'CreateNew', 'ManualReview'])
38
+ .describe('Recommended action based on confidence'),
39
+ warning: z.string().optional()
40
+ .describe('Warning message if applicable'),
41
+ matches: z.array(z.any()).optional()
42
+ .describe('Multiple matches if duplicates detected'),
43
+ });
44
+ /**
45
+ * Duplicate group schema for scan results
46
+ */
47
+ export const DuplicateGroupSchema = z.object({
48
+ type: z.enum(['asset', 'user', 'site'])
49
+ .describe('Entity type'),
50
+ matchField: z.string()
51
+ .describe('Field used for matching'),
52
+ matchValue: z.string()
53
+ .describe('Value that matched'),
54
+ confidence: z.enum(['High', 'Medium'])
55
+ .describe('Confidence level'),
56
+ entity_count: z.number().int()
57
+ .describe('Number of duplicate entities'),
58
+ entities: z.array(z.object({
59
+ id: z.number(),
60
+ name: z.string(),
61
+ }).passthrough())
62
+ .describe('Array of duplicate entities'),
63
+ });
64
+ /**
65
+ * Asset custom field schema
66
+ */
67
+ export const AssetFieldSchema = z.object({
68
+ id: z.number().int()
69
+ .describe('Custom field ID'),
70
+ name: z.string()
71
+ .describe('Custom field name'),
72
+ value: z.union([z.string(), z.number(), z.boolean(), z.null()])
73
+ .describe('Custom field value'),
74
+ });
75
+ /**
76
+ * User custom field schema
77
+ */
78
+ export const UserCustomFieldSchema = z.object({
79
+ id: z.number().int()
80
+ .describe('Custom field ID'),
81
+ name: z.string()
82
+ .describe('Custom field name'),
83
+ value: z.string()
84
+ .describe('Custom field value'),
85
+ });
86
+ /**
87
+ * Address schema for sites
88
+ */
89
+ export const AddressSchema = z.object({
90
+ addressline1: z.string().optional(),
91
+ addressline2: z.string().optional(),
92
+ city: z.string().optional(),
93
+ state: z.string().optional(),
94
+ postalcode: z.string().optional(),
95
+ country: z.string().optional(),
96
+ });
97
+ /**
98
+ * Status ID constants for assets
99
+ * CRITICAL: status_id=1 (Active) determines billing eligibility
100
+ */
101
+ export const AssetStatusId = {
102
+ Active: 1, // Counts for billing
103
+ Inactive: 2, // Does NOT count for billing
104
+ Retired: 3, // Does NOT count for billing
105
+ Deleted: 4, // Does NOT count for billing (soft delete)
106
+ };
107
+ /**
108
+ * Confidence thresholds for deduplication
109
+ * Based on WilnerTech deduplication requirements
110
+ */
111
+ export const ConfidenceThresholds = {
112
+ // Assets
113
+ ASSET_SERIAL_EXACT: 1.0, // 100% - exact serial match
114
+ ASSET_HOSTNAME_ONLY: 0.85, // 85% - hostname match, serial mismatch
115
+ // Users
116
+ USER_EMAIL_EXACT: 1.0, // 100% - exact email match
117
+ USER_UPN_MATCH: 0.95, // 95% - UPN match (Entra source of truth)
118
+ USER_USERNAME_ONLY: 0.70, // 70% - username match only
119
+ // Sites
120
+ SITE_NAME_EXACT: 1.0, // 100% - exact name match
121
+ SITE_FUZZY_WITH_ADDRESS: 0.95, // 95% - fuzzy name + address validation
122
+ SITE_FUZZY_ONLY: 0.85, // 85% - fuzzy name only
123
+ // Action thresholds
124
+ AUTO_UPDATE: 0.95, // >= 95% confidence -> auto-update
125
+ MANUAL_REVIEW: 0.70, // 70-94% confidence -> manual review
126
+ };
127
+ //# sourceMappingURL=common.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"common.js","sourceRoot":"","sources":["../../src/schemas/common.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;GAGG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC1C,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC,CAAC,QAAQ,EAAE;SAC3D,QAAQ,CAAC,iFAAiF,CAAC;IAC9F,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE;SACnC,QAAQ,CAAC,wCAAwC,CAAC;IACrD,UAAU,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;SAC/B,QAAQ,CAAC,wCAAwC,CAAC;CACtD,CAAC,CAAC,QAAQ,EAAE,CAAC;AAOd;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC;IACvC,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE;SAC/C,QAAQ,CAAC,kDAAkD,CAAC;IAC/D,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,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