snow-flow 3.4.39 → 3.5.1

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.
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Artifact Registry - Central configuration for ALL ServiceNow artifact types
3
+ *
4
+ * This is the foundation for dynamic artifact handling.
5
+ * Each artifact type defines how it should be synced to local files.
6
+ *
7
+ * CAREFULLY DESIGNED FOR EXTENSIBILITY
8
+ */
9
+ export interface FieldMapping {
10
+ serviceNowField: string;
11
+ localFileName: string;
12
+ fileExtension: string;
13
+ description: string;
14
+ wrapperHeader?: string;
15
+ wrapperFooter?: string;
16
+ maxTokens: number;
17
+ isRequired: boolean;
18
+ validateES5?: boolean;
19
+ preprocessor?: (content: string) => string;
20
+ postprocessor?: (content: string) => string;
21
+ }
22
+ export interface ArtifactTypeConfig {
23
+ tableName: string;
24
+ displayName: string;
25
+ folderName: string;
26
+ identifierField: string;
27
+ fieldMappings: FieldMapping[];
28
+ coherenceRules?: CoherenceRule[];
29
+ searchableFields: string[];
30
+ supportsBulkOperations: boolean;
31
+ customValidation?: (artifact: any) => ValidationResult;
32
+ documentation?: string;
33
+ }
34
+ export interface CoherenceRule {
35
+ name: string;
36
+ description: string;
37
+ validate: (files: Map<string, string>) => ValidationResult;
38
+ }
39
+ export interface ValidationResult {
40
+ valid: boolean;
41
+ errors: string[];
42
+ warnings: string[];
43
+ hints: string[];
44
+ }
45
+ /**
46
+ * COMPLETE REGISTRY OF ALL SERVICENOW ARTIFACT TYPES
47
+ * Each entry is carefully configured for optimal local development
48
+ */
49
+ export declare const ARTIFACT_REGISTRY: Record<string, ArtifactTypeConfig>;
50
+ /**
51
+ * Get artifact configuration by table name
52
+ */
53
+ export declare function getArtifactConfig(tableName: string): ArtifactTypeConfig | undefined;
54
+ /**
55
+ * Get all supported table names
56
+ */
57
+ export declare function getSupportedTables(): string[];
58
+ /**
59
+ * Check if a table is supported
60
+ */
61
+ export declare function isTableSupported(tableName: string): boolean;
62
+ /**
63
+ * Get display name for a table
64
+ */
65
+ export declare function getTableDisplayName(tableName: string): string;
66
+ //# sourceMappingURL=artifact-registry.d.ts.map
@@ -0,0 +1,450 @@
1
+ "use strict";
2
+ /**
3
+ * Artifact Registry - Central configuration for ALL ServiceNow artifact types
4
+ *
5
+ * This is the foundation for dynamic artifact handling.
6
+ * Each artifact type defines how it should be synced to local files.
7
+ *
8
+ * CAREFULLY DESIGNED FOR EXTENSIBILITY
9
+ */
10
+ Object.defineProperty(exports, "__esModule", { value: true });
11
+ exports.ARTIFACT_REGISTRY = void 0;
12
+ exports.getArtifactConfig = getArtifactConfig;
13
+ exports.getSupportedTables = getSupportedTables;
14
+ exports.isTableSupported = isTableSupported;
15
+ exports.getTableDisplayName = getTableDisplayName;
16
+ /**
17
+ * COMPLETE REGISTRY OF ALL SERVICENOW ARTIFACT TYPES
18
+ * Each entry is carefully configured for optimal local development
19
+ */
20
+ exports.ARTIFACT_REGISTRY = {
21
+ // ========== WIDGETS ==========
22
+ 'sp_widget': {
23
+ tableName: 'sp_widget',
24
+ displayName: 'Service Portal Widget',
25
+ folderName: 'widgets',
26
+ identifierField: 'name',
27
+ searchableFields: ['name', 'title', 'template', 'script', 'client_script', 'css'],
28
+ supportsBulkOperations: true,
29
+ fieldMappings: [
30
+ {
31
+ serviceNowField: 'template',
32
+ localFileName: '{name}.template',
33
+ fileExtension: 'html',
34
+ description: 'HTML template with Angular bindings',
35
+ wrapperHeader: '<!-- ServiceNow Widget Template: {name} -->\n<!-- Angular bindings: {{data.x}}, ng-click="method()" -->\n\n',
36
+ maxTokens: 20000,
37
+ isRequired: true
38
+ },
39
+ {
40
+ serviceNowField: 'script',
41
+ localFileName: '{name}.server',
42
+ fileExtension: 'js',
43
+ description: 'Server-side script (ES5 ONLY)',
44
+ wrapperHeader: '/**\n * Server Script for Widget: {name}\n * ES5 ONLY - No arrow functions, const/let, template literals\n * Available: data, input, options, gs, $sp\n */\n\n(function() {\n',
45
+ wrapperFooter: '\n})();',
46
+ maxTokens: 20000,
47
+ isRequired: false,
48
+ validateES5: true
49
+ },
50
+ {
51
+ serviceNowField: 'client_script',
52
+ localFileName: '{name}.client',
53
+ fileExtension: 'js',
54
+ description: 'Client-side AngularJS controller',
55
+ wrapperHeader: '/**\n * Client Controller for Widget: {name}\n * AngularJS 1.x\n * Available: c (this), c.data, c.server, $scope\n */\n\nfunction(',
56
+ wrapperFooter: ')',
57
+ maxTokens: 20000,
58
+ isRequired: false
59
+ },
60
+ {
61
+ serviceNowField: 'css',
62
+ localFileName: '{name}',
63
+ fileExtension: 'css',
64
+ description: 'Widget-specific CSS styles',
65
+ wrapperHeader: '/* Styles for Widget: {name} */\n/* Prefix classes to avoid conflicts */\n\n',
66
+ maxTokens: 20000,
67
+ isRequired: false
68
+ },
69
+ {
70
+ serviceNowField: 'option_schema',
71
+ localFileName: '{name}.options',
72
+ fileExtension: 'json',
73
+ description: 'Widget instance options configuration',
74
+ maxTokens: 5000,
75
+ isRequired: false,
76
+ preprocessor: (content) => {
77
+ try {
78
+ return JSON.stringify(JSON.parse(content), null, 2);
79
+ }
80
+ catch {
81
+ return content;
82
+ }
83
+ }
84
+ }
85
+ ],
86
+ coherenceRules: [
87
+ {
88
+ name: 'Template-Server Data Binding',
89
+ description: 'Every {{data.x}} in template must have data.x in server script',
90
+ validate: (files) => {
91
+ const template = files.get('template') || '';
92
+ const server = files.get('script') || '';
93
+ const dataRefs = template.match(/\{\{data\.(\w+)/g) || [];
94
+ const errors = [];
95
+ dataRefs.forEach(ref => {
96
+ const prop = ref.replace('{{data.', '');
97
+ if (!server.includes(`data.${prop}`)) {
98
+ errors.push(`Template references {{data.${prop}}} but server doesn't set it`);
99
+ }
100
+ });
101
+ return {
102
+ valid: errors.length === 0,
103
+ errors,
104
+ warnings: [],
105
+ hints: []
106
+ };
107
+ }
108
+ },
109
+ {
110
+ name: 'Template-Client Method Binding',
111
+ description: 'Every ng-click in template must have matching method in client',
112
+ validate: (files) => {
113
+ const template = files.get('template') || '';
114
+ const client = files.get('client_script') || '';
115
+ const methods = template.match(/ng-click="(\w+)\(/g) || [];
116
+ const errors = [];
117
+ methods.forEach(method => {
118
+ const methodName = method.replace('ng-click="', '').replace('(', '');
119
+ if (!client.includes(`$scope.${methodName}`) && !client.includes(`c.${methodName}`)) {
120
+ errors.push(`Template calls ${methodName}() but client doesn't implement it`);
121
+ }
122
+ });
123
+ return {
124
+ valid: errors.length === 0,
125
+ errors,
126
+ warnings: [],
127
+ hints: []
128
+ };
129
+ }
130
+ }
131
+ ],
132
+ documentation: `
133
+ ## Widget Development Guidelines
134
+
135
+ 1. **Server Script** must be ES5 (no modern JavaScript)
136
+ 2. **Template** references must match server data properties
137
+ 3. **Client Script** must implement all template methods
138
+ 4. **CSS** should use prefixed classes
139
+ 5. Test widget in Service Portal after pushing
140
+ `
141
+ },
142
+ // ========== FLOWS ==========
143
+ 'sys_hub_flow': {
144
+ tableName: 'sys_hub_flow',
145
+ displayName: 'Flow Designer Flow',
146
+ folderName: 'flows',
147
+ identifierField: 'name',
148
+ searchableFields: ['name', 'label', 'description', 'definition'],
149
+ supportsBulkOperations: false,
150
+ fieldMappings: [
151
+ {
152
+ serviceNowField: 'definition',
153
+ localFileName: '{name}.flow',
154
+ fileExtension: 'json',
155
+ description: 'Complete flow definition with all steps and actions',
156
+ maxTokens: 50000, // Flows can be huge
157
+ isRequired: true,
158
+ preprocessor: (content) => {
159
+ try {
160
+ return JSON.stringify(JSON.parse(content), null, 2);
161
+ }
162
+ catch {
163
+ return content;
164
+ }
165
+ },
166
+ postprocessor: (content) => {
167
+ try {
168
+ return JSON.stringify(JSON.parse(content)); // Minify for ServiceNow
169
+ }
170
+ catch {
171
+ return content;
172
+ }
173
+ }
174
+ },
175
+ {
176
+ serviceNowField: 'description',
177
+ localFileName: '{name}.description',
178
+ fileExtension: 'md',
179
+ description: 'Flow description and documentation',
180
+ maxTokens: 5000,
181
+ isRequired: false
182
+ }
183
+ ],
184
+ documentation: `
185
+ ## Flow Development Notes
186
+
187
+ 1. Flows are JSON structures - be careful with syntax
188
+ 2. Test thoroughly after pushing changes
189
+ 3. Consider using subflows for reusable logic
190
+ 4. Check trigger conditions carefully
191
+ `
192
+ },
193
+ // ========== SCRIPT INCLUDES ==========
194
+ 'sys_script_include': {
195
+ tableName: 'sys_script_include',
196
+ displayName: 'Script Include',
197
+ folderName: 'script_includes',
198
+ identifierField: 'api_name',
199
+ searchableFields: ['api_name', 'name', 'script', 'description'],
200
+ supportsBulkOperations: true,
201
+ fieldMappings: [
202
+ {
203
+ serviceNowField: 'script',
204
+ localFileName: '{api_name}',
205
+ fileExtension: 'js',
206
+ description: 'Server-side class or function (ES5)',
207
+ wrapperHeader: '/**\n * Script Include: {name}\n * API Name: {api_name}\n * Type: {client_callable ? "Client Callable" : "Server Only"}\n */\n\n',
208
+ maxTokens: 30000,
209
+ isRequired: true,
210
+ validateES5: true
211
+ },
212
+ {
213
+ serviceNowField: 'description',
214
+ localFileName: '{api_name}.docs',
215
+ fileExtension: 'md',
216
+ description: 'Documentation for the Script Include',
217
+ maxTokens: 5000,
218
+ isRequired: false
219
+ }
220
+ ],
221
+ documentation: `
222
+ ## Script Include Guidelines
223
+
224
+ 1. Use prototype pattern for classes
225
+ 2. Document all public methods
226
+ 3. Handle errors gracefully
227
+ 4. Consider making client-callable if needed
228
+ `
229
+ },
230
+ // ========== BUSINESS RULES ==========
231
+ 'sys_script': {
232
+ tableName: 'sys_script',
233
+ displayName: 'Business Rule',
234
+ folderName: 'business_rules',
235
+ identifierField: 'name',
236
+ searchableFields: ['name', 'collection', 'script', 'condition'],
237
+ supportsBulkOperations: true,
238
+ fieldMappings: [
239
+ {
240
+ serviceNowField: 'script',
241
+ localFileName: '{name}',
242
+ fileExtension: 'js',
243
+ description: 'Business rule script',
244
+ wrapperHeader: '/**\n * Business Rule: {name}\n * Table: {collection}\n * When: {when}\n * Order: {order}\n * Available: current, previous, gs, g_scratchpad\n */\n\n(function executeRule(current, previous /*null when async*/) {\n',
245
+ wrapperFooter: '\n})(current, previous);',
246
+ maxTokens: 20000,
247
+ isRequired: true,
248
+ validateES5: true
249
+ },
250
+ {
251
+ serviceNowField: 'condition',
252
+ localFileName: '{name}.condition',
253
+ fileExtension: 'js',
254
+ description: 'Business rule condition script',
255
+ maxTokens: 5000,
256
+ isRequired: false
257
+ }
258
+ ]
259
+ },
260
+ // ========== UI PAGES ==========
261
+ 'sys_ui_page': {
262
+ tableName: 'sys_ui_page',
263
+ displayName: 'UI Page',
264
+ folderName: 'ui_pages',
265
+ identifierField: 'name',
266
+ searchableFields: ['name', 'html', 'client_script', 'processing_script'],
267
+ supportsBulkOperations: true,
268
+ fieldMappings: [
269
+ {
270
+ serviceNowField: 'html',
271
+ localFileName: '{name}',
272
+ fileExtension: 'html',
273
+ description: 'HTML content with Jelly scripting',
274
+ wrapperHeader: '<!-- UI Page: {name} -->\n<?xml version="1.0" encoding="utf-8" ?>\n<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">\n',
275
+ wrapperFooter: '\n</j:jelly>',
276
+ maxTokens: 30000,
277
+ isRequired: true
278
+ },
279
+ {
280
+ serviceNowField: 'client_script',
281
+ localFileName: '{name}.client',
282
+ fileExtension: 'js',
283
+ description: 'Client-side JavaScript',
284
+ maxTokens: 20000,
285
+ isRequired: false
286
+ },
287
+ {
288
+ serviceNowField: 'processing_script',
289
+ localFileName: '{name}.server',
290
+ fileExtension: 'js',
291
+ description: 'Server-side processing script (ES5)',
292
+ maxTokens: 20000,
293
+ isRequired: false,
294
+ validateES5: true
295
+ }
296
+ ]
297
+ },
298
+ // ========== CLIENT SCRIPTS ==========
299
+ 'sys_script_client': {
300
+ tableName: 'sys_script_client',
301
+ displayName: 'Client Script',
302
+ folderName: 'client_scripts',
303
+ identifierField: 'name',
304
+ searchableFields: ['name', 'table', 'script', 'description'],
305
+ supportsBulkOperations: true,
306
+ fieldMappings: [
307
+ {
308
+ serviceNowField: 'script',
309
+ localFileName: '{name}',
310
+ fileExtension: 'js',
311
+ description: 'Client-side form script',
312
+ wrapperHeader: '/**\n * Client Script: {name}\n * Table: {table}\n * Type: {type}\n * Available: g_form, g_user, g_list\n */\n\n',
313
+ maxTokens: 20000,
314
+ isRequired: true
315
+ }
316
+ ]
317
+ },
318
+ // ========== UI POLICIES ==========
319
+ 'sys_ui_policy': {
320
+ tableName: 'sys_ui_policy',
321
+ displayName: 'UI Policy',
322
+ folderName: 'ui_policies',
323
+ identifierField: 'short_description',
324
+ searchableFields: ['short_description', 'table', 'conditions'],
325
+ supportsBulkOperations: true,
326
+ fieldMappings: [
327
+ {
328
+ serviceNowField: 'script_true',
329
+ localFileName: '{short_description}.true',
330
+ fileExtension: 'js',
331
+ description: 'Script when condition is true',
332
+ maxTokens: 10000,
333
+ isRequired: false
334
+ },
335
+ {
336
+ serviceNowField: 'script_false',
337
+ localFileName: '{short_description}.false',
338
+ fileExtension: 'js',
339
+ description: 'Script when condition is false',
340
+ maxTokens: 10000,
341
+ isRequired: false
342
+ }
343
+ ]
344
+ },
345
+ // ========== REST MESSAGES ==========
346
+ 'sys_rest_message': {
347
+ tableName: 'sys_rest_message',
348
+ displayName: 'REST Message',
349
+ folderName: 'rest_messages',
350
+ identifierField: 'name',
351
+ searchableFields: ['name', 'description', 'rest_endpoint'],
352
+ supportsBulkOperations: false,
353
+ fieldMappings: [
354
+ {
355
+ serviceNowField: 'description',
356
+ localFileName: '{name}',
357
+ fileExtension: 'md',
358
+ description: 'REST message documentation',
359
+ maxTokens: 5000,
360
+ isRequired: false
361
+ }
362
+ ]
363
+ },
364
+ // ========== TRANSFORM MAPS ==========
365
+ 'sys_transform_map': {
366
+ tableName: 'sys_transform_map',
367
+ displayName: 'Transform Map',
368
+ folderName: 'transform_maps',
369
+ identifierField: 'name',
370
+ searchableFields: ['name', 'source_table', 'target_table'],
371
+ supportsBulkOperations: false,
372
+ fieldMappings: [
373
+ {
374
+ serviceNowField: 'script',
375
+ localFileName: '{name}',
376
+ fileExtension: 'js',
377
+ description: 'Transform map script',
378
+ maxTokens: 20000,
379
+ isRequired: false,
380
+ validateES5: true
381
+ }
382
+ ]
383
+ },
384
+ // ========== SCHEDULED JOBS ==========
385
+ 'sysauto_script': {
386
+ tableName: 'sysauto_script',
387
+ displayName: 'Scheduled Job',
388
+ folderName: 'scheduled_jobs',
389
+ identifierField: 'name',
390
+ searchableFields: ['name', 'script'],
391
+ supportsBulkOperations: true,
392
+ fieldMappings: [
393
+ {
394
+ serviceNowField: 'script',
395
+ localFileName: '{name}',
396
+ fileExtension: 'js',
397
+ description: 'Scheduled job script (ES5)',
398
+ wrapperHeader: '/**\n * Scheduled Job: {name}\n * Run as: {run_as}\n * Time zone: {time_zone}\n */\n\n',
399
+ maxTokens: 20000,
400
+ isRequired: true,
401
+ validateES5: true
402
+ }
403
+ ]
404
+ },
405
+ // ========== FIX SCRIPTS ==========
406
+ 'sys_script_fix': {
407
+ tableName: 'sys_script_fix',
408
+ displayName: 'Fix Script',
409
+ folderName: 'fix_scripts',
410
+ identifierField: 'name',
411
+ searchableFields: ['name', 'script', 'description'],
412
+ supportsBulkOperations: true,
413
+ fieldMappings: [
414
+ {
415
+ serviceNowField: 'script',
416
+ localFileName: '{name}',
417
+ fileExtension: 'js',
418
+ description: 'Fix script for one-time execution',
419
+ maxTokens: 30000,
420
+ isRequired: true,
421
+ validateES5: true
422
+ }
423
+ ]
424
+ }
425
+ };
426
+ /**
427
+ * Get artifact configuration by table name
428
+ */
429
+ function getArtifactConfig(tableName) {
430
+ return exports.ARTIFACT_REGISTRY[tableName];
431
+ }
432
+ /**
433
+ * Get all supported table names
434
+ */
435
+ function getSupportedTables() {
436
+ return Object.keys(exports.ARTIFACT_REGISTRY);
437
+ }
438
+ /**
439
+ * Check if a table is supported
440
+ */
441
+ function isTableSupported(tableName) {
442
+ return tableName in exports.ARTIFACT_REGISTRY;
443
+ }
444
+ /**
445
+ * Get display name for a table
446
+ */
447
+ function getTableDisplayName(tableName) {
448
+ return exports.ARTIFACT_REGISTRY[tableName]?.displayName || tableName;
449
+ }
450
+ //# sourceMappingURL=artifact-registry.js.map
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Artifact Sync System - Public API
3
+ *
4
+ * This module provides dynamic synchronization between ServiceNow artifacts
5
+ * and local files, enabling Claude Code to use its native tools on ServiceNow code.
6
+ */
7
+ export * from './artifact-registry';
8
+ export { ArtifactLocalSync } from '../artifact-local-sync';
9
+ export { SmartFieldFetcher } from '../smart-field-fetcher';
10
+ /**
11
+ * Example usage:
12
+ *
13
+ * ```typescript
14
+ * import { ArtifactLocalSync, getArtifactConfig } from './utils/artifact-sync';
15
+ *
16
+ * const sync = new ArtifactLocalSync(serviceNowClient);
17
+ *
18
+ * // Pull any artifact type
19
+ * const artifact = await sync.pullArtifact('sp_widget', 'widget_sys_id');
20
+ * const artifact = await sync.pullArtifact('sys_script', 'business_rule_sys_id');
21
+ * const artifact = await sync.pullArtifact('sys_script_include', 'script_include_sys_id');
22
+ *
23
+ * // Auto-detect artifact type
24
+ * const artifact = await sync.pullArtifactBySysId('any_sys_id');
25
+ *
26
+ * // Push changes back
27
+ * await sync.pushArtifact('sys_id');
28
+ *
29
+ * // Validate coherence
30
+ * const results = await sync.validateArtifactCoherence('sys_id');
31
+ * ```
32
+ */
33
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ /**
3
+ * Artifact Sync System - Public API
4
+ *
5
+ * This module provides dynamic synchronization between ServiceNow artifacts
6
+ * and local files, enabling Claude Code to use its native tools on ServiceNow code.
7
+ */
8
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
9
+ if (k2 === undefined) k2 = k;
10
+ var desc = Object.getOwnPropertyDescriptor(m, k);
11
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
12
+ desc = { enumerable: true, get: function() { return m[k]; } };
13
+ }
14
+ Object.defineProperty(o, k2, desc);
15
+ }) : (function(o, m, k, k2) {
16
+ if (k2 === undefined) k2 = k;
17
+ o[k2] = m[k];
18
+ }));
19
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
20
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
21
+ };
22
+ Object.defineProperty(exports, "__esModule", { value: true });
23
+ exports.SmartFieldFetcher = exports.ArtifactLocalSync = void 0;
24
+ __exportStar(require("./artifact-registry"), exports);
25
+ var artifact_local_sync_1 = require("../artifact-local-sync");
26
+ Object.defineProperty(exports, "ArtifactLocalSync", { enumerable: true, get: function () { return artifact_local_sync_1.ArtifactLocalSync; } });
27
+ var smart_field_fetcher_1 = require("../smart-field-fetcher");
28
+ Object.defineProperty(exports, "SmartFieldFetcher", { enumerable: true, get: function () { return smart_field_fetcher_1.SmartFieldFetcher; } });
29
+ /**
30
+ * Example usage:
31
+ *
32
+ * ```typescript
33
+ * import { ArtifactLocalSync, getArtifactConfig } from './utils/artifact-sync';
34
+ *
35
+ * const sync = new ArtifactLocalSync(serviceNowClient);
36
+ *
37
+ * // Pull any artifact type
38
+ * const artifact = await sync.pullArtifact('sp_widget', 'widget_sys_id');
39
+ * const artifact = await sync.pullArtifact('sys_script', 'business_rule_sys_id');
40
+ * const artifact = await sync.pullArtifact('sys_script_include', 'script_include_sys_id');
41
+ *
42
+ * // Auto-detect artifact type
43
+ * const artifact = await sync.pullArtifactBySysId('any_sys_id');
44
+ *
45
+ * // Push changes back
46
+ * await sync.pushArtifact('sys_id');
47
+ *
48
+ * // Validate coherence
49
+ * const results = await sync.validateArtifactCoherence('sys_id');
50
+ * ```
51
+ */
52
+ //# sourceMappingURL=index.js.map