@adtrackify/at-service-common 1.0.20 → 1.0.22
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 +13 -9
- package/dist/index.js +79 -127
- package/dist/index.js.map +4 -4
- package/package.json +1 -1
- package/src/clients/internal-api/destinations-client.ts +15 -16
- package/src/index.ts +1 -1
- package/src/types/api-response.ts +1 -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
|
|
80
|
+
import { ApiResponse } 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;
|
|
@@ -119,12 +119,16 @@ declare module '@adtrackify/at-service-common/clients/internal-api/destinations-
|
|
|
119
119
|
}>;
|
|
120
120
|
setBaseUrl: (url: string) => boolean;
|
|
121
121
|
}>;
|
|
122
|
-
createDestination: (createDestinationRequest: any) => Promise<ApiResponse<
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
122
|
+
createDestination: (createDestinationRequest: any) => Promise<ApiResponse<CreateDestinationResponseData>>;
|
|
123
|
+
getPixelDestinations: (pixelId: string) => Promise<ApiResponse<GetDestinationsResponseData>>;
|
|
124
|
+
}
|
|
125
|
+
export interface GetDestinationsResponseData {
|
|
126
|
+
destinations: Destination[];
|
|
127
|
+
[key: string]: any;
|
|
128
|
+
}
|
|
129
|
+
export interface CreateDestinationResponseData {
|
|
130
|
+
destination: Destination;
|
|
131
|
+
[key: string]: any;
|
|
128
132
|
}
|
|
129
133
|
export default DestinationsClient;
|
|
130
134
|
|
|
@@ -188,7 +192,7 @@ declare module '@adtrackify/at-service-common/helpers/response-helper' {
|
|
|
188
192
|
|
|
189
193
|
}
|
|
190
194
|
declare module '@adtrackify/at-service-common/index' {
|
|
191
|
-
export * from '@adtrackify/at-service-common/clients/index';
|
|
195
|
+
export * from '@adtrackify/at-service-common/clients/generic/index';
|
|
192
196
|
export * from '@adtrackify/at-service-common/helpers/index';
|
|
193
197
|
export * from '@adtrackify/at-service-common/libs/index';
|
|
194
198
|
export * from '@adtrackify/at-service-common/types/index';
|
|
@@ -303,7 +307,7 @@ declare module '@adtrackify/at-service-common/types/api-response' {
|
|
|
303
307
|
status: number;
|
|
304
308
|
headers?: AxiosResponseHeaders;
|
|
305
309
|
}
|
|
306
|
-
export type ErrorData =
|
|
310
|
+
export type ErrorData = unknown;
|
|
307
311
|
|
|
308
312
|
}
|
|
309
313
|
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,115 +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 response = await client2.get(`/?pixelId=${pixelId}`);
|
|
628308
|
-
log2.info("getPixelResponse", { response });
|
|
628309
|
-
return {
|
|
628310
|
-
status: response.status,
|
|
628311
|
-
headers: response.headers,
|
|
628312
|
-
data: response.status === 200 /* OK */ ? response.data : response.data
|
|
628313
|
-
};
|
|
628314
|
-
};
|
|
628315
|
-
};
|
|
628316
|
-
|
|
628317
|
-
// src/helpers/input-validation-helper.ts
|
|
628318
|
-
import * as log3 from "lambda-log";
|
|
628319
|
-
var validateInput = (schema, input) => {
|
|
628320
|
-
const { error: error2, value } = schema.validate(input);
|
|
628321
|
-
if (error2) {
|
|
628322
|
-
log3.info("", { error: error2 });
|
|
628323
|
-
const httperr = HttpError.badRequest("Input Validation Failure", {
|
|
628324
|
-
errors: error2.details.map((detail) => ({
|
|
628325
|
-
message: detail?.message,
|
|
628326
|
-
key: detail?.context?.key,
|
|
628327
|
-
path: detail?.path
|
|
628328
|
-
}))
|
|
628329
|
-
});
|
|
628330
|
-
log3.info("", { httperr });
|
|
628331
|
-
throw httperr;
|
|
628332
|
-
}
|
|
628333
|
-
return value;
|
|
628334
|
-
};
|
|
628335
|
-
|
|
628336
|
-
// src/helpers/logging-helper.ts
|
|
628337
|
-
import * as log4 from "lambda-log";
|
|
628338
|
-
var stage = process?.env?.STAGE;
|
|
628339
|
-
var configureLogger = (event, context, debug = true) => {
|
|
628340
|
-
log4.options.meta.stage = stage;
|
|
628341
|
-
log4.options.meta.source_name = context?.functionName || "unknown";
|
|
628342
|
-
log4.options.meta.awsRequestId = context?.awsRequestId || "unknown";
|
|
628343
|
-
log4.options.meta.lambdaEvent = event;
|
|
628344
|
-
log4.options.debug = debug;
|
|
628345
|
-
};
|
|
628346
|
-
|
|
628347
|
-
// src/helpers/response-helper.ts
|
|
628348
|
-
var success = (body) => {
|
|
628349
|
-
return buildResponse(200, body);
|
|
628350
|
-
};
|
|
628351
|
-
var defaultError = {
|
|
628352
|
-
message: "internalServerError"
|
|
628353
|
-
};
|
|
628354
|
-
var failure = (error2, statusCode = 500) => {
|
|
628355
|
-
statusCode = error2?.statusCode ?? statusCode;
|
|
628356
|
-
let body = defaultError;
|
|
628357
|
-
if (error2?.body) {
|
|
628358
|
-
body = error2.body;
|
|
628359
|
-
} else if (error2?.message) {
|
|
628360
|
-
body = { message: error2.message };
|
|
628361
|
-
} else if (statusCode === 500) {
|
|
628362
|
-
body = defaultError;
|
|
628363
|
-
}
|
|
628364
|
-
return buildResponse(statusCode, body);
|
|
628365
|
-
};
|
|
628366
|
-
var buildResponse = (statusCode, body = {}) => {
|
|
628367
|
-
delete body.stack;
|
|
628368
|
-
return {
|
|
628369
|
-
statusCode,
|
|
628370
|
-
headers: {
|
|
628371
|
-
"Access-Control-Allow-Origin": "*",
|
|
628372
|
-
"Access-Control-Allow-Credentials": true,
|
|
628373
|
-
"cache-control": "max-age=86400",
|
|
628374
|
-
Date: new Date(),
|
|
628375
|
-
"Last-Modified": new Date(),
|
|
628376
|
-
"Access-Control-Allow-Headers": "Content-Type, Content-Encoding"
|
|
628377
|
-
},
|
|
628378
|
-
body: JSON.stringify(body)
|
|
628379
|
-
};
|
|
628380
|
-
};
|
|
628381
|
-
|
|
628382
628335
|
// src/types/db/destinations.ts
|
|
628383
628336
|
var DESTINATIONS = /* @__PURE__ */ ((DESTINATIONS2) => {
|
|
628384
628337
|
DESTINATIONS2["FACEBOOK"] = "facebook";
|
|
@@ -628389,7 +628342,6 @@ var DESTINATIONS = /* @__PURE__ */ ((DESTINATIONS2) => {
|
|
|
628389
628342
|
})(DESTINATIONS || {});
|
|
628390
628343
|
export {
|
|
628391
628344
|
DESTINATIONS,
|
|
628392
|
-
DestinationsClient,
|
|
628393
628345
|
DynamoDbClient,
|
|
628394
628346
|
EventBridgeClient,
|
|
628395
628347
|
HttpError,
|