@platformatic/basic 3.25.0 → 3.27.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.
package/config.d.ts CHANGED
@@ -417,6 +417,62 @@ export interface PlatformaticBasicConfig {
417
417
  [k: string]: string | [string, ...string[]];
418
418
  };
419
419
  };
420
+ application?: {
421
+ reuseTcpPorts?: boolean;
422
+ workers?:
423
+ | number
424
+ | string
425
+ | {
426
+ static?: number;
427
+ minimum?: number;
428
+ maximum?: number;
429
+ [k: string]: unknown;
430
+ };
431
+ health?: {
432
+ enabled?: boolean | string;
433
+ interval?: number | string;
434
+ gracePeriod?: number | string;
435
+ maxUnhealthyChecks?: number | string;
436
+ maxELU?: number | string;
437
+ maxHeapUsed?: number | string;
438
+ maxHeapTotal?: number | string;
439
+ maxYoungGeneration?: number | string;
440
+ codeRangeSize?: number | string;
441
+ };
442
+ arguments?: string[];
443
+ env?: {
444
+ [k: string]: string;
445
+ };
446
+ envfile?: string;
447
+ sourceMaps?: boolean;
448
+ packageManager?: "npm" | "pnpm" | "yarn";
449
+ preload?: string | string[];
450
+ nodeOptions?: string;
451
+ execArgv?: string[];
452
+ permissions?: {
453
+ fs?: {
454
+ read?: string[];
455
+ write?: string[];
456
+ };
457
+ };
458
+ telemetry?: {
459
+ /**
460
+ * An array of instrumentations loaded if telemetry is enabled
461
+ */
462
+ instrumentations?: (
463
+ | string
464
+ | {
465
+ package: string;
466
+ exportName?: string;
467
+ options?: {
468
+ [k: string]: unknown;
469
+ };
470
+ [k: string]: unknown;
471
+ }
472
+ )[];
473
+ [k: string]: unknown;
474
+ };
475
+ };
420
476
  };
421
477
  [k: string]: unknown;
422
478
  }
package/lib/capability.js CHANGED
@@ -134,8 +134,6 @@ export class BaseCapability extends EventEmitter {
134
134
  return
135
135
  }
136
136
 
137
- // TODO@PI: Handle reusePort
138
-
139
137
  // Wait for explicit dependencies to start
140
138
  await this.waitForDependenciesStart(this.dependencies)
141
139
 
package/lib/utils.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { createRequire } from 'node:module'
2
- import { pathToFileURL } from 'node:url'
2
+ import { fileURLToPath, pathToFileURL } from 'node:url'
3
3
  import { request } from 'undici'
4
4
 
