quidproquo-actionprocessor-awslambda 0.0.116 → 0.0.118
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/lib/getActionProcessor/core/keyValueStore/getKeyValueStoreQueryActionProcessor.js +2 -2
- package/lib/getActionProcessor/core/keyValueStore/getKeyValueStoreScanActionProcessor.js +2 -2
- package/lib/getActionProcessor/core/userDirectory/getUserDirectoryChangePasswordActionProcessor.d.ts +5 -0
- package/lib/getActionProcessor/core/userDirectory/getUserDirectoryChangePasswordActionProcessor.js +26 -0
- package/lib/getActionProcessor/core/userDirectory/index.d.ts +1 -0
- package/lib/getActionProcessor/core/userDirectory/index.js +2 -1
- package/lib/logic/cognito/changePassword.d.ts +1 -0
- package/lib/logic/cognito/changePassword.js +23 -0
- package/lib/logic/dynamo/logs/utils/stringToLastEvaluatedKey.d.ts +2 -1
- package/lib/logic/dynamo/query.d.ts +2 -2
- package/lib/logic/dynamo/query.js +7 -4
- package/lib/logic/dynamo/scan.d.ts +2 -2
- package/lib/logic/dynamo/scan.js +7 -3
- package/lib/logic/dynamo/utils/itemsToQpqPagedData.d.ts +2 -0
- package/lib/logic/dynamo/utils/itemsToQpqPagedData.js +9 -0
- package/lib/logic/dynamo/utils/qpqPagedDataToItems.d.ts +4 -0
- package/lib/logic/dynamo/utils/qpqPagedDataToItems.js +9 -0
- package/package.json +1 -1
|
@@ -15,14 +15,14 @@ const quidproquo_core_2 = require("quidproquo-core");
|
|
|
15
15
|
const dynamo_1 = require("../../../logic/dynamo");
|
|
16
16
|
const qpqDynamoOrm_1 = require("../../../logic/dynamo/qpqDynamoOrm");
|
|
17
17
|
const getProcessKeyValueStoreQuery = (qpqConfig) => {
|
|
18
|
-
return ({ keyValueStoreName, keyCondition, filterCondition }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
18
|
+
return ({ keyValueStoreName, keyCondition, filterCondition, nextPageKey }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
19
19
|
const dynamoTableName = (0, awsNamingUtils_1.getKvsDynamoTableNameFromConfig)(keyValueStoreName, qpqConfig, 'kvs');
|
|
20
20
|
const region = quidproquo_core_1.qpqCoreUtils.getApplicationModuleDeployRegion(qpqConfig);
|
|
21
21
|
const storeConfig = quidproquo_core_1.qpqCoreUtils.getKeyValueStoreByName(qpqConfig, keyValueStoreName);
|
|
22
22
|
if (!storeConfig) {
|
|
23
23
|
return (0, quidproquo_core_1.actionResultError)(quidproquo_core_1.ErrorTypeEnum.NotFound, `Could not find key value store with name "${keyValueStoreName}"`);
|
|
24
24
|
}
|
|
25
|
-
const items = yield (0, dynamo_1.query)(dynamoTableName, region, keyCondition, filterCondition, (0, qpqDynamoOrm_1.getDynamoTableIndexByConfigAndQuery)(storeConfig, keyCondition));
|
|
25
|
+
const items = yield (0, dynamo_1.query)(dynamoTableName, region, keyCondition, filterCondition, nextPageKey, (0, qpqDynamoOrm_1.getDynamoTableIndexByConfigAndQuery)(storeConfig, keyCondition));
|
|
26
26
|
return (0, quidproquo_core_2.actionResult)(items);
|
|
27
27
|
});
|
|
28
28
|
};
|
|
@@ -14,10 +14,10 @@ const awsNamingUtils_1 = require("../../../awsNamingUtils");
|
|
|
14
14
|
const quidproquo_core_2 = require("quidproquo-core");
|
|
15
15
|
const scan_1 = require("../../../logic/dynamo/scan");
|
|
16
16
|
const getProcessKeyValueStoreScan = (qpqConfig) => {
|
|
17
|
-
return ({ keyValueStoreName, filterCondition }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
17
|
+
return ({ keyValueStoreName, filterCondition, nextPageKey }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
18
18
|
const dynamoTableName = (0, awsNamingUtils_1.getKvsDynamoTableNameFromConfig)(keyValueStoreName, qpqConfig, 'kvs');
|
|
19
19
|
const region = quidproquo_core_1.qpqCoreUtils.getApplicationModuleDeployRegion(qpqConfig);
|
|
20
|
-
const items = yield (0, scan_1.scan)(dynamoTableName, region, filterCondition);
|
|
20
|
+
const items = yield (0, scan_1.scan)(dynamoTableName, region, filterCondition, nextPageKey);
|
|
21
21
|
return (0, quidproquo_core_2.actionResult)(items);
|
|
22
22
|
});
|
|
23
23
|
};
|
package/lib/getActionProcessor/core/userDirectory/getUserDirectoryChangePasswordActionProcessor.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
const quidproquo_core_1 = require("quidproquo-core");
|
|
13
|
+
const changePassword_1 = require("../../../logic/cognito/changePassword");
|
|
14
|
+
const getUserDirectoryChangePasswordActionProcessor = (qpqConfig) => {
|
|
15
|
+
return ({ oldPassword, newPassword }, session) => __awaiter(void 0, void 0, void 0, function* () {
|
|
16
|
+
const region = quidproquo_core_1.qpqCoreUtils.getApplicationModuleDeployRegion(qpqConfig);
|
|
17
|
+
console.log({ oldPassword, newPassword });
|
|
18
|
+
yield (0, changePassword_1.changePassword)(session.accessToken, oldPassword, newPassword, region);
|
|
19
|
+
return (0, quidproquo_core_1.actionResult)(void 0);
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
exports.default = (qpqConfig) => {
|
|
23
|
+
return {
|
|
24
|
+
[quidproquo_core_1.UserDirectoryActionType.ChangePassword]: getUserDirectoryChangePasswordActionProcessor(qpqConfig),
|
|
25
|
+
};
|
|
26
|
+
};
|
|
@@ -12,6 +12,7 @@ declare const _default: (qpqConfig: QPQConfig) => {
|
|
|
12
12
|
"@quidproquo-core/UserDirectory/CreateUser": import("quidproquo-core").UserDirectoryCreateUserActionProcessor;
|
|
13
13
|
"@quidproquo-core/UserDirectory/ConfirmForgotPassword": import("quidproquo-core").UserDirectoryConfirmForgotPasswordActionProcessor;
|
|
14
14
|
"@quidproquo-core/UserDirectory/ConfirmEmailVerification": import("quidproquo-core").UserDirectoryConfirmEmailVerificationActionProcessor;
|
|
15
|
+
"@quidproquo-core/UserDirectory/ChangePassword": import("quidproquo-core").UserDirectoryChangePasswordActionProcessor;
|
|
15
16
|
"@quidproquo-core/UserDirectory/AuthenticateUser": import("quidproquo-core").UserDirectoryAuthenticateUserActionProcessor;
|
|
16
17
|
};
|
|
17
18
|
export default _default;
|
|
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const getUserDirectoryAuthenticateUserActionProcessor_1 = __importDefault(require("./getUserDirectoryAuthenticateUserActionProcessor"));
|
|
7
|
+
const getUserDirectoryChangePasswordActionProcessor_1 = __importDefault(require("./getUserDirectoryChangePasswordActionProcessor"));
|
|
7
8
|
const getUserDirectoryConfirmEmailVerificationActionProcessor_1 = __importDefault(require("./getUserDirectoryConfirmEmailVerificationActionProcessor"));
|
|
8
9
|
const getUserDirectoryConfirmForgetPasswordActionProcessor_1 = __importDefault(require("./getUserDirectoryConfirmForgetPasswordActionProcessor"));
|
|
9
10
|
const getUserDirectoryCreateUserActionProcessor_1 = __importDefault(require("./getUserDirectoryCreateUserActionProcessor"));
|
|
@@ -16,4 +17,4 @@ const getUserDirectoryRefreshTokenActionProcessor_1 = __importDefault(require(".
|
|
|
16
17
|
const getUserDirectoryRequestEmailVerificationActionProcessor_1 = __importDefault(require("./getUserDirectoryRequestEmailVerificationActionProcessor"));
|
|
17
18
|
const getUserDirectoryRespondToAuthChallengeActionProcessor_1 = __importDefault(require("./getUserDirectoryRespondToAuthChallengeActionProcessor"));
|
|
18
19
|
const getUserDirectorySetUserAttributesActionProcessor_1 = __importDefault(require("./getUserDirectorySetUserAttributesActionProcessor"));
|
|
19
|
-
exports.default = (qpqConfig) => (Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (0, getUserDirectoryAuthenticateUserActionProcessor_1.default)(qpqConfig)), (0, getUserDirectoryConfirmEmailVerificationActionProcessor_1.default)(qpqConfig)), (0, getUserDirectoryConfirmForgetPasswordActionProcessor_1.default)(qpqConfig)), (0, getUserDirectoryCreateUserActionProcessor_1.default)(qpqConfig)), (0, getUserDirectoryDecodeAccessTokenActionProcessor_1.default)(qpqConfig)), (0, getUserDirectoryForgetPasswordActionProcessor_1.default)(qpqConfig)), (0, getUserDirectoryGetUserAttributesActionProcessor_1.default)(qpqConfig)), (0, getUserDirectoryGetUserAttributesByUserIdActionProcessor_1.default)(qpqConfig)), (0, getUserDirectoryReadAccessTokenActionProcessor_1.default)(qpqConfig)), (0, getUserDirectoryRefreshTokenActionProcessor_1.default)(qpqConfig)), (0, getUserDirectoryRequestEmailVerificationActionProcessor_1.default)(qpqConfig)), (0, getUserDirectoryRespondToAuthChallengeActionProcessor_1.default)(qpqConfig)), (0, getUserDirectorySetUserAttributesActionProcessor_1.default)(qpqConfig)));
|
|
20
|
+
exports.default = (qpqConfig) => (Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (0, getUserDirectoryAuthenticateUserActionProcessor_1.default)(qpqConfig)), (0, getUserDirectoryChangePasswordActionProcessor_1.default)(qpqConfig)), (0, getUserDirectoryConfirmEmailVerificationActionProcessor_1.default)(qpqConfig)), (0, getUserDirectoryConfirmForgetPasswordActionProcessor_1.default)(qpqConfig)), (0, getUserDirectoryCreateUserActionProcessor_1.default)(qpqConfig)), (0, getUserDirectoryDecodeAccessTokenActionProcessor_1.default)(qpqConfig)), (0, getUserDirectoryForgetPasswordActionProcessor_1.default)(qpqConfig)), (0, getUserDirectoryGetUserAttributesActionProcessor_1.default)(qpqConfig)), (0, getUserDirectoryGetUserAttributesByUserIdActionProcessor_1.default)(qpqConfig)), (0, getUserDirectoryReadAccessTokenActionProcessor_1.default)(qpqConfig)), (0, getUserDirectoryRefreshTokenActionProcessor_1.default)(qpqConfig)), (0, getUserDirectoryRequestEmailVerificationActionProcessor_1.default)(qpqConfig)), (0, getUserDirectoryRespondToAuthChallengeActionProcessor_1.default)(qpqConfig)), (0, getUserDirectorySetUserAttributesActionProcessor_1.default)(qpqConfig)));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const changePassword: (accessToken: string, previousPassword: string, proposedPassword: string, region: string) => Promise<void>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.changePassword = void 0;
|
|
13
|
+
const client_cognito_identity_provider_1 = require("@aws-sdk/client-cognito-identity-provider");
|
|
14
|
+
const changePassword = (accessToken, previousPassword, proposedPassword, region) => __awaiter(void 0, void 0, void 0, function* () {
|
|
15
|
+
const cognitoClient = new client_cognito_identity_provider_1.CognitoIdentityProviderClient({ region });
|
|
16
|
+
const params = {
|
|
17
|
+
AccessToken: accessToken,
|
|
18
|
+
PreviousPassword: previousPassword,
|
|
19
|
+
ProposedPassword: proposedPassword,
|
|
20
|
+
};
|
|
21
|
+
yield cognitoClient.send(new client_cognito_identity_provider_1.ChangePasswordCommand(params));
|
|
22
|
+
});
|
|
23
|
+
exports.changePassword = changePassword;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import { AttributeValue } from '@aws-sdk/client-dynamodb';
|
|
2
|
+
export declare function stringToLastEvaluatedKey(encodedKey: string): Record<string, AttributeValue>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { KvsQueryOperation } from 'quidproquo-core';
|
|
2
|
-
export declare function query<Item>(tableName: string, region: string, keyExpression: KvsQueryOperation, filterExpression?: KvsQueryOperation, indexName?: string): Promise<Item
|
|
1
|
+
import { KvsQueryOperation, QpqPagedData } from 'quidproquo-core';
|
|
2
|
+
export declare function query<Item>(tableName: string, region: string, keyExpression: KvsQueryOperation, filterExpression?: KvsQueryOperation, pageKey?: string, indexName?: string): Promise<QpqPagedData<Item>>;
|
|
@@ -12,8 +12,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.query = void 0;
|
|
13
13
|
const client_dynamodb_1 = require("@aws-sdk/client-dynamodb");
|
|
14
14
|
const convertObjectToDynamoMap_1 = require("./convertObjectToDynamoMap");
|
|
15
|
+
const logs_1 = require("./logs");
|
|
16
|
+
const itemsToQpqPagedData_1 = require("./utils/itemsToQpqPagedData");
|
|
15
17
|
const qpqDynamoOrm_1 = require("./qpqDynamoOrm");
|
|
16
|
-
function query(tableName, region, keyExpression, filterExpression, indexName) {
|
|
18
|
+
function query(tableName, region, keyExpression, filterExpression, pageKey, indexName) {
|
|
17
19
|
var _a;
|
|
18
20
|
return __awaiter(this, void 0, void 0, function* () {
|
|
19
21
|
// Instantiate DynamoDB client
|
|
@@ -26,13 +28,14 @@ function query(tableName, region, keyExpression, filterExpression, indexName) {
|
|
|
26
28
|
ExpressionAttributeNames: (0, qpqDynamoOrm_1.buildExpressionAttributeNames)([keyExpression, filterExpression]),
|
|
27
29
|
IndexName: indexName,
|
|
28
30
|
};
|
|
29
|
-
|
|
30
|
-
|
|
31
|
+
if (pageKey) {
|
|
32
|
+
params.ExclusiveStartKey = (0, logs_1.stringToLastEvaluatedKey)(pageKey);
|
|
33
|
+
}
|
|
31
34
|
// Create QueryCommand
|
|
32
35
|
const command = new client_dynamodb_1.QueryCommand(params);
|
|
33
36
|
// TODO: Catch errors and throw QPQ ones
|
|
34
37
|
const data = yield dynamoClient.send(command);
|
|
35
|
-
return (((_a = data.Items) === null || _a === void 0 ? void 0 : _a.map((i) => (0, convertObjectToDynamoMap_1.convertDynamoMapToObject)(i))) || []);
|
|
38
|
+
return (0, itemsToQpqPagedData_1.itemsToQpqPagedData)((((_a = data.Items) === null || _a === void 0 ? void 0 : _a.map((i) => (0, convertObjectToDynamoMap_1.convertDynamoMapToObject)(i))) || []), data.LastEvaluatedKey);
|
|
36
39
|
});
|
|
37
40
|
}
|
|
38
41
|
exports.query = query;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { KvsQueryOperation } from 'quidproquo-core';
|
|
2
|
-
export declare function scan<Item>(tableName: string, region: string, filterExpression?: KvsQueryOperation): Promise<Item
|
|
1
|
+
import { KvsQueryOperation, QpqPagedData } from 'quidproquo-core';
|
|
2
|
+
export declare function scan<Item>(tableName: string, region: string, filterExpression?: KvsQueryOperation, pageKey?: string): Promise<QpqPagedData<Item>>;
|
package/lib/logic/dynamo/scan.js
CHANGED
|
@@ -12,8 +12,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.scan = void 0;
|
|
13
13
|
const client_dynamodb_1 = require("@aws-sdk/client-dynamodb");
|
|
14
14
|
const convertObjectToDynamoMap_1 = require("./convertObjectToDynamoMap");
|
|
15
|
+
const logs_1 = require("./logs");
|
|
16
|
+
const itemsToQpqPagedData_1 = require("./utils/itemsToQpqPagedData");
|
|
15
17
|
const qpqDynamoOrm_1 = require("./qpqDynamoOrm");
|
|
16
|
-
function scan(tableName, region, filterExpression) {
|
|
18
|
+
function scan(tableName, region, filterExpression, pageKey) {
|
|
17
19
|
var _a;
|
|
18
20
|
return __awaiter(this, void 0, void 0, function* () {
|
|
19
21
|
// Instantiate DynamoDB client
|
|
@@ -24,12 +26,14 @@ function scan(tableName, region, filterExpression) {
|
|
|
24
26
|
ExpressionAttributeValues: (0, qpqDynamoOrm_1.buildExpressionAttributeValues)([filterExpression]),
|
|
25
27
|
ExpressionAttributeNames: (0, qpqDynamoOrm_1.buildExpressionAttributeNames)([filterExpression]),
|
|
26
28
|
};
|
|
27
|
-
|
|
29
|
+
if (pageKey) {
|
|
30
|
+
params.ExclusiveStartKey = (0, logs_1.stringToLastEvaluatedKey)(pageKey);
|
|
31
|
+
}
|
|
28
32
|
// Create ScanCommand
|
|
29
33
|
const command = new client_dynamodb_1.ScanCommand(params);
|
|
30
34
|
// TODO: Catch errors and throw QPQ ones
|
|
31
35
|
const data = yield dynamoClient.send(command);
|
|
32
|
-
return (((_a = data.Items) === null || _a === void 0 ? void 0 : _a.map((i) => (0, convertObjectToDynamoMap_1.convertDynamoMapToObject)(i))) || []);
|
|
36
|
+
return (0, itemsToQpqPagedData_1.itemsToQpqPagedData)((((_a = data.Items) === null || _a === void 0 ? void 0 : _a.map((i) => (0, convertObjectToDynamoMap_1.convertDynamoMapToObject)(i))) || []), data.LastEvaluatedKey);
|
|
33
37
|
});
|
|
34
38
|
}
|
|
35
39
|
exports.scan = scan;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.itemsToQpqPagedData = void 0;
|
|
4
|
+
const logs_1 = require("../logs");
|
|
5
|
+
const itemsToQpqPagedData = (items, lastEvaluatedKey) => ({
|
|
6
|
+
items,
|
|
7
|
+
nextPageKey: lastEvaluatedKey ? (0, logs_1.lastEvaluatedKeyToString)(lastEvaluatedKey) : undefined,
|
|
8
|
+
});
|
|
9
|
+
exports.itemsToQpqPagedData = itemsToQpqPagedData;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.itemsToQpqPagedData = void 0;
|
|
4
|
+
const logs_1 = require("../logs");
|
|
5
|
+
const itemsToQpqPagedData = (items, lastEvaluatedKey) => ({
|
|
6
|
+
items,
|
|
7
|
+
lastEvaluatedKey: lastEvaluatedKey && (0, logs_1.stringToLastEvaluatedKey)(lastEvaluatedKey),
|
|
8
|
+
});
|
|
9
|
+
exports.itemsToQpqPagedData = itemsToQpqPagedData;
|