@salesforce/mrt-utilities 0.1.1 → 0.1.2
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/dist/cjs/data-store/index.d.ts +56 -0
- package/dist/cjs/data-store/index.js +131 -0
- package/dist/cjs/data-store/index.js.map +1 -0
- package/dist/cjs/index.js +22 -4
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/metrics/index.js +17 -1
- package/dist/cjs/metrics/index.js.map +1 -1
- package/dist/cjs/metrics/metrics-sender.js +14 -9
- package/dist/cjs/metrics/metrics-sender.js.map +1 -1
- package/dist/cjs/middleware/data-store.d.ts +3 -54
- package/dist/cjs/middleware/data-store.js +19 -116
- package/dist/cjs/middleware/data-store.js.map +1 -1
- package/dist/cjs/middleware/express.d.ts +2 -0
- package/dist/cjs/middleware/express.js +23 -0
- package/dist/cjs/middleware/express.js.map +1 -0
- package/dist/cjs/middleware/index.d.ts +2 -3
- package/dist/cjs/middleware/index.js +18 -2
- package/dist/cjs/middleware/index.js.map +1 -1
- package/dist/cjs/middleware/middleware.js +79 -34
- package/dist/cjs/middleware/middleware.js.map +1 -1
- package/dist/cjs/streaming/create-lambda-adapter.js +66 -76
- package/dist/cjs/streaming/create-lambda-adapter.js.map +1 -1
- package/dist/cjs/streaming/index.js +7 -1
- package/dist/cjs/streaming/index.js.map +1 -1
- package/dist/cjs/utils/configure-proxying.js +16 -10
- package/dist/cjs/utils/configure-proxying.js.map +1 -1
- package/dist/cjs/utils/ssr-proxying.js +43 -32
- package/dist/cjs/utils/ssr-proxying.js.map +1 -1
- package/dist/cjs/utils/utils.js +7 -2
- package/dist/cjs/utils/utils.js.map +1 -1
- package/dist/esm/data-store/index.d.ts +56 -0
- package/dist/esm/data-store/index.js +124 -0
- package/dist/esm/data-store/index.js.map +1 -0
- package/dist/esm/middleware/data-store.d.ts +3 -54
- package/dist/esm/middleware/data-store.js +3 -116
- package/dist/esm/middleware/data-store.js.map +1 -1
- package/dist/esm/middleware/express.d.ts +2 -0
- package/dist/esm/middleware/express.js +8 -0
- package/dist/esm/middleware/express.js.map +1 -0
- package/dist/esm/middleware/index.d.ts +2 -3
- package/dist/esm/middleware/index.js +2 -3
- package/dist/esm/middleware/index.js.map +1 -1
- package/dist/esm/streaming/create-lambda-adapter.js +39 -57
- package/dist/esm/streaming/create-lambda-adapter.js.map +1 -1
- package/package.json +23 -1
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { DynamoDBDocumentClient } from '@aws-sdk/lib-dynamodb';
|
|
2
|
+
export declare class DataStoreNotFoundError extends Error {
|
|
3
|
+
constructor(message: string);
|
|
4
|
+
}
|
|
5
|
+
export declare class DataStoreServiceError extends Error {
|
|
6
|
+
constructor(message: string);
|
|
7
|
+
}
|
|
8
|
+
export declare class DataStoreUnavailableError extends Error {
|
|
9
|
+
constructor(message: string);
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* A class for reading entries from the data store.
|
|
13
|
+
*
|
|
14
|
+
* This class uses a singleton pattern.
|
|
15
|
+
* Use DataStore.getDataStore() to get the singleton instance.
|
|
16
|
+
*/
|
|
17
|
+
export declare class DataStore {
|
|
18
|
+
private _tableName;
|
|
19
|
+
private _ddb;
|
|
20
|
+
private static _instance;
|
|
21
|
+
/** @internal Test hook: inject a document client for unit tests */
|
|
22
|
+
static _testDocumentClient: DynamoDBDocumentClient | null;
|
|
23
|
+
/** @internal Test hook: inject logMRTError for unit tests */
|
|
24
|
+
static _testLogMRTError: ((namespace: string, err: unknown, context?: Record<string, unknown>) => void) | null;
|
|
25
|
+
private constructor();
|
|
26
|
+
/**
|
|
27
|
+
* Get or create a DynamoDB document client (for abstraction of attribute values).
|
|
28
|
+
*
|
|
29
|
+
* @private
|
|
30
|
+
* @returns The DynamoDB document client
|
|
31
|
+
* @throws {DataStoreUnavailableError} The data store is unavailable
|
|
32
|
+
*/
|
|
33
|
+
private getClient;
|
|
34
|
+
/**
|
|
35
|
+
* Get or create the singleton DataStore instance.
|
|
36
|
+
*
|
|
37
|
+
* @returns The singleton DataStore instance
|
|
38
|
+
*/
|
|
39
|
+
static getDataStore(): DataStore;
|
|
40
|
+
/**
|
|
41
|
+
* Whether the data store can be used in the current environment.
|
|
42
|
+
*
|
|
43
|
+
* @returns true if the data store is available, false otherwise
|
|
44
|
+
*/
|
|
45
|
+
isDataStoreAvailable(): boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Fetch an entry from the data store.
|
|
48
|
+
*
|
|
49
|
+
* @param key The data store entry's key
|
|
50
|
+
* @returns An object containing the entry's key and value
|
|
51
|
+
* @throws {DataStoreUnavailableError} The data store is unavailable
|
|
52
|
+
* @throws {DataStoreNotFoundError} An entry with the given key cannot be found
|
|
53
|
+
* @throws {DataStoreServiceError} An internal error occurred
|
|
54
|
+
*/
|
|
55
|
+
getEntry(key: string): Promise<Record<string, unknown> | undefined>;
|
|
56
|
+
}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2025, Salesforce, Inc.
|
|
4
|
+
* SPDX-License-Identifier: Apache-2
|
|
5
|
+
* For full license text, see the license.txt file in the repo root or http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.DataStore = exports.DataStoreUnavailableError = exports.DataStoreServiceError = exports.DataStoreNotFoundError = void 0;
|
|
9
|
+
const client_dynamodb_1 = require("@aws-sdk/client-dynamodb");
|
|
10
|
+
const lib_dynamodb_1 = require("@aws-sdk/lib-dynamodb");
|
|
11
|
+
const utils_js_1 = require("../utils/utils.js");
|
|
12
|
+
class DataStoreNotFoundError extends Error {
|
|
13
|
+
constructor(message) {
|
|
14
|
+
super(message);
|
|
15
|
+
this.name = 'DataStoreNotFoundError';
|
|
16
|
+
Object.setPrototypeOf(this, DataStoreNotFoundError.prototype);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
exports.DataStoreNotFoundError = DataStoreNotFoundError;
|
|
20
|
+
class DataStoreServiceError extends Error {
|
|
21
|
+
constructor(message) {
|
|
22
|
+
super(message);
|
|
23
|
+
this.name = 'DataStoreServiceError';
|
|
24
|
+
Object.setPrototypeOf(this, DataStoreServiceError.prototype);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.DataStoreServiceError = DataStoreServiceError;
|
|
28
|
+
class DataStoreUnavailableError extends Error {
|
|
29
|
+
constructor(message) {
|
|
30
|
+
super(message);
|
|
31
|
+
this.name = 'DataStoreUnavailableError';
|
|
32
|
+
Object.setPrototypeOf(this, DataStoreUnavailableError.prototype);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
exports.DataStoreUnavailableError = DataStoreUnavailableError;
|
|
36
|
+
/**
|
|
37
|
+
* A class for reading entries from the data store.
|
|
38
|
+
*
|
|
39
|
+
* This class uses a singleton pattern.
|
|
40
|
+
* Use DataStore.getDataStore() to get the singleton instance.
|
|
41
|
+
*/
|
|
42
|
+
class DataStore {
|
|
43
|
+
_tableName = '';
|
|
44
|
+
_ddb = null;
|
|
45
|
+
static _instance = null;
|
|
46
|
+
/** @internal Test hook: inject a document client for unit tests */
|
|
47
|
+
static _testDocumentClient = null;
|
|
48
|
+
/** @internal Test hook: inject logMRTError for unit tests */
|
|
49
|
+
static _testLogMRTError = null;
|
|
50
|
+
constructor() {
|
|
51
|
+
// Private constructor for singleton; use DataStore.getDataStore() instead.
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Get or create a DynamoDB document client (for abstraction of attribute values).
|
|
55
|
+
*
|
|
56
|
+
* @private
|
|
57
|
+
* @returns The DynamoDB document client
|
|
58
|
+
* @throws {DataStoreUnavailableError} The data store is unavailable
|
|
59
|
+
*/
|
|
60
|
+
getClient() {
|
|
61
|
+
if (!this.isDataStoreAvailable()) {
|
|
62
|
+
throw new DataStoreUnavailableError('The data store is unavailable.');
|
|
63
|
+
}
|
|
64
|
+
if (DataStore._testDocumentClient) {
|
|
65
|
+
this._tableName = `DataAccessLayer-${process.env.AWS_REGION}`;
|
|
66
|
+
return DataStore._testDocumentClient;
|
|
67
|
+
}
|
|
68
|
+
if (!this._ddb) {
|
|
69
|
+
this._tableName = `DataAccessLayer-${process.env.AWS_REGION}`;
|
|
70
|
+
this._ddb = lib_dynamodb_1.DynamoDBDocumentClient.from(new client_dynamodb_1.DynamoDBClient({
|
|
71
|
+
region: process.env.AWS_REGION,
|
|
72
|
+
}));
|
|
73
|
+
}
|
|
74
|
+
return this._ddb;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Get or create the singleton DataStore instance.
|
|
78
|
+
*
|
|
79
|
+
* @returns The singleton DataStore instance
|
|
80
|
+
*/
|
|
81
|
+
static getDataStore() {
|
|
82
|
+
if (!DataStore._instance) {
|
|
83
|
+
DataStore._instance = new DataStore();
|
|
84
|
+
}
|
|
85
|
+
return DataStore._instance;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Whether the data store can be used in the current environment.
|
|
89
|
+
*
|
|
90
|
+
* @returns true if the data store is available, false otherwise
|
|
91
|
+
*/
|
|
92
|
+
isDataStoreAvailable() {
|
|
93
|
+
return Boolean(process.env.AWS_REGION && process.env.MOBIFY_PROPERTY_ID && process.env.DEPLOY_TARGET);
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Fetch an entry from the data store.
|
|
97
|
+
*
|
|
98
|
+
* @param key The data store entry's key
|
|
99
|
+
* @returns An object containing the entry's key and value
|
|
100
|
+
* @throws {DataStoreUnavailableError} The data store is unavailable
|
|
101
|
+
* @throws {DataStoreNotFoundError} An entry with the given key cannot be found
|
|
102
|
+
* @throws {DataStoreServiceError} An internal error occurred
|
|
103
|
+
*/
|
|
104
|
+
async getEntry(key) {
|
|
105
|
+
if (!this.isDataStoreAvailable()) {
|
|
106
|
+
throw new DataStoreUnavailableError('The data store is unavailable.');
|
|
107
|
+
}
|
|
108
|
+
const ddb = this.getClient();
|
|
109
|
+
let response;
|
|
110
|
+
try {
|
|
111
|
+
response = await ddb.send(new lib_dynamodb_1.GetCommand({
|
|
112
|
+
TableName: this._tableName,
|
|
113
|
+
Key: {
|
|
114
|
+
projectEnvironment: `${process.env.MOBIFY_PROPERTY_ID} ${process.env.DEPLOY_TARGET}`,
|
|
115
|
+
key,
|
|
116
|
+
},
|
|
117
|
+
}));
|
|
118
|
+
}
|
|
119
|
+
catch (error) {
|
|
120
|
+
const logFn = DataStore._testLogMRTError ?? utils_js_1.logMRTError;
|
|
121
|
+
logFn('data_store', error, { key, tableName: this._tableName });
|
|
122
|
+
throw new DataStoreServiceError('Data store request failed.');
|
|
123
|
+
}
|
|
124
|
+
if (!response.Item?.value) {
|
|
125
|
+
throw new DataStoreNotFoundError(`Data store entry '${key}' not found.`);
|
|
126
|
+
}
|
|
127
|
+
return { key, value: response.Item.value };
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
exports.DataStore = DataStore;
|
|
131
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/data-store/index.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAEH,8DAAwD;AACxD,wDAAgG;AAEhG,gDAA8C;AAE9C,MAAa,sBAAuB,SAAQ,KAAK;IAC/C,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,wBAAwB,CAAC;QACrC,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,sBAAsB,CAAC,SAAS,CAAC,CAAC;IAChE,CAAC;CACF;AAND,wDAMC;AAED,MAAa,qBAAsB,SAAQ,KAAK;IAC9C,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,uBAAuB,CAAC;QACpC,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,qBAAqB,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,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC;YAC1B,MAAM,IAAI,sBAAsB,CAAC,qBAAqB,GAAG,cAAc,CAAC,CAAC;QAC3E,CAAC;QAED,OAAO,EAAC,GAAG,EAAE,KAAK,EAAE,QAAQ,CAAC,IAAI,CAAC,KAAK,EAAC,CAAC;IAC3C,CAAC;;AArGH,8BAsGC"}
|
package/dist/cjs/index.js
CHANGED
|
@@ -1,10 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
/*
|
|
2
3
|
* Copyright (c) 2025, Salesforce, Inc.
|
|
3
4
|
* SPDX-License-Identifier: Apache-2
|
|
4
5
|
* For full license text, see the license.txt file in the repo root or http://www.apache.org/licenses/LICENSE-2.0
|
|
5
6
|
*/
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
8
|
+
if (k2 === undefined) k2 = k;
|
|
9
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
10
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
11
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
12
|
+
}
|
|
13
|
+
Object.defineProperty(o, k2, desc);
|
|
14
|
+
}) : (function(o, m, k, k2) {
|
|
15
|
+
if (k2 === undefined) k2 = k;
|
|
16
|
+
o[k2] = m[k];
|
|
17
|
+
}));
|
|
18
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
19
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
20
|
+
};
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
exports.isLocal = void 0;
|
|
23
|
+
__exportStar(require("./middleware/index.js"), exports);
|
|
24
|
+
__exportStar(require("./metrics/index.js"), exports);
|
|
25
|
+
__exportStar(require("./streaming/index.js"), exports);
|
|
26
|
+
var utils_js_1 = require("./utils/utils.js");
|
|
27
|
+
Object.defineProperty(exports, "isLocal", { enumerable: true, get: function () { return utils_js_1.isLocal; } });
|
|
10
28
|
//# sourceMappingURL=index.js.map
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;AAEH,wDAAsC;AACtC,qDAAmC;AACnC,uDAAqC;AACrC,6CAAyC;AAAjC,mGAAA,OAAO,OAAA"}
|
|
@@ -1,7 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
/*
|
|
2
3
|
* Copyright (c) 2025, Salesforce, Inc.
|
|
3
4
|
* SPDX-License-Identifier: Apache-2
|
|
4
5
|
* For full license text, see the license.txt file in the repo root or http://www.apache.org/licenses/LICENSE-2.0
|
|
5
6
|
*/
|
|
6
|
-
|
|
7
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
8
|
+
if (k2 === undefined) k2 = k;
|
|
9
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
10
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
11
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
12
|
+
}
|
|
13
|
+
Object.defineProperty(o, k2, desc);
|
|
14
|
+
}) : (function(o, m, k, k2) {
|
|
15
|
+
if (k2 === undefined) k2 = k;
|
|
16
|
+
o[k2] = m[k];
|
|
17
|
+
}));
|
|
18
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
19
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
20
|
+
};
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
__exportStar(require("./metrics-sender.js"), exports);
|
|
7
23
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/metrics/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/metrics/index.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;AAEH,sDAAoC"}
|
|
@@ -1,18 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
/*
|
|
2
3
|
* Copyright (c) 2025, Salesforce, Inc.
|
|
3
4
|
* SPDX-License-Identifier: Apache-2
|
|
4
5
|
* For full license text, see the license.txt file in the repo root or http://www.apache.org/licenses/LICENSE-2.0
|
|
5
6
|
*/
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.MetricsSender = exports.getDimensions = exports.DEFAULT_NAMESPACE = void 0;
|
|
9
|
+
const client_cloudwatch_1 = require("@aws-sdk/client-cloudwatch");
|
|
10
|
+
const utils_js_1 = require("../utils/utils.js");
|
|
11
|
+
const isRemote = () => !(0, utils_js_1.isLocal)();
|
|
12
|
+
exports.DEFAULT_NAMESPACE = 'ssr';
|
|
13
|
+
const getDimensions = () => {
|
|
11
14
|
return {
|
|
12
15
|
Project: process.env.MOBIFY_PROPERTY_ID || 'UNKNOWN',
|
|
13
16
|
Target: process.env.DEPLOY_TARGET || 'UNKNOWN',
|
|
14
17
|
};
|
|
15
18
|
};
|
|
19
|
+
exports.getDimensions = getDimensions;
|
|
16
20
|
/**
|
|
17
21
|
* A class that handles asynchronous sending of CloudWatch metrics.
|
|
18
22
|
*
|
|
@@ -24,7 +28,7 @@ export const getDimensions = () => {
|
|
|
24
28
|
* In local development environments, metrics are queued but not sent
|
|
25
29
|
* unless the SEND_CW_METRICS environment variable is set.
|
|
26
30
|
*/
|
|
27
|
-
|
|
31
|
+
class MetricsSender {
|
|
28
32
|
_CW = null;
|
|
29
33
|
_queue = [];
|
|
30
34
|
static _override = false;
|
|
@@ -72,7 +76,7 @@ export class MetricsSender {
|
|
|
72
76
|
// Setting maxAttempts to 1 will prevent the SDK from retrying.
|
|
73
77
|
// This is necessary because under high load, there will be backpressure
|
|
74
78
|
// on the Lambda function, and causing severe performance issues (400-500ms latency)
|
|
75
|
-
this._CW = new CloudWatchClient({
|
|
79
|
+
this._CW = new client_cloudwatch_1.CloudWatchClient({
|
|
76
80
|
region: process.env.AWS_REGION || 'us-east-1',
|
|
77
81
|
maxAttempts: 1,
|
|
78
82
|
});
|
|
@@ -128,9 +132,9 @@ export class MetricsSender {
|
|
|
128
132
|
return Promise.resolve();
|
|
129
133
|
}
|
|
130
134
|
try {
|
|
131
|
-
const command = new PutMetricDataCommand({
|
|
135
|
+
const command = new client_cloudwatch_1.PutMetricDataCommand({
|
|
132
136
|
MetricData: metrics,
|
|
133
|
-
Namespace: DEFAULT_NAMESPACE,
|
|
137
|
+
Namespace: exports.DEFAULT_NAMESPACE,
|
|
134
138
|
});
|
|
135
139
|
await cw.send(command);
|
|
136
140
|
}
|
|
@@ -233,6 +237,7 @@ export class MetricsSender {
|
|
|
233
237
|
return MetricsSender._instance;
|
|
234
238
|
}
|
|
235
239
|
}
|
|
240
|
+
exports.MetricsSender = MetricsSender;
|
|
236
241
|
// Allow the presence of an environment variable to
|
|
237
242
|
// enable sending of CloudWatch metrics (for local
|
|
238
243
|
// integration testing)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metrics-sender.js","sourceRoot":"","sources":["../../../src/metrics/metrics-sender.ts"],"names":[],"mappings":"AAAA;;;;GAIG
|
|
1
|
+
{"version":3,"file":"metrics-sender.js","sourceRoot":"","sources":["../../../src/metrics/metrics-sender.ts"],"names":[],"mappings":";A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I,CAAC,MAAM,CAAC,CAAC;QACvC,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;QACjB,IAAI,CAAC,mBAAmB,CAAC,aAAa,CAAC,CAAC;QACxC,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC3B,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA6BG;IACH,IAAI,CAAC,OAAsB,EAAE,YAAqB,KAAK;QACrD,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,MAAM,eAAe,GAAkB,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,CAAC,qBAAqB,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC;QAExG,IAAI,SAAS,EAAE,CAAC;YACd,qDAAqD;YACrD,IAAI,CAAC,mBAAmB,CAAC,eAAe,CAAC,CAAC;QAC5C,CAAC;aAAM,CAAC;YACN,eAAe;YACf,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,eAAe,CAAC,CAAC;QACvC,CAAC;IACH,CAAC;IAED;;;;;;;OAOG;IACH,MAAM,CAAC,SAAS;QACd,IAAI,CAAC,aAAa,CAAC,SAAS,EAAE,CAAC;YAC7B,aAAa,CAAC,SAAS,GAAG,IAAI,aAAa,EAAE,CAAC;QAChD,CAAC;QACD,OAAO,aAAa,CAAC,SAAS,CAAC;IACjC,CAAC;;AAhOH,sCAiOC;AAED,mDAAmD;AACnD,kDAAkD;AAClD,uBAAuB;AACvB,aAAa,CAAC,SAAS,GAAG,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC"}
|
|
@@ -1,56 +1,5 @@
|
|
|
1
|
-
import { DynamoDBDocumentClient } from '@aws-sdk/lib-dynamodb';
|
|
2
|
-
export declare class DataStoreNotFoundError extends Error {
|
|
3
|
-
constructor(message: string);
|
|
4
|
-
}
|
|
5
|
-
export declare class DataStoreServiceError extends Error {
|
|
6
|
-
constructor(message: string);
|
|
7
|
-
}
|
|
8
|
-
export declare class DataStoreUnavailableError extends Error {
|
|
9
|
-
constructor(message: string);
|
|
10
|
-
}
|
|
11
1
|
/**
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* This class uses a singleton pattern.
|
|
15
|
-
* Use DataStore.getDataStore() to get the singleton instance.
|
|
2
|
+
* @deprecated Import data-store symbols from `@salesforce/mrt-utilities/data-store`.
|
|
3
|
+
* This compatibility path is kept for backward compatibility.
|
|
16
4
|
*/
|
|
17
|
-
export
|
|
18
|
-
private _tableName;
|
|
19
|
-
private _ddb;
|
|
20
|
-
private static _instance;
|
|
21
|
-
/** @internal Test hook: inject a document client for unit tests */
|
|
22
|
-
static _testDocumentClient: DynamoDBDocumentClient | null;
|
|
23
|
-
/** @internal Test hook: inject logMRTError for unit tests */
|
|
24
|
-
static _testLogMRTError: ((namespace: string, err: unknown, context?: Record<string, unknown>) => void) | null;
|
|
25
|
-
private constructor();
|
|
26
|
-
/**
|
|
27
|
-
* Get or create a DynamoDB document client (for abstraction of attribute values).
|
|
28
|
-
*
|
|
29
|
-
* @private
|
|
30
|
-
* @returns The DynamoDB document client
|
|
31
|
-
* @throws {DataStoreUnavailableError} The data store is unavailable
|
|
32
|
-
*/
|
|
33
|
-
private getClient;
|
|
34
|
-
/**
|
|
35
|
-
* Get or create the singleton DataStore instance.
|
|
36
|
-
*
|
|
37
|
-
* @returns The singleton DataStore instance
|
|
38
|
-
*/
|
|
39
|
-
static getDataStore(): DataStore;
|
|
40
|
-
/**
|
|
41
|
-
* Whether the data store can be used in the current environment.
|
|
42
|
-
*
|
|
43
|
-
* @returns true if the data store is available, false otherwise
|
|
44
|
-
*/
|
|
45
|
-
isDataStoreAvailable(): boolean;
|
|
46
|
-
/**
|
|
47
|
-
* Fetch an entry from the data store.
|
|
48
|
-
*
|
|
49
|
-
* @param key The data store entry's key
|
|
50
|
-
* @returns An object containing the entry's key and value
|
|
51
|
-
* @throws {DataStoreUnavailableError} The data store is unavailable
|
|
52
|
-
* @throws {DataStoreNotFoundError} An entry with the given key cannot be found
|
|
53
|
-
* @throws {DataStoreServiceError} An internal error occurred
|
|
54
|
-
*/
|
|
55
|
-
getEntry(key: string): Promise<Record<string, unknown> | undefined>;
|
|
56
|
-
}
|
|
5
|
+
export * from '../data-store/index.js';
|
|
@@ -1,124 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
/*
|
|
2
3
|
* Copyright (c) 2025, Salesforce, Inc.
|
|
3
4
|
* SPDX-License-Identifier: Apache-2
|
|
4
5
|
* For full license text, see the license.txt file in the repo root or http://www.apache.org/licenses/LICENSE-2.0
|
|
5
6
|
*/
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
export class DataStoreUnavailableError extends Error {
|
|
24
|
-
constructor(message) {
|
|
25
|
-
super(message);
|
|
26
|
-
this.name = 'DataStoreUnavailableError';
|
|
27
|
-
Object.setPrototypeOf(this, DataStoreUnavailableError.prototype);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
7
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
8
|
+
if (k2 === undefined) k2 = k;
|
|
9
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
10
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
11
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
12
|
+
}
|
|
13
|
+
Object.defineProperty(o, k2, desc);
|
|
14
|
+
}) : (function(o, m, k, k2) {
|
|
15
|
+
if (k2 === undefined) k2 = k;
|
|
16
|
+
o[k2] = m[k];
|
|
17
|
+
}));
|
|
18
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
19
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
20
|
+
};
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
22
|
/**
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
* This class uses a singleton pattern.
|
|
34
|
-
* Use DataStore.getDataStore() to get the singleton instance.
|
|
23
|
+
* @deprecated Import data-store symbols from `@salesforce/mrt-utilities/data-store`.
|
|
24
|
+
* This compatibility path is kept for backward compatibility.
|
|
35
25
|
*/
|
|
36
|
-
|
|
37
|
-
_tableName = '';
|
|
38
|
-
_ddb = null;
|
|
39
|
-
static _instance = null;
|
|
40
|
-
/** @internal Test hook: inject a document client for unit tests */
|
|
41
|
-
static _testDocumentClient = null;
|
|
42
|
-
/** @internal Test hook: inject logMRTError for unit tests */
|
|
43
|
-
static _testLogMRTError = null;
|
|
44
|
-
constructor() {
|
|
45
|
-
// Private constructor for singleton; use DataStore.getDataStore() instead.
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Get or create a DynamoDB document client (for abstraction of attribute values).
|
|
49
|
-
*
|
|
50
|
-
* @private
|
|
51
|
-
* @returns The DynamoDB document client
|
|
52
|
-
* @throws {DataStoreUnavailableError} The data store is unavailable
|
|
53
|
-
*/
|
|
54
|
-
getClient() {
|
|
55
|
-
if (!this.isDataStoreAvailable()) {
|
|
56
|
-
throw new DataStoreUnavailableError('The data store is unavailable.');
|
|
57
|
-
}
|
|
58
|
-
if (DataStore._testDocumentClient) {
|
|
59
|
-
this._tableName = `DataAccessLayer-${process.env.AWS_REGION}`;
|
|
60
|
-
return DataStore._testDocumentClient;
|
|
61
|
-
}
|
|
62
|
-
if (!this._ddb) {
|
|
63
|
-
this._tableName = `DataAccessLayer-${process.env.AWS_REGION}`;
|
|
64
|
-
this._ddb = DynamoDBDocumentClient.from(new DynamoDBClient({
|
|
65
|
-
region: process.env.AWS_REGION,
|
|
66
|
-
}));
|
|
67
|
-
}
|
|
68
|
-
return this._ddb;
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Get or create the singleton DataStore instance.
|
|
72
|
-
*
|
|
73
|
-
* @returns The singleton DataStore instance
|
|
74
|
-
*/
|
|
75
|
-
static getDataStore() {
|
|
76
|
-
if (!DataStore._instance) {
|
|
77
|
-
DataStore._instance = new DataStore();
|
|
78
|
-
}
|
|
79
|
-
return DataStore._instance;
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* Whether the data store can be used in the current environment.
|
|
83
|
-
*
|
|
84
|
-
* @returns true if the data store is available, false otherwise
|
|
85
|
-
*/
|
|
86
|
-
isDataStoreAvailable() {
|
|
87
|
-
return Boolean(process.env.AWS_REGION && process.env.MOBIFY_PROPERTY_ID && process.env.DEPLOY_TARGET);
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Fetch an entry from the data store.
|
|
91
|
-
*
|
|
92
|
-
* @param key The data store entry's key
|
|
93
|
-
* @returns An object containing the entry's key and value
|
|
94
|
-
* @throws {DataStoreUnavailableError} The data store is unavailable
|
|
95
|
-
* @throws {DataStoreNotFoundError} An entry with the given key cannot be found
|
|
96
|
-
* @throws {DataStoreServiceError} An internal error occurred
|
|
97
|
-
*/
|
|
98
|
-
async getEntry(key) {
|
|
99
|
-
if (!this.isDataStoreAvailable()) {
|
|
100
|
-
throw new DataStoreUnavailableError('The data store is unavailable.');
|
|
101
|
-
}
|
|
102
|
-
const ddb = this.getClient();
|
|
103
|
-
let response;
|
|
104
|
-
try {
|
|
105
|
-
response = await ddb.send(new GetCommand({
|
|
106
|
-
TableName: this._tableName,
|
|
107
|
-
Key: {
|
|
108
|
-
projectEnvironment: `${process.env.MOBIFY_PROPERTY_ID} ${process.env.DEPLOY_TARGET}`,
|
|
109
|
-
key,
|
|
110
|
-
},
|
|
111
|
-
}));
|
|
112
|
-
}
|
|
113
|
-
catch (error) {
|
|
114
|
-
const logFn = DataStore._testLogMRTError ?? logMRTError;
|
|
115
|
-
logFn('data_store', error, { key, tableName: this._tableName });
|
|
116
|
-
throw new DataStoreServiceError('Data store request failed.');
|
|
117
|
-
}
|
|
118
|
-
if (!response.Item?.value) {
|
|
119
|
-
throw new DataStoreNotFoundError(`Data store entry '${key}' not found.`);
|
|
120
|
-
}
|
|
121
|
-
return { key, value: response.Item.value };
|
|
122
|
-
}
|
|
123
|
-
}
|
|
26
|
+
__exportStar(require("../data-store/index.js"), exports);
|
|
124
27
|
//# sourceMappingURL=data-store.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-store.js","sourceRoot":"","sources":["../../../src/middleware/data-store.ts"],"names":[],"mappings":"AAAA;;;;GAIG
|
|
1
|
+
{"version":3,"file":"data-store.js","sourceRoot":"","sources":["../../../src/middleware/data-store.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;AAEH;;;GAGG;AACH,yDAAuC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2025, Salesforce, Inc.
|
|
4
|
+
* SPDX-License-Identifier: Apache-2
|
|
5
|
+
* For full license text, see the license.txt file in the repo root or http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
*/
|
|
7
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
8
|
+
if (k2 === undefined) k2 = k;
|
|
9
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
10
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
11
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
12
|
+
}
|
|
13
|
+
Object.defineProperty(o, k2, desc);
|
|
14
|
+
}) : (function(o, m, k, k2) {
|
|
15
|
+
if (k2 === undefined) k2 = k;
|
|
16
|
+
o[k2] = m[k];
|
|
17
|
+
}));
|
|
18
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
19
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
20
|
+
};
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
__exportStar(require("./middleware.js"), exports);
|
|
23
|
+
//# sourceMappingURL=express.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"express.js","sourceRoot":"","sources":["../../../src/middleware/express.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;AAEH,kDAAgC"}
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
export * from '
|
|
2
|
-
export * from './
|
|
3
|
-
export { type ProxyConfig } from '../utils/configure-proxying.js';
|
|
1
|
+
export * from '../data-store/index.js';
|
|
2
|
+
export * from './express.js';
|
|
@@ -1,8 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
/*
|
|
2
3
|
* Copyright (c) 2025, Salesforce, Inc.
|
|
3
4
|
* SPDX-License-Identifier: Apache-2
|
|
4
5
|
* For full license text, see the license.txt file in the repo root or http://www.apache.org/licenses/LICENSE-2.0
|
|
5
6
|
*/
|
|
6
|
-
|
|
7
|
-
|
|
7
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
8
|
+
if (k2 === undefined) k2 = k;
|
|
9
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
10
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
11
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
12
|
+
}
|
|
13
|
+
Object.defineProperty(o, k2, desc);
|
|
14
|
+
}) : (function(o, m, k, k2) {
|
|
15
|
+
if (k2 === undefined) k2 = k;
|
|
16
|
+
o[k2] = m[k];
|
|
17
|
+
}));
|
|
18
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
19
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
20
|
+
};
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
__exportStar(require("../data-store/index.js"), exports);
|
|
23
|
+
__exportStar(require("./express.js"), exports);
|
|
8
24
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/middleware/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/middleware/index.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;AAEH,yDAAuC;AACvC,+CAA6B"}
|