@adtrackify/at-service-common 1.0.19 → 1.0.21
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/index.d.ts +4 -3
- package/dist/index.js +79 -123
- package/dist/index.js.map +4 -4
- package/package.json +1 -1
- package/src/clients/internal-api/destinations-client.ts +9 -5
- package/src/index.ts +1 -1
- package/src/types/api-response.ts +3 -1
package/dist/index.d.ts
CHANGED
|
@@ -77,7 +77,7 @@ declare module '@adtrackify/at-service-common/clients/index' {
|
|
|
77
77
|
}
|
|
78
78
|
declare module '@adtrackify/at-service-common/clients/internal-api/destinations-client' {
|
|
79
79
|
import { Destination } from 'aws-sdk/clients/lexmodelbuildingservice';
|
|
80
|
-
import { ApiResponse } from '@adtrackify/at-service-common/types/api-response';
|
|
80
|
+
import { ApiResponse, ErrorData } from '@adtrackify/at-service-common/types/api-response';
|
|
81
81
|
export class DestinationsClient {
|
|
82
82
|
BASE_API_URL: string;
|
|
83
83
|
DESTINATIONS_API_KEY: string;
|
|
@@ -124,7 +124,7 @@ declare module '@adtrackify/at-service-common/clients/internal-api/destinations-
|
|
|
124
124
|
} | any>>;
|
|
125
125
|
getPixelDestinations: (pixelId: string) => Promise<ApiResponse<{
|
|
126
126
|
destinations: Destination[];
|
|
127
|
-
} |
|
|
127
|
+
} | ErrorData>>;
|
|
128
128
|
}
|
|
129
129
|
export default DestinationsClient;
|
|
130
130
|
|
|
@@ -188,7 +188,7 @@ declare module '@adtrackify/at-service-common/helpers/response-helper' {
|
|
|
188
188
|
|
|
189
189
|
}
|
|
190
190
|
declare module '@adtrackify/at-service-common/index' {
|
|
191
|
-
export * from '@adtrackify/at-service-common/clients/index';
|
|
191
|
+
export * from '@adtrackify/at-service-common/clients/generic/index';
|
|
192
192
|
export * from '@adtrackify/at-service-common/helpers/index';
|
|
193
193
|
export * from '@adtrackify/at-service-common/libs/index';
|
|
194
194
|
export * from '@adtrackify/at-service-common/types/index';
|
|
@@ -303,6 +303,7 @@ declare module '@adtrackify/at-service-common/types/api-response' {
|
|
|
303
303
|
status: number;
|
|
304
304
|
headers?: AxiosResponseHeaders;
|
|
305
305
|
}
|
|
306
|
+
export type ErrorData = any;
|
|
306
307
|
|
|
307
308
|
}
|
|
308
309
|
declare module '@adtrackify/at-service-common/types/db/destination' {
|
package/dist/index.js
CHANGED
|
@@ -240268,22 +240268,22 @@ var require_managed_upload = __commonJS({
|
|
|
240268
240268
|
data.Bucket = this.request.params.Bucket;
|
|
240269
240269
|
upload.callback(err, data);
|
|
240270
240270
|
},
|
|
240271
|
-
progress: function progress(
|
|
240271
|
+
progress: function progress(info3) {
|
|
240272
240272
|
var upload = this._managedUpload;
|
|
240273
240273
|
if (this.operation === "putObject") {
|
|
240274
|
-
|
|
240275
|
-
|
|
240274
|
+
info3.part = 1;
|
|
240275
|
+
info3.key = this.params.Key;
|
|
240276
240276
|
} else {
|
|
240277
|
-
upload.totalUploadedBytes +=
|
|
240278
|
-
this._lastUploadedBytes =
|
|
240279
|
-
|
|
240277
|
+
upload.totalUploadedBytes += info3.loaded - this._lastUploadedBytes;
|
|
240278
|
+
this._lastUploadedBytes = info3.loaded;
|
|
240279
|
+
info3 = {
|
|
240280
240280
|
loaded: upload.totalUploadedBytes,
|
|
240281
240281
|
total: upload.totalBytes,
|
|
240282
240282
|
part: this.params.PartNumber,
|
|
240283
240283
|
key: this.params.Key
|
|
240284
240284
|
};
|
|
240285
240285
|
}
|
|
240286
|
-
upload.emit("httpUploadProgress", [
|
|
240286
|
+
upload.emit("httpUploadProgress", [info3]);
|
|
240287
240287
|
}
|
|
240288
240288
|
});
|
|
240289
240289
|
AWS3.util.mixin(AWS3.S3.ManagedUpload, AWS3.SequentialExecutor);
|
|
@@ -628118,16 +628118,6 @@ var axiosHttpService = (config = {}) => {
|
|
|
628118
628118
|
};
|
|
628119
628119
|
};
|
|
628120
628120
|
|
|
628121
|
-
// src/clients/internal-api/destinations-client.ts
|
|
628122
|
-
import * as log2 from "lambda-log";
|
|
628123
|
-
|
|
628124
|
-
// src/libs/crypto.ts
|
|
628125
|
-
import crypto from "crypto";
|
|
628126
|
-
var generatePublicKey = () => {
|
|
628127
|
-
const publicKey = crypto.randomBytes(26);
|
|
628128
|
-
return publicKey.toString("utf8");
|
|
628129
|
-
};
|
|
628130
|
-
|
|
628131
628121
|
// src/libs/http-error.ts
|
|
628132
628122
|
import { strict as assert } from "assert";
|
|
628133
628123
|
var deepClone = (o = {}) => JSON.parse(JSON.stringify(o));
|
|
@@ -628209,6 +628199,78 @@ __publicField(HttpError, "badGateway", () => new _HttpError(502));
|
|
|
628209
628199
|
__publicField(HttpError, "serviceUnavailable", (headers) => new _HttpError(503, void 0, void 0, headers));
|
|
628210
628200
|
__publicField(HttpError, "gatewayTimeout", () => new _HttpError(504));
|
|
628211
628201
|
|
|
628202
|
+
// src/helpers/input-validation-helper.ts
|
|
628203
|
+
import * as log2 from "lambda-log";
|
|
628204
|
+
var validateInput = (schema, input) => {
|
|
628205
|
+
const { error: error2, value } = schema.validate(input);
|
|
628206
|
+
if (error2) {
|
|
628207
|
+
log2.info("", { error: error2 });
|
|
628208
|
+
const httperr = HttpError.badRequest("Input Validation Failure", {
|
|
628209
|
+
errors: error2.details.map((detail) => ({
|
|
628210
|
+
message: detail?.message,
|
|
628211
|
+
key: detail?.context?.key,
|
|
628212
|
+
path: detail?.path
|
|
628213
|
+
}))
|
|
628214
|
+
});
|
|
628215
|
+
log2.info("", { httperr });
|
|
628216
|
+
throw httperr;
|
|
628217
|
+
}
|
|
628218
|
+
return value;
|
|
628219
|
+
};
|
|
628220
|
+
|
|
628221
|
+
// src/helpers/logging-helper.ts
|
|
628222
|
+
import * as log3 from "lambda-log";
|
|
628223
|
+
var stage = process?.env?.STAGE;
|
|
628224
|
+
var configureLogger = (event, context, debug = true) => {
|
|
628225
|
+
log3.options.meta.stage = stage;
|
|
628226
|
+
log3.options.meta.source_name = context?.functionName || "unknown";
|
|
628227
|
+
log3.options.meta.awsRequestId = context?.awsRequestId || "unknown";
|
|
628228
|
+
log3.options.meta.lambdaEvent = event;
|
|
628229
|
+
log3.options.debug = debug;
|
|
628230
|
+
};
|
|
628231
|
+
|
|
628232
|
+
// src/helpers/response-helper.ts
|
|
628233
|
+
var success = (body) => {
|
|
628234
|
+
return buildResponse(200, body);
|
|
628235
|
+
};
|
|
628236
|
+
var defaultError = {
|
|
628237
|
+
message: "internalServerError"
|
|
628238
|
+
};
|
|
628239
|
+
var failure = (error2, statusCode = 500) => {
|
|
628240
|
+
statusCode = error2?.statusCode ?? statusCode;
|
|
628241
|
+
let body = defaultError;
|
|
628242
|
+
if (error2?.body) {
|
|
628243
|
+
body = error2.body;
|
|
628244
|
+
} else if (error2?.message) {
|
|
628245
|
+
body = { message: error2.message };
|
|
628246
|
+
} else if (statusCode === 500) {
|
|
628247
|
+
body = defaultError;
|
|
628248
|
+
}
|
|
628249
|
+
return buildResponse(statusCode, body);
|
|
628250
|
+
};
|
|
628251
|
+
var buildResponse = (statusCode, body = {}) => {
|
|
628252
|
+
delete body.stack;
|
|
628253
|
+
return {
|
|
628254
|
+
statusCode,
|
|
628255
|
+
headers: {
|
|
628256
|
+
"Access-Control-Allow-Origin": "*",
|
|
628257
|
+
"Access-Control-Allow-Credentials": true,
|
|
628258
|
+
"cache-control": "max-age=86400",
|
|
628259
|
+
Date: new Date(),
|
|
628260
|
+
"Last-Modified": new Date(),
|
|
628261
|
+
"Access-Control-Allow-Headers": "Content-Type, Content-Encoding"
|
|
628262
|
+
},
|
|
628263
|
+
body: JSON.stringify(body)
|
|
628264
|
+
};
|
|
628265
|
+
};
|
|
628266
|
+
|
|
628267
|
+
// src/libs/crypto.ts
|
|
628268
|
+
import crypto from "crypto";
|
|
628269
|
+
var generatePublicKey = () => {
|
|
628270
|
+
const publicKey = crypto.randomBytes(26);
|
|
628271
|
+
return publicKey.toString("utf8");
|
|
628272
|
+
};
|
|
628273
|
+
|
|
628212
628274
|
// src/libs/http-status-codes.ts
|
|
628213
628275
|
var HttpStatusCodes = /* @__PURE__ */ ((HttpStatusCodes2) => {
|
|
628214
628276
|
HttpStatusCodes2[HttpStatusCodes2["CONTINUE"] = 100] = "CONTINUE";
|
|
@@ -628270,111 +628332,6 @@ var HttpStatusCodes = /* @__PURE__ */ ((HttpStatusCodes2) => {
|
|
|
628270
628332
|
return HttpStatusCodes2;
|
|
628271
628333
|
})(HttpStatusCodes || {});
|
|
628272
628334
|
|
|
628273
|
-
// src/clients/internal-api/destinations-client.ts
|
|
628274
|
-
var DestinationsClient = class {
|
|
628275
|
-
BASE_API_URL;
|
|
628276
|
-
DESTINATIONS_API_KEY;
|
|
628277
|
-
constructor(baseApiUrl, destinationsApiKey) {
|
|
628278
|
-
this.BASE_API_URL = baseApiUrl;
|
|
628279
|
-
this.DESTINATIONS_API_KEY = destinationsApiKey;
|
|
628280
|
-
}
|
|
628281
|
-
getConfig = () => {
|
|
628282
|
-
const SERVICE_API_ROOT_URL = `${this.BASE_API_URL}/destinations`;
|
|
628283
|
-
return {
|
|
628284
|
-
baseURL: SERVICE_API_ROOT_URL,
|
|
628285
|
-
headers: {
|
|
628286
|
-
common: {
|
|
628287
|
-
"x-api-key": this.DESTINATIONS_API_KEY
|
|
628288
|
-
}
|
|
628289
|
-
}
|
|
628290
|
-
};
|
|
628291
|
-
};
|
|
628292
|
-
getClient = async () => {
|
|
628293
|
-
return axiosHttpService(this.getConfig());
|
|
628294
|
-
};
|
|
628295
|
-
createDestination = async (createDestinationRequest) => {
|
|
628296
|
-
const client2 = await this.getClient();
|
|
628297
|
-
const createDestinationResponse = await client2.post("/", createDestinationRequest);
|
|
628298
|
-
log2.info("createDestinationResponse", { createDestinationResponse });
|
|
628299
|
-
return {
|
|
628300
|
-
status: createDestinationResponse.status,
|
|
628301
|
-
headers: createDestinationResponse.headers,
|
|
628302
|
-
data: createDestinationResponse.status === 200 /* OK */ ? createDestinationResponse.data : createDestinationResponse.data
|
|
628303
|
-
};
|
|
628304
|
-
};
|
|
628305
|
-
getPixelDestinations = async (pixelId) => {
|
|
628306
|
-
const client2 = await this.getClient();
|
|
628307
|
-
const pixelDestinationsResponse = await client2.get(`/?pixelId=${pixelId}`);
|
|
628308
|
-
log2.info("pixelDestinationsResponse", { pixelDestinationsResponse });
|
|
628309
|
-
return pixelDestinationsResponse;
|
|
628310
|
-
};
|
|
628311
|
-
};
|
|
628312
|
-
|
|
628313
|
-
// src/helpers/input-validation-helper.ts
|
|
628314
|
-
import * as log3 from "lambda-log";
|
|
628315
|
-
var validateInput = (schema, input) => {
|
|
628316
|
-
const { error: error2, value } = schema.validate(input);
|
|
628317
|
-
if (error2) {
|
|
628318
|
-
log3.info("", { error: error2 });
|
|
628319
|
-
const httperr = HttpError.badRequest("Input Validation Failure", {
|
|
628320
|
-
errors: error2.details.map((detail) => ({
|
|
628321
|
-
message: detail?.message,
|
|
628322
|
-
key: detail?.context?.key,
|
|
628323
|
-
path: detail?.path
|
|
628324
|
-
}))
|
|
628325
|
-
});
|
|
628326
|
-
log3.info("", { httperr });
|
|
628327
|
-
throw httperr;
|
|
628328
|
-
}
|
|
628329
|
-
return value;
|
|
628330
|
-
};
|
|
628331
|
-
|
|
628332
|
-
// src/helpers/logging-helper.ts
|
|
628333
|
-
import * as log4 from "lambda-log";
|
|
628334
|
-
var stage = process?.env?.STAGE;
|
|
628335
|
-
var configureLogger = (event, context, debug = true) => {
|
|
628336
|
-
log4.options.meta.stage = stage;
|
|
628337
|
-
log4.options.meta.source_name = context?.functionName || "unknown";
|
|
628338
|
-
log4.options.meta.awsRequestId = context?.awsRequestId || "unknown";
|
|
628339
|
-
log4.options.meta.lambdaEvent = event;
|
|
628340
|
-
log4.options.debug = debug;
|
|
628341
|
-
};
|
|
628342
|
-
|
|
628343
|
-
// src/helpers/response-helper.ts
|
|
628344
|
-
var success = (body) => {
|
|
628345
|
-
return buildResponse(200, body);
|
|
628346
|
-
};
|
|
628347
|
-
var defaultError = {
|
|
628348
|
-
message: "internalServerError"
|
|
628349
|
-
};
|
|
628350
|
-
var failure = (error2, statusCode = 500) => {
|
|
628351
|
-
statusCode = error2?.statusCode ?? statusCode;
|
|
628352
|
-
let body = defaultError;
|
|
628353
|
-
if (error2?.body) {
|
|
628354
|
-
body = error2.body;
|
|
628355
|
-
} else if (error2?.message) {
|
|
628356
|
-
body = { message: error2.message };
|
|
628357
|
-
} else if (statusCode === 500) {
|
|
628358
|
-
body = defaultError;
|
|
628359
|
-
}
|
|
628360
|
-
return buildResponse(statusCode, body);
|
|
628361
|
-
};
|
|
628362
|
-
var buildResponse = (statusCode, body = {}) => {
|
|
628363
|
-
delete body.stack;
|
|
628364
|
-
return {
|
|
628365
|
-
statusCode,
|
|
628366
|
-
headers: {
|
|
628367
|
-
"Access-Control-Allow-Origin": "*",
|
|
628368
|
-
"Access-Control-Allow-Credentials": true,
|
|
628369
|
-
"cache-control": "max-age=86400",
|
|
628370
|
-
Date: new Date(),
|
|
628371
|
-
"Last-Modified": new Date(),
|
|
628372
|
-
"Access-Control-Allow-Headers": "Content-Type, Content-Encoding"
|
|
628373
|
-
},
|
|
628374
|
-
body: JSON.stringify(body)
|
|
628375
|
-
};
|
|
628376
|
-
};
|
|
628377
|
-
|
|
628378
628335
|
// src/types/db/destinations.ts
|
|
628379
628336
|
var DESTINATIONS = /* @__PURE__ */ ((DESTINATIONS2) => {
|
|
628380
628337
|
DESTINATIONS2["FACEBOOK"] = "facebook";
|
|
@@ -628385,7 +628342,6 @@ var DESTINATIONS = /* @__PURE__ */ ((DESTINATIONS2) => {
|
|
|
628385
628342
|
})(DESTINATIONS || {});
|
|
628386
628343
|
export {
|
|
628387
628344
|
DESTINATIONS,
|
|
628388
|
-
DestinationsClient,
|
|
628389
628345
|
DynamoDbClient,
|
|
628390
628346
|
EventBridgeClient,
|
|
628391
628347
|
HttpError,
|