@requestly/mcp 1.0.2 → 1.0.3

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@requestly/mcp",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "main": "build/index.js",
5
5
  "type": "module",
6
6
  "bin": {
@@ -12,6 +12,7 @@ import {
12
12
  DelayPairSchema,
13
13
  ScriptPairSchema,
14
14
  ScriptModificationSchema,
15
+ ScriptAttributeSchema,
15
16
  RuleTypeEnum,
16
17
  } from '../types/ruleSchemas.js';
17
18
  import {
@@ -403,6 +404,42 @@ describe('ScriptModificationSchema', () => {
403
404
  const { codeType, ...rest } = validMod;
404
405
  expect(() => ScriptModificationSchema.parse(rest)).toThrow();
405
406
  });
407
+
408
+ it('accepts optional attributes array', () => {
409
+ const result = ScriptModificationSchema.parse({
410
+ ...validMod,
411
+ attributes: [
412
+ { name: 'data-tracker-id', value: '1234-5678' },
413
+ { name: 'type', value: 'text/javascript' },
414
+ ],
415
+ });
416
+ expect(result.attributes).toHaveLength(2);
417
+ expect(result.attributes![0].name).toBe('data-tracker-id');
418
+ });
419
+
420
+ it('accepts script without attributes (optional)', () => {
421
+ const result = ScriptModificationSchema.parse(validMod);
422
+ expect(result.attributes).toBeUndefined();
423
+ });
424
+
425
+ it('accepts empty attributes array', () => {
426
+ const result = ScriptModificationSchema.parse({ ...validMod, attributes: [] });
427
+ expect(result.attributes).toHaveLength(0);
428
+ });
429
+ });
430
+
431
+ describe('ScriptAttributeSchema', () => {
432
+ it('accepts valid attribute', () => {
433
+ expect(() => ScriptAttributeSchema.parse({ name: 'data-id', value: '123' })).not.toThrow();
434
+ });
435
+
436
+ it('rejects missing name', () => {
437
+ expect(() => ScriptAttributeSchema.parse({ value: '123' })).toThrow();
438
+ });
439
+
440
+ it('rejects missing value', () => {
441
+ expect(() => ScriptAttributeSchema.parse({ name: 'data-id' })).toThrow();
442
+ });
406
443
  });
407
444
 
408
445
  describe('ScriptPairSchema', () => {
@@ -424,7 +461,7 @@ describe('ScriptPairSchema', () => {
424
461
  scripts: [
425
462
  { codeType: 'js', value: 'alert("hi")', loadTime: 'beforePageLoad', type: 'code' },
426
463
  { codeType: 'css', value: 'body { color: red; }', loadTime: 'afterPageLoad', type: 'code' },
427
- { codeType: 'js', value: 'https://cdn.example.com/lib.js', loadTime: 'beforePageLoad', type: 'url' },
464
+ { codeType: 'js', value: 'https://cdn.example.com/lib.js', loadTime: 'beforePageLoad', type: 'url', attributes: [{ name: 'defer', value: '' }] },
428
465
  ],
429
466
  })
430
467
  ).not.toThrow();
@@ -584,6 +621,27 @@ describe('createRuleSchema (discriminated union)', () => {
584
621
  ).not.toThrow();
585
622
  });
586
623
 
624
+ it('validates Script rule with custom attributes', () => {
625
+ const result = createRuleSchema.parse({
626
+ ...baseRule,
627
+ ruleType: 'Script',
628
+ pairs: [{
629
+ source: validSource,
630
+ scripts: [{
631
+ codeType: 'js',
632
+ value: 'https://tracker.example.com/script.js',
633
+ loadTime: 'afterPageLoad',
634
+ type: 'url',
635
+ attributes: [
636
+ { name: 'data-luigisbox-tracker-id', value: '1234-5678' },
637
+ { name: 'type', value: 'text/javascript' },
638
+ ],
639
+ }],
640
+ }],
641
+ });
642
+ expect(result.pairs[0].scripts[0].attributes).toHaveLength(2);
643
+ });
644
+
587
645
  it('rejects Script rule with invalid pair (missing scripts)', () => {
588
646
  expect(() =>
589
647
  createRuleSchema.parse({
@@ -125,6 +125,16 @@ describe('Create Rule Tool - Schema Validation per Rule Type', () => {
125
125
  source: validSource,
126
126
  scripts: [
127
127
  { codeType: 'js', value: 'console.log("injected")', loadTime: 'afterPageLoad', type: 'code' },
128
+ {
129
+ codeType: 'js',
130
+ value: 'https://tracker.example.com/script.js',
131
+ loadTime: 'afterPageLoad',
132
+ type: 'url',
133
+ attributes: [
134
+ { name: 'data-tracker-id', value: '12345' },
135
+ { name: 'type', value: 'text/javascript' },
136
+ ],
137
+ },
128
138
  ],
129
139
  }],
130
140
  },
@@ -89,11 +89,17 @@ export const DelayPairSchema = z.object({
89
89
  }).describe('Delay value in milliseconds (stringified number).'),
90
90
  }).describe('Delay rule pair: source and delay.');
91
91
 
92
+ export const ScriptAttributeSchema = z.object({
93
+ name: z.string().describe('Attribute name (e.g. "data-tracker-id", "type", "defer").'),
94
+ value: z.string().describe('Attribute value.'),
95
+ }).describe('Custom HTML attribute to add to the injected script tag.');
96
+
92
97
  export const ScriptModificationSchema = z.object({
93
98
  codeType: z.enum(['js', 'css']).describe('Script language: js or css.'),
94
99
  value: z.string().describe('Script content or URL depending on type.'),
95
100
  loadTime: z.enum(['beforePageLoad', 'afterPageLoad']).describe('When to load the script: beforePageLoad or afterPageLoad.'),
96
101
  type: z.enum(['url', 'code']).describe('Script value type: url (external script URL) or code (inline script).'),
102
+ attributes: z.array(ScriptAttributeSchema).optional().describe('Optional array of custom HTML attributes to add to the injected script tag.'),
97
103
  }).describe('Script modification details.');
98
104
 
99
105
  export const ScriptPairSchema = z.object({