@adobe-commerce/aio-toolkit 1.0.11 → 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 +71 -0
- package/dist/index.d.mts +9 -2
- package/dist/index.d.ts +9 -2
- package/dist/index.js +146 -89
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +146 -89
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -5
- package/scripts/postinstall.js +0 -105
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,77 @@ 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
|
+
|
|
45
|
+
## [1.0.12] - 2026-01-06
|
|
46
|
+
|
|
47
|
+
### ✨ Features
|
|
48
|
+
|
|
49
|
+
- **feat(openwhisk):** Add configurable blocking parameter to execute method
|
|
50
|
+
- Created `OpenwhiskConfig` interface with optional `blocking` parameter
|
|
51
|
+
- Updated `Openwhisk.execute()` to accept optional config parameter
|
|
52
|
+
- Default `blocking` value is `true` for backward compatibility
|
|
53
|
+
- Allows non-blocking action execution when `blocking: false` is specified
|
|
54
|
+
- Enhanced JSDoc documentation with parameter descriptions
|
|
55
|
+
- Exported `OpenwhiskConfig` type from framework module for TypeScript users
|
|
56
|
+
|
|
57
|
+
### 🐛 Bug Fixes
|
|
58
|
+
|
|
59
|
+
- **fix(postinstall):** Simplified postinstall script to use Node.js built-in module resolution
|
|
60
|
+
- Replaced complex relative path logic with `require.resolve()` for automatic absolute path resolution
|
|
61
|
+
- Reduced script complexity from 20+ lines of path logic to 6 lines using Node's module resolution
|
|
62
|
+
- More reliable package detection that works in all Node.js environments
|
|
63
|
+
- Fixes issue where postinstall script couldn't find telemetry package in client projects
|
|
64
|
+
- Script now uses `require.resolve('@adobe/aio-lib-telemetry/package.json')` for automatic path handling
|
|
65
|
+
- Eliminated fragile relative path calculations (`../../../`) that depended on specific directory structures
|
|
66
|
+
- Works seamlessly across npm, yarn, pnpm, and different installation scenarios
|
|
67
|
+
|
|
68
|
+
### 📝 Technical Details
|
|
69
|
+
|
|
70
|
+
- Created `src/framework/openwhisk/types.ts` with `OpenwhiskConfig` interface
|
|
71
|
+
- Updated `Openwhisk.execute()` method signature to support configuration options
|
|
72
|
+
- Simplified `scripts/postinstall.js` from 108 lines to 93 lines
|
|
73
|
+
- Replaced manual path construction with Node's native module resolution algorithm
|
|
74
|
+
- More maintainable and robust solution that leverages Node.js built-in capabilities
|
|
75
|
+
- Script now works correctly whether telemetry is installed as direct dependency or peer dependency
|
|
76
|
+
- Automatic handling of hoisted vs nested node_modules structures
|
|
77
|
+
- All validations passed: type-check, linting, tests (1679+), and build
|
|
78
|
+
|
|
8
79
|
## [1.0.11] - 2026-01-04
|
|
9
80
|
|
|
10
81
|
### 🐛 Bug Fixes
|
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: {
|
|
@@ -107,10 +110,14 @@ declare class GraphQlAction {
|
|
|
107
110
|
}) => Promise<RuntimeActionResponseType>;
|
|
108
111
|
}
|
|
109
112
|
|
|
113
|
+
interface OpenwhiskConfig {
|
|
114
|
+
blocking?: boolean;
|
|
115
|
+
}
|
|
116
|
+
|
|
110
117
|
declare class Openwhisk {
|
|
111
118
|
openwhiskClient: ReturnType<typeof openwhisk>;
|
|
112
119
|
constructor(host: string, apiKey: string);
|
|
113
|
-
execute(action: string, params: Dict): Promise<Activation<Dict>>;
|
|
120
|
+
execute(action: string, params: Dict, config?: OpenwhiskConfig): Promise<Activation<Dict>>;
|
|
114
121
|
}
|
|
115
122
|
|
|
116
123
|
declare class OpenwhiskAction {
|
|
@@ -955,4 +962,4 @@ declare class AdminUiSdk {
|
|
|
955
962
|
getRegistration(): AdminUiSdkRegistration;
|
|
956
963
|
}
|
|
957
964
|
|
|
958
|
-
export { AdminUiSdk, type AdminUiSdkRegistration, AdobeAuth, AdobeCommerceClient, type AdobeIMSConfig, type BaseTelemetry, type BaseTelemetryValidator, BasicAuthConnection, BearerToken, type BearerTokenInfo, type CommerceEvent, type CommerceEventConfig, type CommerceEventField, type Connection, type CreateEventResult, CreateEvents, type CreateProviderParams, type CreateProviderResult, type CreateRegistrationResult, CreateRegistrations, type ErrorResponse, EventConsumerAction, type EventData, type EventMetadata, type EventMetadataInputModel, type EventMetadataListResponse, EventMetadataManager, type ExtendedRequestError, type FileMetadata, type FileRecord, FileRepository, GenerateBasicAuthToken, type GetProviderQueryParams, type GetRegistrationQueryParams, GraphQlAction, type HALLink, type Headers, HttpMethod, HttpStatus, IOEventsApiError, type IOEventsError, ImsConnection, ImsToken, type ImsTokenResult, InfiniteLoopBreaker, type InfiniteLoopData, IoEventsGlobals, JsonMessageProcessor, type ListProvidersQueryParams, type ListRegistrationQueryParams, type MenuItem, Oauth1aConnection, OnboardCommerce, type OnboardCommerceConfig, type OnboardCommerceResult, OnboardEvents, type OnboardEventsInput, type OnboardEventsResponse, OnboardEvents as OnboardIOEvents, Openwhisk, OpenwhiskAction, type Page, Parameters, type Provider, type ProviderInputModel, ProviderManager, PublishEvent, type PublishEventResult, type Registration, type RegistrationCreateModel, type RegistrationListResponse, RegistrationManager, RestClient, RuntimeAction, RuntimeActionResponse, type RuntimeActionResponseType, RuntimeApiGatewayService, ShippingCarrier, type ShippingCarrierData, ShippingCarrierMethod, type ShippingCarrierMethodAdditionalData, type ShippingCarrierMethodData, ShippingCarrierResponse, SignatureVerification, SuccessChecker, type SuccessResponse, Telemetry, TelemetryInputError, type TokenResult, Validator, WebhookAction, type WebhookActionAddResponse, type WebhookActionExceptionResponse, WebhookActionOperation, type WebhookActionRemoveResponse, type WebhookActionReplaceResponse, WebhookActionResponse, type WebhookActionResponseType, type WebhookActionSuccessResponse, type WorkspaceConfig };
|
|
965
|
+
export { AdminUiSdk, type AdminUiSdkRegistration, AdobeAuth, AdobeCommerceClient, type AdobeIMSConfig, type BaseTelemetry, type BaseTelemetryValidator, BasicAuthConnection, BearerToken, type BearerTokenInfo, type CommerceEvent, type CommerceEventConfig, type CommerceEventField, type Connection, type CreateEventResult, CreateEvents, type CreateProviderParams, type CreateProviderResult, type CreateRegistrationResult, CreateRegistrations, type ErrorResponse, EventConsumerAction, type EventData, type EventMetadata, type EventMetadataInputModel, type EventMetadataListResponse, EventMetadataManager, type ExtendedRequestError, type FileMetadata, type FileRecord, FileRepository, GenerateBasicAuthToken, type GetProviderQueryParams, type GetRegistrationQueryParams, GraphQlAction, type HALLink, type Headers, HttpMethod, HttpStatus, IOEventsApiError, type IOEventsError, ImsConnection, ImsToken, type ImsTokenResult, InfiniteLoopBreaker, type InfiniteLoopData, IoEventsGlobals, JsonMessageProcessor, type ListProvidersQueryParams, type ListRegistrationQueryParams, type MenuItem, Oauth1aConnection, OnboardCommerce, type OnboardCommerceConfig, type OnboardCommerceResult, OnboardEvents, type OnboardEventsInput, type OnboardEventsResponse, OnboardEvents as OnboardIOEvents, Openwhisk, OpenwhiskAction, type OpenwhiskConfig, type Page, Parameters, type Provider, type ProviderInputModel, ProviderManager, PublishEvent, type PublishEventResult, type Registration, type RegistrationCreateModel, type RegistrationListResponse, RegistrationManager, RestClient, RuntimeAction, RuntimeActionResponse, type RuntimeActionResponseType, RuntimeApiGatewayService, ShippingCarrier, type ShippingCarrierData, ShippingCarrierMethod, type ShippingCarrierMethodAdditionalData, type ShippingCarrierMethodData, ShippingCarrierResponse, SignatureVerification, SuccessChecker, type SuccessResponse, Telemetry, TelemetryInputError, type TokenResult, Validator, WebhookAction, type WebhookActionAddResponse, type WebhookActionExceptionResponse, WebhookActionOperation, type WebhookActionRemoveResponse, type WebhookActionReplaceResponse, WebhookActionResponse, type WebhookActionResponseType, type WebhookActionSuccessResponse, type WorkspaceConfig };
|
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: {
|
|
@@ -107,10 +110,14 @@ declare class GraphQlAction {
|
|
|
107
110
|
}) => Promise<RuntimeActionResponseType>;
|
|
108
111
|
}
|
|
109
112
|
|
|
113
|
+
interface OpenwhiskConfig {
|
|
114
|
+
blocking?: boolean;
|
|
115
|
+
}
|
|
116
|
+
|
|
110
117
|
declare class Openwhisk {
|
|
111
118
|
openwhiskClient: ReturnType<typeof openwhisk>;
|
|
112
119
|
constructor(host: string, apiKey: string);
|
|
113
|
-
execute(action: string, params: Dict): Promise<Activation<Dict>>;
|
|
120
|
+
execute(action: string, params: Dict, config?: OpenwhiskConfig): Promise<Activation<Dict>>;
|
|
114
121
|
}
|
|
115
122
|
|
|
116
123
|
declare class OpenwhiskAction {
|
|
@@ -955,4 +962,4 @@ declare class AdminUiSdk {
|
|
|
955
962
|
getRegistration(): AdminUiSdkRegistration;
|
|
956
963
|
}
|
|
957
964
|
|
|
958
|
-
export { AdminUiSdk, type AdminUiSdkRegistration, AdobeAuth, AdobeCommerceClient, type AdobeIMSConfig, type BaseTelemetry, type BaseTelemetryValidator, BasicAuthConnection, BearerToken, type BearerTokenInfo, type CommerceEvent, type CommerceEventConfig, type CommerceEventField, type Connection, type CreateEventResult, CreateEvents, type CreateProviderParams, type CreateProviderResult, type CreateRegistrationResult, CreateRegistrations, type ErrorResponse, EventConsumerAction, type EventData, type EventMetadata, type EventMetadataInputModel, type EventMetadataListResponse, EventMetadataManager, type ExtendedRequestError, type FileMetadata, type FileRecord, FileRepository, GenerateBasicAuthToken, type GetProviderQueryParams, type GetRegistrationQueryParams, GraphQlAction, type HALLink, type Headers, HttpMethod, HttpStatus, IOEventsApiError, type IOEventsError, ImsConnection, ImsToken, type ImsTokenResult, InfiniteLoopBreaker, type InfiniteLoopData, IoEventsGlobals, JsonMessageProcessor, type ListProvidersQueryParams, type ListRegistrationQueryParams, type MenuItem, Oauth1aConnection, OnboardCommerce, type OnboardCommerceConfig, type OnboardCommerceResult, OnboardEvents, type OnboardEventsInput, type OnboardEventsResponse, OnboardEvents as OnboardIOEvents, Openwhisk, OpenwhiskAction, type Page, Parameters, type Provider, type ProviderInputModel, ProviderManager, PublishEvent, type PublishEventResult, type Registration, type RegistrationCreateModel, type RegistrationListResponse, RegistrationManager, RestClient, RuntimeAction, RuntimeActionResponse, type RuntimeActionResponseType, RuntimeApiGatewayService, ShippingCarrier, type ShippingCarrierData, ShippingCarrierMethod, type ShippingCarrierMethodAdditionalData, type ShippingCarrierMethodData, ShippingCarrierResponse, SignatureVerification, SuccessChecker, type SuccessResponse, Telemetry, TelemetryInputError, type TokenResult, Validator, WebhookAction, type WebhookActionAddResponse, type WebhookActionExceptionResponse, WebhookActionOperation, type WebhookActionRemoveResponse, type WebhookActionReplaceResponse, WebhookActionResponse, type WebhookActionResponseType, type WebhookActionSuccessResponse, type WorkspaceConfig };
|
|
965
|
+
export { AdminUiSdk, type AdminUiSdkRegistration, AdobeAuth, AdobeCommerceClient, type AdobeIMSConfig, type BaseTelemetry, type BaseTelemetryValidator, BasicAuthConnection, BearerToken, type BearerTokenInfo, type CommerceEvent, type CommerceEventConfig, type CommerceEventField, type Connection, type CreateEventResult, CreateEvents, type CreateProviderParams, type CreateProviderResult, type CreateRegistrationResult, CreateRegistrations, type ErrorResponse, EventConsumerAction, type EventData, type EventMetadata, type EventMetadataInputModel, type EventMetadataListResponse, EventMetadataManager, type ExtendedRequestError, type FileMetadata, type FileRecord, FileRepository, GenerateBasicAuthToken, type GetProviderQueryParams, type GetRegistrationQueryParams, GraphQlAction, type HALLink, type Headers, HttpMethod, HttpStatus, IOEventsApiError, type IOEventsError, ImsConnection, ImsToken, type ImsTokenResult, InfiniteLoopBreaker, type InfiniteLoopData, IoEventsGlobals, JsonMessageProcessor, type ListProvidersQueryParams, type ListRegistrationQueryParams, type MenuItem, Oauth1aConnection, OnboardCommerce, type OnboardCommerceConfig, type OnboardCommerceResult, OnboardEvents, type OnboardEventsInput, type OnboardEventsResponse, OnboardEvents as OnboardIOEvents, Openwhisk, OpenwhiskAction, type OpenwhiskConfig, type Page, Parameters, type Provider, type ProviderInputModel, ProviderManager, PublishEvent, type PublishEventResult, type Registration, type RegistrationCreateModel, type RegistrationListResponse, RegistrationManager, RestClient, RuntimeAction, RuntimeActionResponse, type RuntimeActionResponseType, RuntimeApiGatewayService, ShippingCarrier, type ShippingCarrierData, ShippingCarrierMethod, type ShippingCarrierMethodAdditionalData, type ShippingCarrierMethodData, ShippingCarrierResponse, SignatureVerification, SuccessChecker, type SuccessResponse, Telemetry, TelemetryInputError, type TokenResult, Validator, WebhookAction, type WebhookActionAddResponse, type WebhookActionExceptionResponse, WebhookActionOperation, type WebhookActionRemoveResponse, type WebhookActionReplaceResponse, WebhookActionResponse, type WebhookActionResponseType, type WebhookActionSuccessResponse, type WorkspaceConfig };
|
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");
|
|
@@ -1922,14 +1974,19 @@ var _Openwhisk = class _Openwhisk {
|
|
|
1922
1974
|
this.openwhiskClient = (0, import_openwhisk.default)({ apihost: host, api_key: apiKey });
|
|
1923
1975
|
}
|
|
1924
1976
|
/**
|
|
1925
|
-
*
|
|
1926
|
-
*
|
|
1927
|
-
* @
|
|
1977
|
+
* Execute an OpenWhisk action
|
|
1978
|
+
*
|
|
1979
|
+
* @param action - Name of the action to execute
|
|
1980
|
+
* @param params - Parameters to pass to the action
|
|
1981
|
+
* @param config - Configuration options for execution
|
|
1982
|
+
* @param config.blocking - Whether to wait for action completion (default: true)
|
|
1983
|
+
* @returns {Promise<Activation<Dict>>} Action activation result
|
|
1928
1984
|
*/
|
|
1929
|
-
async execute(action, params) {
|
|
1985
|
+
async execute(action, params, config = {}) {
|
|
1986
|
+
const { blocking = true } = config;
|
|
1930
1987
|
return await this.openwhiskClient.actions.invoke({
|
|
1931
1988
|
name: action,
|
|
1932
|
-
blocking
|
|
1989
|
+
blocking,
|
|
1933
1990
|
params
|
|
1934
1991
|
});
|
|
1935
1992
|
}
|
|
@@ -1986,29 +2043,28 @@ var _OpenwhiskAction = class _OpenwhiskAction {
|
|
|
1986
2043
|
const logger = telemetry_default.createLogger(name, params);
|
|
1987
2044
|
try {
|
|
1988
2045
|
logger.debug({
|
|
1989
|
-
message:
|
|
1990
|
-
action_name: name
|
|
2046
|
+
message: "OpenWhisk action execution started"
|
|
1991
2047
|
});
|
|
1992
2048
|
logger.debug({
|
|
1993
|
-
message:
|
|
2049
|
+
message: "OpenWhisk action parameters received",
|
|
1994
2050
|
params
|
|
1995
2051
|
});
|
|
1996
2052
|
const result = await action(params, { logger, headers: params.__ow_headers || {} });
|
|
1997
2053
|
logger.debug({
|
|
1998
|
-
message:
|
|
2054
|
+
message: "OpenWhisk action execution completed",
|
|
1999
2055
|
result
|
|
2000
2056
|
});
|
|
2001
2057
|
return result;
|
|
2002
2058
|
} catch (error) {
|
|
2003
2059
|
if (error instanceof Error) {
|
|
2004
2060
|
logger.error({
|
|
2005
|
-
message:
|
|
2061
|
+
message: "OpenWhisk action execution failed",
|
|
2006
2062
|
error: error.message,
|
|
2007
2063
|
stack: error.stack
|
|
2008
2064
|
});
|
|
2009
2065
|
} else {
|
|
2010
2066
|
logger.error({
|
|
2011
|
-
message:
|
|
2067
|
+
message: "OpenWhisk action execution failed",
|
|
2012
2068
|
error
|
|
2013
2069
|
});
|
|
2014
2070
|
}
|
|
@@ -2573,7 +2629,7 @@ var _WebhookAction = class _WebhookAction {
|
|
|
2573
2629
|
const verificationErrorMessage = await verifySignature(params);
|
|
2574
2630
|
if (verificationErrorMessage) {
|
|
2575
2631
|
logger.error({
|
|
2576
|
-
message:
|
|
2632
|
+
message: "Webhook actionsignature verification failed",
|
|
2577
2633
|
error: verificationErrorMessage
|
|
2578
2634
|
});
|
|
2579
2635
|
const verificationErrorResponse = response_default2.exception(verificationErrorMessage);
|
|
@@ -2587,7 +2643,7 @@ var _WebhookAction = class _WebhookAction {
|
|
|
2587
2643
|
const errorMessage = validator_default.checkMissingRequestInputs(params, requiredParams, requiredHeaders) ?? "";
|
|
2588
2644
|
if (errorMessage) {
|
|
2589
2645
|
logger.error({
|
|
2590
|
-
message:
|
|
2646
|
+
message: "Webhook action validation failed",
|
|
2591
2647
|
error: errorMessage
|
|
2592
2648
|
});
|
|
2593
2649
|
const errorMessageResponse = response_default2.exception(errorMessage);
|
|
@@ -2597,6 +2653,7 @@ var _WebhookAction = class _WebhookAction {
|
|
|
2597
2653
|
return response_default.success(JSON.stringify(response));
|
|
2598
2654
|
}, "callback");
|
|
2599
2655
|
runtime_action_default.setActionType("webhook-action");
|
|
2656
|
+
runtime_action_default.setActionTypeName("Webhook action");
|
|
2600
2657
|
return runtime_action_default.execute(name, httpMethods, [], [], callback);
|
|
2601
2658
|
}
|
|
2602
2659
|
};
|