@browserless.io/browserless 2.24.0-beta-3 → 2.24.0-beta-4

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/build/http.d.ts CHANGED
@@ -151,6 +151,7 @@ export declare enum HTTPRoutes {
151
151
  export declare enum HTTPManagementRoutes {
152
152
  active = "/active?(/)",
153
153
  config = "/config?(/)",
154
+ meta = "/meta?(/)",
154
155
  metrics = "/metrics?(/)",
155
156
  metricsTotal = "/metrics/total?(/)",
156
157
  pressure = "/pressure?(/)",
package/build/http.js CHANGED
@@ -117,6 +117,7 @@ export var HTTPManagementRoutes;
117
117
  (function (HTTPManagementRoutes) {
118
118
  HTTPManagementRoutes["active"] = "/active?(/)";
119
119
  HTTPManagementRoutes["config"] = "/config?(/)";
120
+ HTTPManagementRoutes["meta"] = "/meta?(/)";
120
121
  HTTPManagementRoutes["metrics"] = "/metrics?(/)";
121
122
  HTTPManagementRoutes["metricsTotal"] = "/metrics/total?(/)";
122
123
  HTTPManagementRoutes["pressure"] = "/pressure?(/)";
@@ -438,14 +438,14 @@
438
438
  "length": {
439
439
  "type": "number"
440
440
  },
441
- "__@toStringTag@14519": {
441
+ "__@toStringTag@14520": {
442
442
  "type": "string",
443
443
  "const": "Uint8Array"
444
444
  }
445
445
  },
446
446
  "required": [
447
447
  "BYTES_PER_ELEMENT",
448
- "__@toStringTag@14519",
448
+ "__@toStringTag@14520",
449
449
  "buffer",
450
450
  "byteLength",
451
451
  "byteOffset",
@@ -480,13 +480,13 @@
480
480
  "byteLength": {
481
481
  "type": "number"
482
482
  },
483
- "__@toStringTag@14519": {
483
+ "__@toStringTag@14520": {
484
484
  "type": "string"
485
485
  }
486
486
  },
487
487
  "additionalProperties": false,
488
488
  "required": [
489
- "__@toStringTag@14519",
489
+ "__@toStringTag@14520",
490
490
  "byteLength"
491
491
  ]
492
492
  },
@@ -496,18 +496,18 @@
496
496
  "byteLength": {
497
497
  "type": "number"
498
498
  },
499
- "__@species@14557": {
499
+ "__@species@14558": {
500
500
  "$ref": "#/definitions/SharedArrayBuffer"
501
501
  },
502
- "__@toStringTag@14519": {
502
+ "__@toStringTag@14520": {
503
503
  "type": "string",
504
504
  "const": "SharedArrayBuffer"
505
505
  }
506
506
  },
507
507
  "additionalProperties": false,
508
508
  "required": [
509
- "__@species@14557",
510
- "__@toStringTag@14519",
509
+ "__@species@14558",
510
+ "__@toStringTag@14520",
511
511
  "byteLength"
512
512
  ]
513
513
  },
@@ -583,14 +583,14 @@
583
583
  "length": {
584
584
  "type": "number"
585
585
  },
586
- "__@toStringTag@115567": {
586
+ "__@toStringTag@115575": {
587
587
  "type": "string",
588
588
  "const": "Uint8Array"
589
589
  }
590
590
  },
591
591
  "required": [
592
592
  "BYTES_PER_ELEMENT",
593
- "__@toStringTag@115567",
593
+ "__@toStringTag@115575",
594
594
  "buffer",
595
595
  "byteLength",
596
596
  "byteOffset",
@@ -625,13 +625,13 @@
625
625
  "byteLength": {
626
626
  "type": "number"
627
627
  },
628
- "__@toStringTag@115567": {
628
+ "__@toStringTag@115575": {
629
629
  "type": "string"
630
630
  }
631
631
  },
632
632
  "additionalProperties": false,
633
633
  "required": [
634
- "__@toStringTag@115567",
634
+ "__@toStringTag@115575",
635
635
  "byteLength"
636
636
  ]
637
637
  },
@@ -641,18 +641,18 @@
641
641
  "byteLength": {
642
642
  "type": "number"
643
643
  },
644
- "__@species@115605": {
644
+ "__@species@115613": {
645
645
  "$ref": "#/definitions/SharedArrayBuffer"
646
646
  },
647
- "__@toStringTag@115567": {
647
+ "__@toStringTag@115575": {
648
648
  "type": "string",
649
649
  "const": "SharedArrayBuffer"
650
650
  }
651
651
  },
652
652
  "additionalProperties": false,
653
653
  "required": [
654
- "__@species@115605",
655
- "__@toStringTag@115567",
654
+ "__@species@115613",
655
+ "__@toStringTag@115575",
656
656
  "byteLength"
657
657
  ]
658
658
  },
@@ -485,14 +485,14 @@
485
485
  "length": {
486
486
  "type": "number"
487
487
  },
488
- "__@toStringTag@159208": {
488
+ "__@toStringTag@144808": {
489
489
  "type": "string",
490
490
  "const": "Uint8Array"
491
491
  }
492
492
  },
493
493
  "required": [
494
494
  "BYTES_PER_ELEMENT",
495
- "__@toStringTag@159208",
495
+ "__@toStringTag@144808",
496
496
  "buffer",
497
497
  "byteLength",
498
498
  "byteOffset",
@@ -527,13 +527,13 @@
527
527
  "byteLength": {
528
528
  "type": "number"
529
529
  },
530
- "__@toStringTag@159208": {
530
+ "__@toStringTag@144808": {
531
531
  "type": "string"
532
532
  }
533
533
  },
534
534
  "additionalProperties": false,
535
535
  "required": [
536
- "__@toStringTag@159208",
536
+ "__@toStringTag@144808",
537
537
  "byteLength"
538
538
  ]
539
539
  },
@@ -543,18 +543,18 @@
543
543
  "byteLength": {
544
544
  "type": "number"
545
545
  },
546
- "__@species@159246": {
546
+ "__@species@144846": {
547
547
  "$ref": "#/definitions/SharedArrayBuffer"
548
548
  },
549
- "__@toStringTag@159208": {
549
+ "__@toStringTag@144808": {
550
550
  "type": "string",
551
551
  "const": "SharedArrayBuffer"
552
552
  }
553
553
  },
554
554
  "additionalProperties": false,
555
555
  "required": [
556
- "__@species@159246",
557
- "__@toStringTag@159208",
556
+ "__@species@144846",
557
+ "__@toStringTag@144808",
558
558
  "byteLength"
559
559
  ]
560
560
  },
@@ -528,14 +528,14 @@
528
528
  "length": {
529
529
  "type": "number"
530
530
  },
531
- "__@toStringTag@144598": {
531
+ "__@toStringTag@130197": {
532
532
  "type": "string",
533
533
  "const": "Uint8Array"
534
534
  }
535
535
  },
536
536
  "required": [
537
537
  "BYTES_PER_ELEMENT",
538
- "__@toStringTag@144598",
538
+ "__@toStringTag@130197",
539
539
  "buffer",
540
540
  "byteLength",
541
541
  "byteOffset",
@@ -570,13 +570,13 @@
570
570
  "byteLength": {
571
571
  "type": "number"
572
572
  },
573
- "__@toStringTag@144598": {
573
+ "__@toStringTag@130197": {
574
574
  "type": "string"
575
575
  }
576
576
  },
577
577
  "additionalProperties": false,
578
578
  "required": [
579
- "__@toStringTag@144598",
579
+ "__@toStringTag@130197",
580
580
  "byteLength"
581
581
  ]
582
582
  },
@@ -586,18 +586,18 @@
586
586
  "byteLength": {
587
587
  "type": "number"
588
588
  },
589
- "__@species@144636": {
589
+ "__@species@130235": {
590
590
  "$ref": "#/definitions/SharedArrayBuffer"
591
591
  },
592
- "__@toStringTag@144598": {
592
+ "__@toStringTag@130197": {
593
593
  "type": "string",
594
594
  "const": "SharedArrayBuffer"
595
595
  }
596
596
  },
597
597
  "additionalProperties": false,
598
598
  "required": [
599
- "__@species@144636",
600
- "__@toStringTag@144598",
599
+ "__@species@130235",
600
+ "__@toStringTag@130197",
601
601
  "byteLength"
602
602
  ]
603
603
  },
@@ -438,14 +438,14 @@
438
438
  "length": {
439
439
  "type": "number"
440
440
  },
441
- "__@toStringTag@173871": {
441
+ "__@toStringTag@173883": {
442
442
  "type": "string",
443
443
  "const": "Uint8Array"
444
444
  }
445
445
  },
446
446
  "required": [
447
447
  "BYTES_PER_ELEMENT",
448
- "__@toStringTag@173871",
448
+ "__@toStringTag@173883",
449
449
  "buffer",
450
450
  "byteLength",
451
451
  "byteOffset",
@@ -480,13 +480,13 @@
480
480
  "byteLength": {
481
481
  "type": "number"
482
482
  },
483
- "__@toStringTag@173871": {
483
+ "__@toStringTag@173883": {
484
484
  "type": "string"
485
485
  }
486
486
  },
487
487
  "additionalProperties": false,
488
488
  "required": [
489
- "__@toStringTag@173871",
489
+ "__@toStringTag@173883",
490
490
  "byteLength"
491
491
  ]
492
492
  },
@@ -496,18 +496,18 @@
496
496
  "byteLength": {
497
497
  "type": "number"
498
498
  },
499
- "__@species@173909": {
499
+ "__@species@173921": {
500
500
  "$ref": "#/definitions/SharedArrayBuffer"
501
501
  },
502
- "__@toStringTag@173871": {
502
+ "__@toStringTag@173883": {
503
503
  "type": "string",
504
504
  "const": "SharedArrayBuffer"
505
505
  }
506
506
  },
507
507
  "additionalProperties": false,
508
508
  "required": [
509
- "__@species@173909",
510
- "__@toStringTag@173871",
509
+ "__@species@173921",
510
+ "__@toStringTag@173883",
511
511
  "byteLength"
512
512
  ]
513
513
  },
@@ -583,14 +583,14 @@
583
583
  "length": {
584
584
  "type": "number"
585
585
  },
586
- "__@toStringTag@318596": {
586
+ "__@toStringTag@260481": {
587
587
  "type": "string",
588
588
  "const": "Uint8Array"
589
589
  }
590
590
  },
591
591
  "required": [
592
592
  "BYTES_PER_ELEMENT",
593
- "__@toStringTag@318596",
593
+ "__@toStringTag@260481",
594
594
  "buffer",
595
595
  "byteLength",
596
596
  "byteOffset",
@@ -625,13 +625,13 @@
625
625
  "byteLength": {
626
626
  "type": "number"
627
627
  },
628
- "__@toStringTag@318596": {
628
+ "__@toStringTag@260481": {
629
629
  "type": "string"
630
630
  }
631
631
  },
632
632
  "additionalProperties": false,
633
633
  "required": [
634
- "__@toStringTag@318596",
634
+ "__@toStringTag@260481",
635
635
  "byteLength"
636
636
  ]
637
637
  },
@@ -641,18 +641,18 @@
641
641
  "byteLength": {
642
642
  "type": "number"
643
643
  },
644
- "__@species@318634": {
644
+ "__@species@260519": {
645
645
  "$ref": "#/definitions/SharedArrayBuffer"
646
646
  },
647
- "__@toStringTag@318596": {
647
+ "__@toStringTag@260481": {
648
648
  "type": "string",
649
649
  "const": "SharedArrayBuffer"
650
650
  }
651
651
  },
652
652
  "additionalProperties": false,
653
653
  "required": [
654
- "__@species@318634",
655
- "__@toStringTag@318596",
654
+ "__@species@260519",
655
+ "__@toStringTag@260481",
656
656
  "byteLength"
657
657
  ]
658
658
  },
@@ -485,14 +485,14 @@
485
485
  "length": {
486
486
  "type": "number"
487
487
  },
488
- "__@toStringTag@289503": {
488
+ "__@toStringTag@289525": {
489
489
  "type": "string",
490
490
  "const": "Uint8Array"
491
491
  }
492
492
  },
493
493
  "required": [
494
494
  "BYTES_PER_ELEMENT",
495
- "__@toStringTag@289503",
495
+ "__@toStringTag@289525",
496
496
  "buffer",
497
497
  "byteLength",
498
498
  "byteOffset",
@@ -527,13 +527,13 @@
527
527
  "byteLength": {
528
528
  "type": "number"
529
529
  },
530
- "__@toStringTag@289503": {
530
+ "__@toStringTag@289525": {
531
531
  "type": "string"
532
532
  }
533
533
  },
534
534
  "additionalProperties": false,
535
535
  "required": [
536
- "__@toStringTag@289503",
536
+ "__@toStringTag@289525",
537
537
  "byteLength"
538
538
  ]
539
539
  },
@@ -543,18 +543,18 @@
543
543
  "byteLength": {
544
544
  "type": "number"
545
545
  },
546
- "__@species@289541": {
546
+ "__@species@289563": {
547
547
  "$ref": "#/definitions/SharedArrayBuffer"
548
548
  },
549
- "__@toStringTag@289503": {
549
+ "__@toStringTag@289525": {
550
550
  "type": "string",
551
551
  "const": "SharedArrayBuffer"
552
552
  }
553
553
  },
554
554
  "additionalProperties": false,
555
555
  "required": [
556
- "__@species@289541",
557
- "__@toStringTag@289503",
556
+ "__@species@289563",
557
+ "__@toStringTag@289525",
558
558
  "byteLength"
559
559
  ]
560
560
  },
@@ -528,14 +528,14 @@
528
528
  "length": {
529
529
  "type": "number"
530
530
  },
531
- "__@toStringTag@274896": {
531
+ "__@toStringTag@304210": {
532
532
  "type": "string",
533
533
  "const": "Uint8Array"
534
534
  }
535
535
  },
536
536
  "required": [
537
537
  "BYTES_PER_ELEMENT",
538
- "__@toStringTag@274896",
538
+ "__@toStringTag@304210",
539
539
  "buffer",
540
540
  "byteLength",
541
541
  "byteOffset",
@@ -570,13 +570,13 @@
570
570
  "byteLength": {
571
571
  "type": "number"
572
572
  },
573
- "__@toStringTag@274896": {
573
+ "__@toStringTag@304210": {
574
574
  "type": "string"
575
575
  }
576
576
  },
577
577
  "additionalProperties": false,
578
578
  "required": [
579
- "__@toStringTag@274896",
579
+ "__@toStringTag@304210",
580
580
  "byteLength"
581
581
  ]
582
582
  },
@@ -586,18 +586,18 @@
586
586
  "byteLength": {
587
587
  "type": "number"
588
588
  },
589
- "__@species@274934": {
589
+ "__@species@304248": {
590
590
  "$ref": "#/definitions/SharedArrayBuffer"
591
591
  },
592
- "__@toStringTag@274896": {
592
+ "__@toStringTag@304210": {
593
593
  "type": "string",
594
594
  "const": "SharedArrayBuffer"
595
595
  }
596
596
  },
597
597
  "additionalProperties": false,
598
598
  "required": [
599
- "__@species@274934",
600
- "__@toStringTag@274896",
599
+ "__@species@304248",
600
+ "__@toStringTag@304210",
601
601
  "byteLength"
602
602
  ]
603
603
  },
@@ -0,0 +1,41 @@
1
+ import { APITags, HTTPManagementRoutes, HTTPRoute, Methods, Request, contentTypes } from '@browserless.io/browserless';
2
+ import { ServerResponse } from 'http';
3
+ export interface ResponseSchema {
4
+ /**
5
+ * The semantic version of the Browserless API
6
+ */
7
+ version: string;
8
+ /**
9
+ * The version of Chromium installed, or null if not installed
10
+ */
11
+ chromium: string | null;
12
+ /**
13
+ * The version of Webkit installed, or null if not installed
14
+ */
15
+ webkit: string | null;
16
+ /**
17
+ * The version of Firefox installed, or null if not installed
18
+ */
19
+ firefox: string | null;
20
+ /**
21
+ * The supported version(s) of puppeteer
22
+ */
23
+ playwright: string[];
24
+ /**
25
+ * The supported version(s) of playwright
26
+ */
27
+ puppeteer: string[];
28
+ }
29
+ export default class MetaGetRoute extends HTTPRoute {
30
+ name: string;
31
+ accepts: contentTypes[];
32
+ auth: boolean;
33
+ browser: null;
34
+ concurrency: boolean;
35
+ contentTypes: contentTypes[];
36
+ description: string;
37
+ method: Methods;
38
+ path: HTTPManagementRoutes;
39
+ tags: APITags[];
40
+ handler(_req: Request, res: ServerResponse): Promise<void>;
41
+ }
@@ -0,0 +1,40 @@
1
+ import { APITags, BrowserlessRoutes, ChromiumCDP, FirefoxPlaywright, HTTPManagementRoutes, HTTPRoute, Methods, WebKitPlaywright, availableBrowsers, contentTypes, jsonResponse, } from '@browserless.io/browserless';
2
+ import { createRequire } from 'module';
3
+ const semverReg = /(\*|\^|>|=|<|~)/gi;
4
+ const require = createRequire(import.meta.url);
5
+ const blessPackageJSON = require('../../../../package.json');
6
+ const { browsers } = require('../../../../node_modules/playwright-core/browsers.json');
7
+ const chromium = browsers.find((b) => b.name === 'chromium').browserVersion;
8
+ const firefox = browsers.find((b) => b.name === 'firefox').browserVersion;
9
+ const webkit = browsers.find((b) => b.name === 'webkit').browserVersion;
10
+ const playwrightCore = blessPackageJSON.dependencies['playwright-core'].replace(semverReg, '');
11
+ const puppeteer = blessPackageJSON.dependencies['puppeteer-core'].replace(semverReg, '');
12
+ const playwright = Object.entries(blessPackageJSON.playwrightVersions)
13
+ .map(([, v]) => blessPackageJSON.dependencies[v])
14
+ .filter((_) => !!_)
15
+ .map((v) => v.match(/[0-9.]+/g).join(''))
16
+ .concat(playwrightCore);
17
+ export default class MetaGetRoute extends HTTPRoute {
18
+ name = BrowserlessRoutes.MetaGetRoute;
19
+ accepts = [contentTypes.any];
20
+ auth = true;
21
+ browser = null;
22
+ concurrency = false;
23
+ contentTypes = [contentTypes.json];
24
+ description = `Returns a JSON payload of the current system versions, including the core API version.`;
25
+ method = Methods.get;
26
+ path = HTTPManagementRoutes.meta;
27
+ tags = [APITags.management];
28
+ async handler(_req, res) {
29
+ const installedBrowsers = await availableBrowsers;
30
+ const response = {
31
+ version: blessPackageJSON.version,
32
+ chromium: installedBrowsers.includes(ChromiumCDP) ? chromium : null,
33
+ firefox: installedBrowsers.includes(FirefoxPlaywright) ? firefox : null,
34
+ webkit: installedBrowsers.includes(WebKitPlaywright) ? webkit : null,
35
+ playwright: [...new Set(playwright)],
36
+ puppeteer: [puppeteer],
37
+ };
38
+ return jsonResponse(res, 200, response);
39
+ }
40
+ }
@@ -0,0 +1,54 @@
1
+ {
2
+ "type": "object",
3
+ "properties": {
4
+ "version": {
5
+ "description": "The semantic version of the Browserless API",
6
+ "type": "string"
7
+ },
8
+ "chromium": {
9
+ "description": "The version of Chromium installed, or null if not installed",
10
+ "type": [
11
+ "null",
12
+ "string"
13
+ ]
14
+ },
15
+ "webkit": {
16
+ "description": "The version of Webkit installed, or null if not installed",
17
+ "type": [
18
+ "null",
19
+ "string"
20
+ ]
21
+ },
22
+ "firefox": {
23
+ "description": "The version of Firefox installed, or null if not installed",
24
+ "type": [
25
+ "null",
26
+ "string"
27
+ ]
28
+ },
29
+ "playwright": {
30
+ "description": "The supported version(s) of puppeteer",
31
+ "type": "array",
32
+ "items": {
33
+ "type": "string"
34
+ }
35
+ },
36
+ "puppeteer": {
37
+ "description": "The supported version(s) of playwright",
38
+ "type": "array",
39
+ "items": {
40
+ "type": "string"
41
+ }
42
+ }
43
+ },
44
+ "additionalProperties": false,
45
+ "required": [
46
+ "chromium",
47
+ "firefox",
48
+ "playwright",
49
+ "puppeteer",
50
+ "version",
51
+ "webkit"
52
+ ],
53
+ "$schema": "http://json-schema.org/draft-07/schema#"
54
+ }
@@ -17,6 +17,13 @@ describe('Management APIs', function () {
17
17
  expect(res.status).to.equal(200);
18
18
  });
19
19
  });
20
+ it('allows requests to /meta', async () => {
21
+ await start();
22
+ await fetch('http://localhost:3000/meta?token=6R0W53R135510').then(async (res) => {
23
+ expect(res.headers.get('content-type')).to.equal('application/json; charset=UTF-8');
24
+ expect(res.status).to.equal(200);
25
+ });
26
+ });
20
27
  it('allows requests to /metrics', async () => {
21
28
  await start();
22
29
  await fetch('http://localhost:3000/metrics?token=6R0W53R135510').then(async (res) => {
package/build/types.d.ts CHANGED
@@ -520,6 +520,7 @@ export declare const BrowserlessWebKitRoutes: {
520
520
  export declare const BrowserlessManagementRoutes: {
521
521
  ActiveGetRoute: string;
522
522
  ConfigGetRoute: string;
523
+ MetaGetRoute: string;
523
524
  MetricsGetRoute: string;
524
525
  MetricsTotalGetRoute: string;
525
526
  PressureGetRoute: string;
@@ -529,6 +530,7 @@ export declare const BrowserlessManagementRoutes: {
529
530
  export declare const BrowserlessRoutes: {
530
531
  ActiveGetRoute: string;
531
532
  ConfigGetRoute: string;
533
+ MetaGetRoute: string;
532
534
  MetricsGetRoute: string;
533
535
  MetricsTotalGetRoute: string;
534
536
  PressureGetRoute: string;
package/build/types.js CHANGED
@@ -190,6 +190,7 @@ export const BrowserlessWebKitRoutes = {
190
190
  export const BrowserlessManagementRoutes = {
191
191
  ActiveGetRoute: 'ActiveGetRoute',
192
192
  ConfigGetRoute: 'ConfigGetRoute',
193
+ MetaGetRoute: 'MetaGetRoute',
193
194
  MetricsGetRoute: 'MetricsGetRoute',
194
195
  MetricsTotalGetRoute: 'MetricsTotalGetRoute',
195
196
  PressureGetRoute: 'PressureGetRoute',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@browserless.io/browserless",
3
- "version": "2.24.0-beta-3",
3
+ "version": "2.24.0-beta-4",
4
4
  "license": "SSPL",
5
5
  "description": "The browserless platform",
6
6
  "author": "browserless.io",
@@ -78,8 +78,8 @@
78
78
  "@types/mocha": "^10.0.10",
79
79
  "@types/node": "^22.10.1",
80
80
  "@types/sinon": "^17.0.3",
81
- "@typescript-eslint/eslint-plugin": "^8.16.0",
82
- "@typescript-eslint/parser": "^8.16.0",
81
+ "@typescript-eslint/eslint-plugin": "^8.17.0",
82
+ "@typescript-eslint/parser": "^8.17.0",
83
83
  "assert": "^2.0.0",
84
84
  "chai": "^5.1.2",
85
85
  "cross-env": "^7.0.3",
@@ -90,7 +90,7 @@
90
90
  "extract-zip": "^2.0.1",
91
91
  "gunzip-maybe": "^1.4.2",
92
92
  "marked": "^15.0.3",
93
- "mocha": "^10.8.2",
93
+ "mocha": "^11.0.1",
94
94
  "move-file": "^3.1.0",
95
95
  "prettier": "^3.4.1",
96
96
  "sinon": "^19.0.2",
package/src/http.ts CHANGED
@@ -126,6 +126,7 @@ export enum HTTPRoutes {
126
126
  export enum HTTPManagementRoutes {
127
127
  active = '/active?(/)',
128
128
  config = '/config?(/)',
129
+ meta = '/meta?(/)',
129
130
  metrics = '/metrics?(/)',
130
131
  metricsTotal = '/metrics/total?(/)',
131
132
  pressure = '/pressure?(/)',
@@ -0,0 +1,102 @@
1
+ import {
2
+ APITags,
3
+ BrowserlessRoutes,
4
+ ChromiumCDP,
5
+ FirefoxPlaywright,
6
+ HTTPManagementRoutes,
7
+ HTTPRoute,
8
+ Methods,
9
+ Request,
10
+ WebKitPlaywright,
11
+ availableBrowsers,
12
+ contentTypes,
13
+ jsonResponse,
14
+ } from '@browserless.io/browserless';
15
+ import { ServerResponse } from 'http';
16
+ import { createRequire } from 'module';
17
+
18
+ export interface ResponseSchema {
19
+ /**
20
+ * The semantic version of the Browserless API
21
+ */
22
+ version: string;
23
+
24
+ /**
25
+ * The version of Chromium installed, or null if not installed
26
+ */
27
+ chromium: string | null;
28
+
29
+ /**
30
+ * The version of Webkit installed, or null if not installed
31
+ */
32
+ webkit: string | null;
33
+
34
+ /**
35
+ * The version of Firefox installed, or null if not installed
36
+ */
37
+ firefox: string | null;
38
+
39
+ /**
40
+ * The supported version(s) of puppeteer
41
+ */
42
+ playwright: string[];
43
+
44
+ /**
45
+ * The supported version(s) of playwright
46
+ */
47
+ puppeteer: string[];
48
+ }
49
+
50
+ const semverReg = /(\*|\^|>|=|<|~)/gi;
51
+ const require = createRequire(import.meta.url);
52
+ const blessPackageJSON = require('../../../../package.json');
53
+ const { browsers } =
54
+ require('../../../../node_modules/playwright-core/browsers.json') as {
55
+ browsers: [
56
+ {
57
+ name: string;
58
+ browserVersion: string;
59
+ },
60
+ ];
61
+ };
62
+ const chromium = browsers.find((b) => b.name === 'chromium')!.browserVersion;
63
+ const firefox = browsers.find((b) => b.name === 'firefox')!.browserVersion;
64
+ const webkit = browsers.find((b) => b.name === 'webkit')!.browserVersion;
65
+ const playwrightCore = blessPackageJSON.dependencies['playwright-core'].replace(
66
+ semverReg,
67
+ '',
68
+ );
69
+ const puppeteer = blessPackageJSON.dependencies['puppeteer-core'].replace(
70
+ semverReg,
71
+ '',
72
+ );
73
+ const playwright = Object.entries(blessPackageJSON.playwrightVersions)
74
+ .map(([, v]) => blessPackageJSON.dependencies[v as string])
75
+ .filter((_) => !!_)
76
+ .map((v) => v.match(/[0-9.]+/g).join(''))
77
+ .concat(playwrightCore);
78
+
79
+ export default class MetaGetRoute extends HTTPRoute {
80
+ name = BrowserlessRoutes.MetaGetRoute;
81
+ accepts = [contentTypes.any];
82
+ auth = true;
83
+ browser = null;
84
+ concurrency = false;
85
+ contentTypes = [contentTypes.json];
86
+ description = `Returns a JSON payload of the current system versions, including the core API version.`;
87
+ method = Methods.get;
88
+ path = HTTPManagementRoutes.meta;
89
+ tags = [APITags.management];
90
+ async handler(_req: Request, res: ServerResponse): Promise<void> {
91
+ const installedBrowsers = await availableBrowsers;
92
+ const response: ResponseSchema = {
93
+ version: blessPackageJSON.version,
94
+ chromium: installedBrowsers.includes(ChromiumCDP) ? chromium : null,
95
+ firefox: installedBrowsers.includes(FirefoxPlaywright) ? firefox : null,
96
+ webkit: installedBrowsers.includes(WebKitPlaywright) ? webkit : null,
97
+ playwright: [...new Set(playwright)],
98
+ puppeteer: [puppeteer],
99
+ };
100
+ return jsonResponse(res, 200, response);
101
+ }
102
+ }
@@ -30,6 +30,19 @@ describe('Management APIs', function () {
30
30
  );
31
31
  });
32
32
 
33
+ it('allows requests to /meta', async () => {
34
+ await start();
35
+
36
+ await fetch('http://localhost:3000/meta?token=6R0W53R135510').then(
37
+ async (res) => {
38
+ expect(res.headers.get('content-type')).to.equal(
39
+ 'application/json; charset=UTF-8',
40
+ );
41
+ expect(res.status).to.equal(200);
42
+ },
43
+ );
44
+ });
45
+
33
46
  it('allows requests to /metrics', async () => {
34
47
  await start();
35
48
 
package/src/types.ts CHANGED
@@ -661,6 +661,7 @@ export const BrowserlessWebKitRoutes = {
661
661
  export const BrowserlessManagementRoutes = {
662
662
  ActiveGetRoute: 'ActiveGetRoute',
663
663
  ConfigGetRoute: 'ConfigGetRoute',
664
+ MetaGetRoute: 'MetaGetRoute',
664
665
  MetricsGetRoute: 'MetricsGetRoute',
665
666
  MetricsTotalGetRoute: 'MetricsTotalGetRoute',
666
667
  PressureGetRoute: 'PressureGetRoute',
@@ -255,14 +255,14 @@
255
255
  "length": {
256
256
  "type": "number"
257
257
  },
258
- "__@toStringTag@14519": {
258
+ "__@toStringTag@14520": {
259
259
  "type": "string",
260
260
  "const": "Uint8Array"
261
261
  }
262
262
  },
263
263
  "required": [
264
264
  "BYTES_PER_ELEMENT",
265
- "__@toStringTag@14519",
265
+ "__@toStringTag@14520",
266
266
  "buffer",
267
267
  "byteLength",
268
268
  "byteOffset",
@@ -297,13 +297,13 @@
297
297
  "byteLength": {
298
298
  "type": "number"
299
299
  },
300
- "__@toStringTag@14519": {
300
+ "__@toStringTag@14520": {
301
301
  "type": "string"
302
302
  }
303
303
  },
304
304
  "additionalProperties": false,
305
305
  "required": [
306
- "__@toStringTag@14519",
306
+ "__@toStringTag@14520",
307
307
  "byteLength"
308
308
  ]
309
309
  },
@@ -313,18 +313,18 @@
313
313
  "byteLength": {
314
314
  "type": "number"
315
315
  },
316
- "__@species@14557": {
316
+ "__@species@14558": {
317
317
  "$ref": "#/definitions/SharedArrayBuffer"
318
318
  },
319
- "__@toStringTag@14519": {
319
+ "__@toStringTag@14520": {
320
320
  "type": "string",
321
321
  "const": "SharedArrayBuffer"
322
322
  }
323
323
  },
324
324
  "additionalProperties": false,
325
325
  "required": [
326
- "__@species@14557",
327
- "__@toStringTag@14519",
326
+ "__@species@14558",
327
+ "__@toStringTag@14520",
328
328
  "byteLength"
329
329
  ]
330
330
  },
@@ -969,7 +969,7 @@
969
969
  },
970
970
  "info": {
971
971
  "title": "Browserless",
972
- "version": "2.24.0-beta-3",
972
+ "version": "2.24.0-beta-4",
973
973
  "x-logo": {
974
974
  "altText": "browserless logo",
975
975
  "url": "./docs/browserless-logo-inline.svg"
@@ -5848,6 +5848,112 @@
5848
5848
  ]
5849
5849
  }
5850
5850
  },
5851
+ "/meta": {
5852
+ "get": {
5853
+ "definitions": {},
5854
+ "description": "Returns a JSON payload of the current system versions, including the core API version.",
5855
+ "parameters": [],
5856
+ "requestBody": {
5857
+ "content": {}
5858
+ },
5859
+ "responses": {
5860
+ "200": {
5861
+ "content": {
5862
+ "application/json": {
5863
+ "schema": {
5864
+ "type": "object",
5865
+ "properties": {
5866
+ "version": {
5867
+ "description": "The semantic version of the Browserless API",
5868
+ "type": "string"
5869
+ },
5870
+ "chromium": {
5871
+ "description": "The version of Chromium installed, or null if not installed",
5872
+ "type": [
5873
+ "null",
5874
+ "string"
5875
+ ]
5876
+ },
5877
+ "webkit": {
5878
+ "description": "The version of Webkit installed, or null if not installed",
5879
+ "type": [
5880
+ "null",
5881
+ "string"
5882
+ ]
5883
+ },
5884
+ "firefox": {
5885
+ "description": "The version of Firefox installed, or null if not installed",
5886
+ "type": [
5887
+ "null",
5888
+ "string"
5889
+ ]
5890
+ },
5891
+ "playwright": {
5892
+ "description": "The supported version(s) of puppeteer",
5893
+ "type": "array",
5894
+ "items": {
5895
+ "type": "string"
5896
+ }
5897
+ },
5898
+ "puppeteer": {
5899
+ "description": "The supported version(s) of playwright",
5900
+ "type": "array",
5901
+ "items": {
5902
+ "type": "string"
5903
+ }
5904
+ }
5905
+ },
5906
+ "additionalProperties": false,
5907
+ "required": [
5908
+ "chromium",
5909
+ "firefox",
5910
+ "playwright",
5911
+ "puppeteer",
5912
+ "version",
5913
+ "webkit"
5914
+ ],
5915
+ "$schema": "http://json-schema.org/draft-07/schema#"
5916
+ }
5917
+ }
5918
+ }
5919
+ },
5920
+ "400": {
5921
+ "code": 400,
5922
+ "description": "The request contains errors or didn't properly encode content.",
5923
+ "message": "HTTP/1.1 400 Bad Request"
5924
+ },
5925
+ "401": {
5926
+ "code": 401,
5927
+ "description": "The request is missing, or contains bad, authorization credentials.",
5928
+ "message": "HTTP/1.1 401 Unauthorized"
5929
+ },
5930
+ "404": {
5931
+ "code": 404,
5932
+ "description": "Resource couldn't be found.",
5933
+ "message": "HTTP/1.1 404 Not Found"
5934
+ },
5935
+ "408": {
5936
+ "code": 408,
5937
+ "description": "The request took has taken too long to process.",
5938
+ "message": "HTTP/1.1 408 Request Timeout"
5939
+ },
5940
+ "429": {
5941
+ "code": 429,
5942
+ "description": "Too many requests are currently being processed.",
5943
+ "message": "HTTP/1.1 429 Too Many Requests"
5944
+ },
5945
+ "500": {
5946
+ "code": 500,
5947
+ "description": "An internal error occurred when handling the request.",
5948
+ "message": "HTTP/1.1 500 Internal Server Error"
5949
+ }
5950
+ },
5951
+ "summary": "/meta",
5952
+ "tags": [
5953
+ "Management REST APIs"
5954
+ ]
5955
+ }
5956
+ },
5851
5957
  "/metrics/total": {
5852
5958
  "get": {
5853
5959
  "definitions": {},
@@ -255,14 +255,14 @@
255
255
  "length": {
256
256
  "type": "number"
257
257
  },
258
- "__@toStringTag@14519": {
258
+ "__@toStringTag@14520": {
259
259
  "type": "string",
260
260
  "const": "Uint8Array"
261
261
  }
262
262
  },
263
263
  "required": [
264
264
  "BYTES_PER_ELEMENT",
265
- "__@toStringTag@14519",
265
+ "__@toStringTag@14520",
266
266
  "buffer",
267
267
  "byteLength",
268
268
  "byteOffset",
@@ -297,13 +297,13 @@
297
297
  "byteLength": {
298
298
  "type": "number"
299
299
  },
300
- "__@toStringTag@14519": {
300
+ "__@toStringTag@14520": {
301
301
  "type": "string"
302
302
  }
303
303
  },
304
304
  "additionalProperties": false,
305
305
  "required": [
306
- "__@toStringTag@14519",
306
+ "__@toStringTag@14520",
307
307
  "byteLength"
308
308
  ]
309
309
  },
@@ -313,18 +313,18 @@
313
313
  "byteLength": {
314
314
  "type": "number"
315
315
  },
316
- "__@species@14557": {
316
+ "__@species@14558": {
317
317
  "$ref": "#/definitions/SharedArrayBuffer"
318
318
  },
319
- "__@toStringTag@14519": {
319
+ "__@toStringTag@14520": {
320
320
  "type": "string",
321
321
  "const": "SharedArrayBuffer"
322
322
  }
323
323
  },
324
324
  "additionalProperties": false,
325
325
  "required": [
326
- "__@species@14557",
327
- "__@toStringTag@14519",
326
+ "__@species@14558",
327
+ "__@toStringTag@14520",
328
328
  "byteLength"
329
329
  ]
330
330
  },
@@ -969,7 +969,7 @@
969
969
  },
970
970
  "info": {
971
971
  "title": "Browserless",
972
- "version": "2.24.0-beta-3",
972
+ "version": "2.24.0-beta-4",
973
973
  "x-logo": {
974
974
  "altText": "browserless logo",
975
975
  "url": "./docs/browserless-logo-inline.svg"
@@ -5847,6 +5847,112 @@
5847
5847
  ]
5848
5848
  }
5849
5849
  },
5850
+ "/meta": {
5851
+ "get": {
5852
+ "definitions": {},
5853
+ "description": "Returns a JSON payload of the current system versions, including the core API version.",
5854
+ "parameters": [],
5855
+ "requestBody": {
5856
+ "content": {}
5857
+ },
5858
+ "responses": {
5859
+ "200": {
5860
+ "content": {
5861
+ "application/json": {
5862
+ "schema": {
5863
+ "type": "object",
5864
+ "properties": {
5865
+ "version": {
5866
+ "description": "The semantic version of the Browserless API",
5867
+ "type": "string"
5868
+ },
5869
+ "chromium": {
5870
+ "description": "The version of Chromium installed, or null if not installed",
5871
+ "type": [
5872
+ "null",
5873
+ "string"
5874
+ ]
5875
+ },
5876
+ "webkit": {
5877
+ "description": "The version of Webkit installed, or null if not installed",
5878
+ "type": [
5879
+ "null",
5880
+ "string"
5881
+ ]
5882
+ },
5883
+ "firefox": {
5884
+ "description": "The version of Firefox installed, or null if not installed",
5885
+ "type": [
5886
+ "null",
5887
+ "string"
5888
+ ]
5889
+ },
5890
+ "playwright": {
5891
+ "description": "The supported version(s) of puppeteer",
5892
+ "type": "array",
5893
+ "items": {
5894
+ "type": "string"
5895
+ }
5896
+ },
5897
+ "puppeteer": {
5898
+ "description": "The supported version(s) of playwright",
5899
+ "type": "array",
5900
+ "items": {
5901
+ "type": "string"
5902
+ }
5903
+ }
5904
+ },
5905
+ "additionalProperties": false,
5906
+ "required": [
5907
+ "chromium",
5908
+ "firefox",
5909
+ "playwright",
5910
+ "puppeteer",
5911
+ "version",
5912
+ "webkit"
5913
+ ],
5914
+ "$schema": "http://json-schema.org/draft-07/schema#"
5915
+ }
5916
+ }
5917
+ }
5918
+ },
5919
+ "400": {
5920
+ "code": 400,
5921
+ "description": "The request contains errors or didn't properly encode content.",
5922
+ "message": "HTTP/1.1 400 Bad Request"
5923
+ },
5924
+ "401": {
5925
+ "code": 401,
5926
+ "description": "The request is missing, or contains bad, authorization credentials.",
5927
+ "message": "HTTP/1.1 401 Unauthorized"
5928
+ },
5929
+ "404": {
5930
+ "code": 404,
5931
+ "description": "Resource couldn't be found.",
5932
+ "message": "HTTP/1.1 404 Not Found"
5933
+ },
5934
+ "408": {
5935
+ "code": 408,
5936
+ "description": "The request took has taken too long to process.",
5937
+ "message": "HTTP/1.1 408 Request Timeout"
5938
+ },
5939
+ "429": {
5940
+ "code": 429,
5941
+ "description": "Too many requests are currently being processed.",
5942
+ "message": "HTTP/1.1 429 Too Many Requests"
5943
+ },
5944
+ "500": {
5945
+ "code": 500,
5946
+ "description": "An internal error occurred when handling the request.",
5947
+ "message": "HTTP/1.1 500 Internal Server Error"
5948
+ }
5949
+ },
5950
+ "summary": "/meta",
5951
+ "tags": [
5952
+ "Management REST APIs"
5953
+ ]
5954
+ }
5955
+ },
5850
5956
  "/metrics/total": {
5851
5957
  "get": {
5852
5958
  "definitions": {},