5
5
  export function getServerUrl (server) {
@@ -60,7 +60,7 @@ export function importFile (path) {
60
60
  }
61
61
 
62
62
  /* c8 ignore next 6 */
63
- export function resolvePackage (root, pkg) {
63
+ export function resolvePackageViaCJS (root, pkg) {
64
64
  const require = createRequire(root)
65
65
  // We need to add the main module paths to the require.resolve call
66
66
  // Note that `require.main` is not defined in `next` if we set sthe instrumentation hook reequired for ESM applications.
@@ -68,6 +68,18 @@ export function resolvePackage (root, pkg) {
68
68
  return require.resolve(pkg, { paths: [root, ...(require.main?.paths || [])] })
69
69
  }
70
70
 
71
+ /* c8 ignore next 14 */
72
+ export async function resolvePackageViaESM (root, pkg) {
73
+ // Use import.meta.resolve if available first, since it also understands ESM only packages
74
+ try {
75
+ const url = await import.meta.resolve(pkg)
76
+ return fileURLToPath(new URL(url))
77
+ } catch {
78
+ // Fallback to CJS resolution
79
+ return resolvePackageViaCJS(root, pkg)
80
+ }
81
+ }
82
+
71
83
  export function cleanBasePath (basePath) {
72
84
  return basePath ? `/${basePath}`.replaceAll(/\/+/g, '/').replace(/\/$/, '') : '/'
73
85
  }
@@ -75,3 +87,6 @@ export function cleanBasePath (basePath) {
75
87
  export function ensureTrailingSlash (basePath) {
76
88
  return basePath ? `${basePath}${basePath.endsWith('/') ? '' : '/'}` : '/'
77
89
  }
90
+
91
+ // TODO: This is for backwards compatibility, remove in future major release
92
+ export const resolvePackage = resolvePackageViaCJS
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platformatic/basic",
3
- "version": "3.25.0",
3
+ "version": "3.27.0",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -25,10 +25,10 @@
25
25
  "split2": "^4.2.0",
26
26
  "undici": "^7.0.0",
27
27
  "ws": "^8.18.0",
28
- "@platformatic/foundation": "3.25.0",
29
- "@platformatic/itc": "3.25.0",
30
- "@platformatic/metrics": "3.25.0",
31
- "@platformatic/telemetry": "3.25.0"
28
+ "@platformatic/foundation": "3.27.0",
29
+ "@platformatic/itc": "3.27.0",
30
+ "@platformatic/telemetry": "3.27.0",
31
+ "@platformatic/metrics": "3.27.0"
32
32
  },
33
33
  "devDependencies": {
34
34
  "cleaner-spec-reporter": "^0.5.0",
package/schema.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "$id": "https://schemas.platformatic.dev/@platformatic/basic/3.25.0.json",
2
+ "$id": "https://schemas.platformatic.dev/@platformatic/basic/3.27.0.json",
3
3
  "$schema": "http://json-schema.org/draft-07/schema#",
4
4
  "title": "Platformatic Basic Config",
5
5
  "type": "object",
@@ -257,6 +257,12 @@
257
257
  "nodeOptions": {
258
258
  "type": "string"
259
259
  },
260
+ "execArgv": {
261
+ "type": "array",
262
+ "items": {
263
+ "type": "string"
264
+ }
265
+ },
260
266
  "permissions": {
261
267
  "type": "object",
262
268
  "properties": {
@@ -1564,6 +1570,258 @@
1564
1570
  "deny"
1565
1571
  ],
1566
1572
  "additionalProperties": false
1573
+ },
1574
+ "application": {
1575
+ "type": "object",
1576
+ "properties": {
1577
+ "reuseTcpPorts": {
1578
+ "type": "boolean",
1579
+ "default": true
1580
+ },
1581
+ "workers": {
1582
+ "anyOf": [
1583
+ {
1584
+ "type": "number"
1585
+ },
1586
+ {
1587
+ "type": "string"
1588
+ },
1589
+ {
1590
+ "type": "object",
1591
+ "properties": {
1592
+ "static": {
1593
+ "type": "number",
1594
+ "minimum": 1
1595
+ },
1596
+ "minimum": {
1597
+ "type": "number",
1598
+ "minimum": 1
1599
+ },
1600
+ "maximum": {
1601
+ "type": "number",
1602
+ "minimum": 0
1603
+ }
1604
+ }
1605
+ }
1606
+ ]
1607
+ },
1608
+ "health": {
1609
+ "type": "object",
1610
+ "default": {},
1611
+ "properties": {
1612
+ "enabled": {
1613
+ "anyOf": [
1614
+ {
1615
+ "type": "boolean"
1616
+ },
1617
+ {
1618
+ "type": "string"
1619
+ }
1620
+ ]
1621
+ },
1622
+ "interval": {
1623
+ "anyOf": [
1624
+ {
1625
+ "type": "number",
1626
+ "minimum": 0
1627
+ },
1628
+ {
1629
+ "type": "string"
1630
+ }
1631
+ ]
1632
+ },
1633
+ "gracePeriod": {
1634
+ "anyOf": [
1635
+ {
1636
+ "type": "number",
1637
+ "minimum": 0
1638
+ },
1639
+ {
1640
+ "type": "string"
1641
+ }
1642
+ ]
1643
+ },
1644
+ "maxUnhealthyChecks": {
1645
+ "anyOf": [
1646
+ {
1647
+ "type": "number",
1648
+ "minimum": 1
1649
+ },
1650
+ {
1651
+ "type": "string"
1652
+ }
1653
+ ]
1654
+ },
1655
+ "maxELU": {
1656
+ "anyOf": [
1657
+ {
1658
+ "type": "number",
1659
+ "minimum": 0,
1660
+ "maximum": 1
1661
+ },
1662
+ {
1663
+ "type": "string"
1664
+ }
1665
+ ]
1666
+ },
1667
+ "maxHeapUsed": {
1668
+ "anyOf": [
1669
+ {
1670
+ "type": "number",
1671
+ "minimum": 0,
1672
+ "maximum": 1
1673
+ },
1674
+ {
1675
+ "type": "string"
1676
+ }
1677
+ ]
1678
+ },
1679
+ "maxHeapTotal": {
1680
+ "anyOf": [
1681
+ {
1682
+ "type": "number",
1683
+ "minimum": 0
1684
+ },
1685
+ {
1686
+ "type": "string"
1687
+ }
1688
+ ]
1689
+ },
1690
+ "maxYoungGeneration": {
1691
+ "anyOf": [
1692
+ {
1693
+ "type": "number",
1694
+ "minimum": 0
1695
+ },
1696
+ {
1697
+ "type": "string"
1698
+ }
1699
+ ]
1700
+ },
1701
+ "codeRangeSize": {
1702
+ "anyOf": [
1703
+ {
1704
+ "type": "number",
1705
+ "minimum": 0
1706
+ },
1707
+ {
1708
+ "type": "string"
1709
+ }
1710
+ ]
1711
+ }
1712
+ },
1713
+ "additionalProperties": false
1714
+ },
1715
+ "arguments": {
1716
+ "type": "array",
1717
+ "items": {
1718
+ "type": "string"
1719
+ }
1720
+ },
1721
+ "env": {
1722
+ "type": "object",
1723
+ "additionalProperties": {
1724
+ "type": "string"
1725
+ }
1726
+ },
1727
+ "envfile": {
1728
+ "type": "string"
1729
+ },
1730
+ "sourceMaps": {
1731
+ "type": "boolean"
1732
+ },
1733
+ "packageManager": {
1734
+ "type": "string",
1735
+ "enum": [
1736
+ "npm",
1737
+ "pnpm",
1738
+ "yarn"
1739
+ ]
1740
+ },
1741
+ "preload": {
1742
+ "anyOf": [
1743
+ {
1744
+ "type": "string",
1745
+ "resolvePath": true
1746
+ },
1747
+ {
1748
+ "type": "array",
1749
+ "items": {
1750
+ "type": "string",
1751
+ "resolvePath": true
1752
+ }
1753
+ }
1754
+ ]
1755
+ },
1756
+ "nodeOptions": {
1757
+ "type": "string"
1758
+ },
1759
+ "execArgv": {
1760
+ "type": "array",
1761
+ "items": {
1762
+ "type": "string"
1763
+ }
1764
+ },
1765
+ "permissions": {
1766
+ "type": "object",
1767
+ "properties": {
1768
+ "fs": {
1769
+ "type": "object",
1770
+ "properties": {
1771
+ "read": {
1772
+ "type": "array",
1773
+ "items": {
1774
+ "type": "string"
1775
+ }
1776
+ },
1777
+ "write": {
1778
+ "type": "array",
1779
+ "items": {
1780
+ "type": "string"
1781
+ }
1782
+ }
1783
+ },
1784
+ "additionalProperties": false
1785
+ }
1786
+ },
1787
+ "additionalProperties": false
1788
+ },
1789
+ "telemetry": {
1790
+ "type": "object",
1791
+ "properties": {
1792
+ "instrumentations": {
1793
+ "type": "array",
1794
+ "description": "An array of instrumentations loaded if telemetry is enabled",
1795
+ "items": {
1796
+ "oneOf": [
1797
+ {
1798
+ "type": "string"
1799
+ },
1800
+ {
1801
+ "type": "object",
1802
+ "properties": {
1803
+ "package": {
1804
+ "type": "string"
1805
+ },
1806
+ "exportName": {
1807
+ "type": "string"
1808
+ },
1809
+ "options": {
1810
+ "type": "object",
1811
+ "additionalProperties": true
1812
+ }
1813
+ },
1814
+ "required": [
1815
+ "package"
1816
+ ]
1817
+ }
1818
+ ]
1819
+ }
1820
+ }
1821
+ }
1822
+ }
1823
+ },
1824
+ "additionalProperties": false
1567
1825
  }
1568
1826
  },
1569
1827
  "additionalProperties": false