@adobe-commerce/aio-toolkit 1.0.12 → 1.0.13
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/CHANGELOG.md +37 -0
- package/dist/index.d.mts +3 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +136 -84
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +136 -84
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -5
- package/scripts/postinstall.js +0 -92
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,43 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [1.0.13] - 2026-01-07
|
|
9
|
+
|
|
10
|
+
### ✨ Features
|
|
11
|
+
|
|
12
|
+
- **feat(logging):** Enhanced action logging with structured data and customizable action type names
|
|
13
|
+
- Added `setActionTypeName()` and `getActionTypeName()` static methods to `RuntimeAction` for user-friendly log messages
|
|
14
|
+
- Implemented `JSON.stringify()` for complex object logging (headers, body, results) to properly handle arrays and nested structures
|
|
15
|
+
- Enhanced GraphQL action with comprehensive logging:
|
|
16
|
+
- Query parsing with parsed AST logging
|
|
17
|
+
- Validation failures with detailed error information
|
|
18
|
+
- Introspection check detection and logging
|
|
19
|
+
- Variables parsing and logging
|
|
20
|
+
- Updated all action types with consistent log message patterns:
|
|
21
|
+
- `RuntimeAction`: "Runtime action execution started/completed"
|
|
22
|
+
- `GraphQlAction`: "GraphQL action query parsed/validation failed"
|
|
23
|
+
- `OpenwhiskAction`: "OpenWhisk action execution started/completed"
|
|
24
|
+
- `EventConsumerAction`: "Event consumer action execution started/completed"
|
|
25
|
+
- Improved observability in New Relic with human-readable transaction names and structured logs
|
|
26
|
+
|
|
27
|
+
### 🔧 Maintenance
|
|
28
|
+
|
|
29
|
+
- **chore(scripts):** Removed deprecated `scripts/postinstall.js`
|
|
30
|
+
- Postinstall script no longer needed after telemetry package fixes
|
|
31
|
+
- Cleaner package structure without installation hooks
|
|
32
|
+
|
|
33
|
+
### 📝 Technical Details
|
|
34
|
+
|
|
35
|
+
- Enhanced `RuntimeAction` class with action type name customization
|
|
36
|
+
- Updated `GraphQlAction` to set custom action type name via `RuntimeAction.setActionTypeName('GraphQL action')`
|
|
37
|
+
- Modified logging format to use `JSON.stringify()` for headers, body, and result objects
|
|
38
|
+
- Added comprehensive test coverage for:
|
|
39
|
+
- Custom action type names
|
|
40
|
+
- JSON.stringify logging format
|
|
41
|
+
- Missing headers and body graceful handling
|
|
42
|
+
- All 1902 tests passing with 100% coverage maintained
|
|
43
|
+
- No breaking changes - purely additive enhancements with backward compatibility
|
|
44
|
+
|
|
8
45
|
## [1.0.12] - 2026-01-06
|
|
9
46
|
|
|
10
47
|
### ✨ Features
|
package/dist/index.d.mts
CHANGED
|
@@ -43,8 +43,11 @@ type RuntimeActionResponseType = SuccessResponse | ErrorResponse;
|
|
|
43
43
|
|
|
44
44
|
declare class RuntimeAction {
|
|
45
45
|
private static actionType;
|
|
46
|
+
private static actionTypeName;
|
|
46
47
|
static setActionType(type: string): void;
|
|
47
48
|
static getActionType(): string;
|
|
49
|
+
static setActionTypeName(name: string): void;
|
|
50
|
+
static getActionTypeName(): string;
|
|
48
51
|
static execute(name?: string, httpMethods?: HttpMethod[], requiredParams?: string[], requiredHeaders?: string[], action?: (params: {
|
|
49
52
|
[key: string]: any;
|
|
50
53
|
}, ctx: {
|
package/dist/index.d.ts
CHANGED
|
@@ -43,8 +43,11 @@ type RuntimeActionResponseType = SuccessResponse | ErrorResponse;
|
|
|
43
43
|
|
|
44
44
|
declare class RuntimeAction {
|
|
45
45
|
private static actionType;
|
|
46
|
+
private static actionTypeName;
|
|
46
47
|
static setActionType(type: string): void;
|
|
47
48
|
static getActionType(): string;
|
|
49
|
+
static setActionTypeName(name: string): void;
|
|
50
|
+
static getActionTypeName(): string;
|
|
48
51
|
static execute(name?: string, httpMethods?: HttpMethod[], requiredParams?: string[], requiredHeaders?: string[], action?: (params: {
|
|
49
52
|
[key: string]: any;
|
|
50
53
|
}, ctx: {
|
package/dist/index.js
CHANGED
|
@@ -1557,6 +1557,23 @@ var _RuntimeAction = class _RuntimeAction {
|
|
|
1557
1557
|
static getActionType() {
|
|
1558
1558
|
return _RuntimeAction.actionType;
|
|
1559
1559
|
}
|
|
1560
|
+
/**
|
|
1561
|
+
* Sets the action type name for the next action execution
|
|
1562
|
+
* This is used for logging to identify different action types
|
|
1563
|
+
* (runtime-action, webhook-action, event-consumer-action, etc.)
|
|
1564
|
+
*
|
|
1565
|
+
* @param name - The action type name identifier
|
|
1566
|
+
*/
|
|
1567
|
+
static setActionTypeName(name) {
|
|
1568
|
+
_RuntimeAction.actionTypeName = name;
|
|
1569
|
+
}
|
|
1570
|
+
/**
|
|
1571
|
+
* Gets the current action type name
|
|
1572
|
+
* @returns The current action type name identifier
|
|
1573
|
+
*/
|
|
1574
|
+
static getActionTypeName() {
|
|
1575
|
+
return _RuntimeAction.actionTypeName;
|
|
1576
|
+
}
|
|
1560
1577
|
/**
|
|
1561
1578
|
* Creates a runtime action handler with validation, logging, and telemetry
|
|
1562
1579
|
*
|
|
@@ -1617,17 +1634,20 @@ var _RuntimeAction = class _RuntimeAction {
|
|
|
1617
1634
|
const logger = telemetry_default.createLogger(name, params);
|
|
1618
1635
|
try {
|
|
1619
1636
|
logger.debug({
|
|
1620
|
-
message: `${
|
|
1621
|
-
action_name: name
|
|
1622
|
-
});
|
|
1623
|
-
logger.debug({
|
|
1624
|
-
message: `${name}-headers`,
|
|
1625
|
-
headers: params.__ow_headers || {}
|
|
1626
|
-
});
|
|
1627
|
-
logger.debug({
|
|
1628
|
-
message: `${name}-body`,
|
|
1629
|
-
body: params.__ow_body || {}
|
|
1637
|
+
message: `${_RuntimeAction.getActionTypeName()} execution started`
|
|
1630
1638
|
});
|
|
1639
|
+
logger.debug(
|
|
1640
|
+
JSON.stringify({
|
|
1641
|
+
message: `${_RuntimeAction.getActionTypeName()} headers received`,
|
|
1642
|
+
headers: params.__ow_headers || {}
|
|
1643
|
+
})
|
|
1644
|
+
);
|
|
1645
|
+
logger.debug(
|
|
1646
|
+
JSON.stringify({
|
|
1647
|
+
message: `${_RuntimeAction.getActionTypeName()} body received`,
|
|
1648
|
+
body: params.__ow_body || {}
|
|
1649
|
+
})
|
|
1650
|
+
);
|
|
1631
1651
|
const validationError = _RuntimeAction.validateRequest(
|
|
1632
1652
|
params,
|
|
1633
1653
|
requiredParams,
|
|
@@ -1640,21 +1660,23 @@ var _RuntimeAction = class _RuntimeAction {
|
|
|
1640
1660
|
return validationError;
|
|
1641
1661
|
}
|
|
1642
1662
|
const result = await action(params, { logger, headers: params.__ow_headers || {} });
|
|
1643
|
-
logger.debug(
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1663
|
+
logger.debug(
|
|
1664
|
+
JSON.stringify({
|
|
1665
|
+
message: `${_RuntimeAction.getActionTypeName()} execution completed`,
|
|
1666
|
+
result
|
|
1667
|
+
})
|
|
1668
|
+
);
|
|
1647
1669
|
return result;
|
|
1648
1670
|
} catch (error) {
|
|
1649
1671
|
if (error instanceof Error) {
|
|
1650
1672
|
logger.error({
|
|
1651
|
-
message: `${
|
|
1673
|
+
message: `${_RuntimeAction.getActionTypeName()} execution failed`,
|
|
1652
1674
|
error: error.message,
|
|
1653
1675
|
stack: error.stack
|
|
1654
1676
|
});
|
|
1655
1677
|
} else {
|
|
1656
1678
|
logger.error({
|
|
1657
|
-
message: `${
|
|
1679
|
+
message: `${_RuntimeAction.getActionTypeName()} execution failed`,
|
|
1658
1680
|
error
|
|
1659
1681
|
});
|
|
1660
1682
|
}
|
|
@@ -1696,11 +1718,11 @@ var _RuntimeAction = class _RuntimeAction {
|
|
|
1696
1718
|
* }
|
|
1697
1719
|
* ```
|
|
1698
1720
|
*/
|
|
1699
|
-
static validateRequest(params, requiredParams, requiredHeaders, httpMethods, logger,
|
|
1721
|
+
static validateRequest(params, requiredParams, requiredHeaders, httpMethods, logger, _name) {
|
|
1700
1722
|
const errorMessage = validator_default.checkMissingRequestInputs(params, requiredParams, requiredHeaders) ?? "";
|
|
1701
1723
|
if (errorMessage) {
|
|
1702
1724
|
logger.error({
|
|
1703
|
-
message: `${
|
|
1725
|
+
message: `${_RuntimeAction.getActionTypeName()} validation failed`,
|
|
1704
1726
|
error: errorMessage
|
|
1705
1727
|
});
|
|
1706
1728
|
return response_default.error(400 /* BAD_REQUEST */, errorMessage);
|
|
@@ -1709,7 +1731,7 @@ var _RuntimeAction = class _RuntimeAction {
|
|
|
1709
1731
|
if (httpMethods.length > 0 && !httpMethods.includes(requestMethod)) {
|
|
1710
1732
|
const errorMessage2 = `Invalid HTTP method: ${params.__ow_method}. Allowed methods are: ${httpMethods.join(", ")}`;
|
|
1711
1733
|
logger.error({
|
|
1712
|
-
message: `${
|
|
1734
|
+
message: `${_RuntimeAction.getActionTypeName()} validation failed`,
|
|
1713
1735
|
error: errorMessage2
|
|
1714
1736
|
});
|
|
1715
1737
|
return response_default.error(405 /* METHOD_NOT_ALLOWED */, errorMessage2);
|
|
@@ -1723,6 +1745,11 @@ __name(_RuntimeAction, "RuntimeAction");
|
|
|
1723
1745
|
* Can be set using setActionType() before calling execute()
|
|
1724
1746
|
*/
|
|
1725
1747
|
_RuntimeAction.actionType = "runtime-action";
|
|
1748
|
+
/**
|
|
1749
|
+
* Private static property to store the action type name for logging
|
|
1750
|
+
* Can be set using setActionTypeName() before calling execute()
|
|
1751
|
+
*/
|
|
1752
|
+
_RuntimeAction.actionTypeName = "Runtime action";
|
|
1726
1753
|
var RuntimeAction = _RuntimeAction;
|
|
1727
1754
|
var runtime_action_default = RuntimeAction;
|
|
1728
1755
|
|
|
@@ -1790,28 +1817,27 @@ var _EventConsumerAction = class _EventConsumerAction {
|
|
|
1790
1817
|
const logger = telemetry_default.createLogger(name, params);
|
|
1791
1818
|
try {
|
|
1792
1819
|
logger.debug({
|
|
1793
|
-
message:
|
|
1794
|
-
action_name: name
|
|
1820
|
+
message: "Event consumer action execution started"
|
|
1795
1821
|
});
|
|
1796
1822
|
logger.debug({
|
|
1797
|
-
message:
|
|
1823
|
+
message: "Event consumer action headers received",
|
|
1798
1824
|
headers: params.__ow_headers || {}
|
|
1799
1825
|
});
|
|
1800
1826
|
logger.debug({
|
|
1801
|
-
message:
|
|
1827
|
+
message: "Event consumer action parameters received",
|
|
1802
1828
|
parameters: params
|
|
1803
1829
|
});
|
|
1804
1830
|
const errorMessage = validator_default.checkMissingRequestInputs(params, requiredParams, requiredHeaders) || "";
|
|
1805
1831
|
if (errorMessage) {
|
|
1806
1832
|
logger.error({
|
|
1807
|
-
message:
|
|
1833
|
+
message: "Event consumer action validation failed",
|
|
1808
1834
|
error: errorMessage
|
|
1809
1835
|
});
|
|
1810
1836
|
return response_default.error(400 /* BAD_REQUEST */, errorMessage);
|
|
1811
1837
|
}
|
|
1812
1838
|
const result = await action(params, { logger, headers: params.__ow_headers || {} });
|
|
1813
1839
|
logger.debug({
|
|
1814
|
-
message:
|
|
1840
|
+
message: "Event consumer action execution completed",
|
|
1815
1841
|
result
|
|
1816
1842
|
});
|
|
1817
1843
|
return result;
|
|
@@ -1846,65 +1872,91 @@ var _GraphQlAction = class _GraphQlAction {
|
|
|
1846
1872
|
hello: /* @__PURE__ */ __name(() => "Hello World!", "hello")
|
|
1847
1873
|
};
|
|
1848
1874
|
}, name = "main", disableIntrospection = false) {
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1875
|
+
runtime_action_default.setActionType("graphql-action");
|
|
1876
|
+
runtime_action_default.setActionTypeName("GraphQL action");
|
|
1877
|
+
const callback = /* @__PURE__ */ __name(async (params, ctx) => {
|
|
1878
|
+
const { logger } = ctx;
|
|
1879
|
+
let graphqlSchema;
|
|
1880
|
+
try {
|
|
1881
|
+
graphqlSchema = (0, import_graphql.buildSchema)(schema);
|
|
1882
|
+
} catch (error) {
|
|
1883
|
+
return response_default.error(400 /* BAD_REQUEST */, error.message);
|
|
1884
|
+
}
|
|
1885
|
+
const graphqlResolvers = await resolvers({
|
|
1886
|
+
...ctx,
|
|
1887
|
+
...{
|
|
1888
|
+
params
|
|
1860
1889
|
}
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1890
|
+
});
|
|
1891
|
+
const context2 = {};
|
|
1892
|
+
const query = params.query;
|
|
1893
|
+
let parsedQuery;
|
|
1894
|
+
try {
|
|
1895
|
+
parsedQuery = (0, import_graphql.parse)(query);
|
|
1896
|
+
} catch (error) {
|
|
1897
|
+
return response_default.error(400 /* BAD_REQUEST */, error.message);
|
|
1898
|
+
}
|
|
1899
|
+
logger.debug(
|
|
1900
|
+
JSON.stringify({
|
|
1901
|
+
message: "GraphQL action query parsed",
|
|
1902
|
+
query: parsedQuery
|
|
1903
|
+
})
|
|
1904
|
+
);
|
|
1905
|
+
const validationErrors = (0, import_graphql.validate)(graphqlSchema, parsedQuery);
|
|
1906
|
+
if (validationErrors.length) {
|
|
1907
|
+
logger.error({
|
|
1908
|
+
message: "GraphQL action query validation failed",
|
|
1909
|
+
errors: validationErrors
|
|
1866
1910
|
});
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1911
|
+
return response_default.error(
|
|
1912
|
+
400 /* BAD_REQUEST */,
|
|
1913
|
+
validationErrors.map((err) => err.message).join(", ")
|
|
1914
|
+
);
|
|
1915
|
+
}
|
|
1916
|
+
if (disableIntrospection) {
|
|
1917
|
+
logger.debug({
|
|
1918
|
+
message: "GraphQL action introspection check disabled"
|
|
1919
|
+
});
|
|
1920
|
+
const isIntrospectionQuery = parsedQuery.definitions.some(
|
|
1921
|
+
(definition) => definition.selectionSet.selections.some(
|
|
1922
|
+
(selection) => selection.name.value.startsWith("__")
|
|
1923
|
+
)
|
|
1924
|
+
);
|
|
1925
|
+
if (isIntrospectionQuery) {
|
|
1926
|
+
logger.error({
|
|
1927
|
+
message: "GraphQL action introspection query detected",
|
|
1928
|
+
query: parsedQuery
|
|
1929
|
+
});
|
|
1877
1930
|
return response_default.error(
|
|
1878
1931
|
400 /* BAD_REQUEST */,
|
|
1879
|
-
|
|
1932
|
+
"Introspection is disabled for security reasons."
|
|
1880
1933
|
);
|
|
1881
1934
|
}
|
|
1882
|
-
if (disableIntrospection) {
|
|
1883
|
-
const isIntrospectionQuery = parsedQuery.definitions.some(
|
|
1884
|
-
(definition) => definition.selectionSet.selections.some(
|
|
1885
|
-
(selection) => selection.name.value.startsWith("__")
|
|
1886
|
-
)
|
|
1887
|
-
);
|
|
1888
|
-
if (isIntrospectionQuery) {
|
|
1889
|
-
return response_default.error(
|
|
1890
|
-
400 /* BAD_REQUEST */,
|
|
1891
|
-
"Introspection is disabled for security reasons."
|
|
1892
|
-
);
|
|
1893
|
-
}
|
|
1894
|
-
}
|
|
1895
|
-
const variables = typeof params.variables === "string" ? JSON.parse(params.variables) : params.variables;
|
|
1896
|
-
return response_default.success(
|
|
1897
|
-
await (0, import_graphql.graphql)({
|
|
1898
|
-
schema: graphqlSchema,
|
|
1899
|
-
source: query,
|
|
1900
|
-
rootValue: graphqlResolvers,
|
|
1901
|
-
contextValue: context2,
|
|
1902
|
-
variableValues: variables,
|
|
1903
|
-
operationName: params.operationName
|
|
1904
|
-
})
|
|
1905
|
-
);
|
|
1906
1935
|
}
|
|
1936
|
+
const variables = typeof params.variables === "string" ? JSON.parse(params.variables) : params.variables;
|
|
1937
|
+
logger.debug({
|
|
1938
|
+
message: "GraphQL action variables parsed",
|
|
1939
|
+
variables
|
|
1940
|
+
});
|
|
1941
|
+
return response_default.success(
|
|
1942
|
+
await (0, import_graphql.graphql)({
|
|
1943
|
+
schema: graphqlSchema,
|
|
1944
|
+
source: query,
|
|
1945
|
+
rootValue: graphqlResolvers,
|
|
1946
|
+
contextValue: context2,
|
|
1947
|
+
variableValues: variables,
|
|
1948
|
+
operationName: params.operationName
|
|
1949
|
+
})
|
|
1950
|
+
);
|
|
1951
|
+
}, "callback");
|
|
1952
|
+
const graphqlAction = runtime_action_default.execute(
|
|
1953
|
+
`graphql-${name}`,
|
|
1954
|
+
["GET" /* GET */, "POST" /* POST */],
|
|
1955
|
+
["query"],
|
|
1956
|
+
[],
|
|
1957
|
+
callback
|
|
1907
1958
|
);
|
|
1959
|
+
return telemetry_default.initialize(graphqlAction);
|
|
1908
1960
|
}
|
|
1909
1961
|
};
|
|
1910
1962
|
__name(_GraphQlAction, "GraphQlAction");
|
|
@@ -1991,29 +2043,28 @@ var _OpenwhiskAction = class _OpenwhiskAction {
|
|
|
1991
2043
|
const logger = telemetry_default.createLogger(name, params);
|
|
1992
2044
|
try {
|
|
1993
2045
|
logger.debug({
|
|
1994
|
-
message:
|
|
1995
|
-
action_name: name
|
|
2046
|
+
message: "OpenWhisk action execution started"
|
|
1996
2047
|
});
|
|
1997
2048
|
logger.debug({
|
|
1998
|
-
message:
|
|
2049
|
+
message: "OpenWhisk action parameters received",
|
|
1999
2050
|
params
|
|
2000
2051
|
});
|
|
2001
2052
|
const result = await action(params, { logger, headers: params.__ow_headers || {} });
|
|
2002
2053
|
logger.debug({
|
|
2003
|
-
message:
|
|
2054
|
+
message: "OpenWhisk action execution completed",
|
|
2004
2055
|
result
|
|
2005
2056
|
});
|
|
2006
2057
|
return result;
|
|
2007
2058
|
} catch (error) {
|
|
2008
2059
|
if (error instanceof Error) {
|
|
2009
2060
|
logger.error({
|
|
2010
|
-
message:
|
|
2061
|
+
message: "OpenWhisk action execution failed",
|
|
2011
2062
|
error: error.message,
|
|
2012
2063
|
stack: error.stack
|
|
2013
2064
|
});
|
|
2014
2065
|
} else {
|
|
2015
2066
|
logger.error({
|
|
2016
|
-
message:
|
|
2067
|
+
message: "OpenWhisk action execution failed",
|
|
2017
2068
|
error
|
|
2018
2069
|
});
|
|
2019
2070
|
}
|
|
@@ -2578,7 +2629,7 @@ var _WebhookAction = class _WebhookAction {
|
|
|
2578
2629
|
const verificationErrorMessage = await verifySignature(params);
|
|
2579
2630
|
if (verificationErrorMessage) {
|
|
2580
2631
|
logger.error({
|
|
2581
|
-
message:
|
|
2632
|
+
message: "Webhook actionsignature verification failed",
|
|
2582
2633
|
error: verificationErrorMessage
|
|
2583
2634
|
});
|
|
2584
2635
|
const verificationErrorResponse = response_default2.exception(verificationErrorMessage);
|
|
@@ -2592,7 +2643,7 @@ var _WebhookAction = class _WebhookAction {
|
|
|
2592
2643
|
const errorMessage = validator_default.checkMissingRequestInputs(params, requiredParams, requiredHeaders) ?? "";
|
|
2593
2644
|
if (errorMessage) {
|
|
2594
2645
|
logger.error({
|
|
2595
|
-
message:
|
|
2646
|
+
message: "Webhook action validation failed",
|
|
2596
2647
|
error: errorMessage
|
|
2597
2648
|
});
|
|
2598
2649
|
const errorMessageResponse = response_default2.exception(errorMessage);
|
|
@@ -2602,6 +2653,7 @@ var _WebhookAction = class _WebhookAction {
|
|
|
2602
2653
|
return response_default.success(JSON.stringify(response));
|
|
2603
2654
|
}, "callback");
|
|
2604
2655
|
runtime_action_default.setActionType("webhook-action");
|
|
2656
|
+
runtime_action_default.setActionTypeName("Webhook action");
|
|
2605
2657
|
return runtime_action_default.execute(name, httpMethods, [], [], callback);
|
|
2606
2658
|
}
|
|
2607
2659
|
};
|