@adtrackify/at-service-common 1.0.16 → 1.0.17
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 +125 -6
- package/dist/index.js +73 -25
- package/dist/index.js.map +4 -4
- package/package.json +1 -1
- package/src/clients/{eventbridge-client.ts → generic/eventbridge-client.ts} +1 -1
- package/src/clients/{http-client.ts → generic/http-client.ts} +5 -5
- package/src/clients/generic/index.ts +3 -0
- package/src/clients/index.ts +2 -3
- package/src/clients/internal-api/destinations-client.ts +51 -0
- package/src/clients/internal-api/index.ts +1 -0
- package/src/types/api-response.ts +6 -0
- package/src/types/db/destination.ts +35 -0
- package/src/types/db/destinations.ts +6 -0
- package/src/types/db/index.ts +3 -1
- /package/src/clients/{axios.d.ts → generic/axios.d.ts} +0 -0
- /package/src/clients/{dynamodb-client.ts → generic/dynamodb-client.ts} +0 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
declare module '@adtrackify/at-service-common/clients/dynamodb-client' {
|
|
1
|
+
declare module '@adtrackify/at-service-common/clients/generic/dynamodb-client' {
|
|
2
2
|
import AWS from 'aws-sdk';
|
|
3
3
|
export class DynamoDbClient {
|
|
4
4
|
static safeGet: (tableName: string, keyName: string, keyValue: any) => Promise<AWS.DynamoDB.DocumentClient.AttributeMap | null>;
|
|
@@ -16,7 +16,7 @@ declare module '@adtrackify/at-service-common/clients/dynamodb-client' {
|
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
}
|
|
19
|
-
declare module '@adtrackify/at-service-common/clients/eventbridge-client' {
|
|
19
|
+
declare module '@adtrackify/at-service-common/clients/generic/eventbridge-client' {
|
|
20
20
|
import { EventBridge } from 'aws-sdk';
|
|
21
21
|
export class EventBridgeClient {
|
|
22
22
|
eventBridge: EventBridge;
|
|
@@ -32,7 +32,7 @@ declare module '@adtrackify/at-service-common/clients/eventbridge-client' {
|
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
}
|
|
35
|
-
declare module '@adtrackify/at-service-common/clients/http-client' {
|
|
35
|
+
declare module '@adtrackify/at-service-common/clients/generic/http-client' {
|
|
36
36
|
export const axiosHttpService: (config?: any) => {
|
|
37
37
|
instance: () => import("axios").AxiosInstance;
|
|
38
38
|
get: (url: string, config?: any) => Promise<{
|
|
@@ -63,11 +63,74 @@ declare module '@adtrackify/at-service-common/clients/http-client' {
|
|
|
63
63
|
setBaseUrl: (url: string) => boolean;
|
|
64
64
|
};
|
|
65
65
|
|
|
66
|
+
}
|
|
67
|
+
declare module '@adtrackify/at-service-common/clients/generic/index' {
|
|
68
|
+
export * from '@adtrackify/at-service-common/clients/generic/dynamodb-client';
|
|
69
|
+
export * from '@adtrackify/at-service-common/clients/generic/eventbridge-client';
|
|
70
|
+
export * from '@adtrackify/at-service-common/clients/generic/http-client';
|
|
71
|
+
|
|
66
72
|
}
|
|
67
73
|
declare module '@adtrackify/at-service-common/clients/index' {
|
|
68
|
-
export * from '@adtrackify/at-service-common/clients/
|
|
69
|
-
export * from '@adtrackify/at-service-common/clients/
|
|
70
|
-
|
|
74
|
+
export * from '@adtrackify/at-service-common/clients/generic/index';
|
|
75
|
+
export * from '@adtrackify/at-service-common/clients/internal-api/index';
|
|
76
|
+
|
|
77
|
+
}
|
|
78
|
+
declare module '@adtrackify/at-service-common/clients/internal-api/destinations-client' {
|
|
79
|
+
import { Destination } from 'aws-sdk/clients/lexmodelbuildingservice';
|
|
80
|
+
import { ApiResponse } from '@adtrackify/at-service-common/types/api-response';
|
|
81
|
+
export class DestinationsClient {
|
|
82
|
+
BASE_API_URL: string;
|
|
83
|
+
DESTINATIONS_API_KEY: string;
|
|
84
|
+
constructor(baseApiUrl: string, destinationsApiKey: string);
|
|
85
|
+
getConfig: () => {
|
|
86
|
+
baseURL: string;
|
|
87
|
+
headers: {
|
|
88
|
+
common: {
|
|
89
|
+
'x-api-key': string;
|
|
90
|
+
};
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
getClient: () => Promise<{
|
|
94
|
+
instance: () => import("axios").AxiosInstance;
|
|
95
|
+
get: (url: string, config?: any) => Promise<{
|
|
96
|
+
headers: any;
|
|
97
|
+
data: any;
|
|
98
|
+
status: any;
|
|
99
|
+
}>;
|
|
100
|
+
post: (url: string, data?: any, config?: any) => Promise<{
|
|
101
|
+
headers: any;
|
|
102
|
+
data: any;
|
|
103
|
+
status: any;
|
|
104
|
+
}>;
|
|
105
|
+
delete: (url: string, config?: any) => Promise<{
|
|
106
|
+
headers: any;
|
|
107
|
+
data: any;
|
|
108
|
+
status: any;
|
|
109
|
+
}>;
|
|
110
|
+
put: (url: string, data?: any, config?: any) => Promise<{
|
|
111
|
+
headers: any;
|
|
112
|
+
data: any;
|
|
113
|
+
status: any;
|
|
114
|
+
}>;
|
|
115
|
+
patch: (url: string, data?: any, config?: any) => Promise<{
|
|
116
|
+
headers: any;
|
|
117
|
+
data: any;
|
|
118
|
+
status: any;
|
|
119
|
+
}>;
|
|
120
|
+
setBaseUrl: (url: string) => boolean;
|
|
121
|
+
}>;
|
|
122
|
+
createDestination: (createDestinationRequest: any) => Promise<ApiResponse<{
|
|
123
|
+
destination: Destination;
|
|
124
|
+
} | any>>;
|
|
125
|
+
getPixelDestinations: (pixelId: string) => Promise<ApiResponse<{
|
|
126
|
+
destinations: Destination[];
|
|
127
|
+
} | any>>;
|
|
128
|
+
}
|
|
129
|
+
export default DestinationsClient;
|
|
130
|
+
|
|
131
|
+
}
|
|
132
|
+
declare module '@adtrackify/at-service-common/clients/internal-api/index' {
|
|
133
|
+
export * from '@adtrackify/at-service-common/clients/internal-api/destinations-client';
|
|
71
134
|
|
|
72
135
|
}
|
|
73
136
|
declare module '@adtrackify/at-service-common/helpers/index' {
|
|
@@ -232,9 +295,65 @@ declare module '@adtrackify/at-service-common/libs/index' {
|
|
|
232
295
|
export * from '@adtrackify/at-service-common/libs/http-error';
|
|
233
296
|
export * from '@adtrackify/at-service-common/libs/http-status-codes';
|
|
234
297
|
|
|
298
|
+
}
|
|
299
|
+
declare module '@adtrackify/at-service-common/types/api-response' {
|
|
300
|
+
import { AxiosResponseHeaders } from 'axios';
|
|
301
|
+
export interface ApiResponse<T> {
|
|
302
|
+
data: T;
|
|
303
|
+
status: number;
|
|
304
|
+
headers?: AxiosResponseHeaders;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
}
|
|
308
|
+
declare module '@adtrackify/at-service-common/types/db/destination' {
|
|
309
|
+
export interface Destination {
|
|
310
|
+
id: string;
|
|
311
|
+
accountId: string;
|
|
312
|
+
pixelId: string;
|
|
313
|
+
destination: string;
|
|
314
|
+
displayName?: string;
|
|
315
|
+
enabled: boolean;
|
|
316
|
+
configuration: any;
|
|
317
|
+
createdAt: string;
|
|
318
|
+
updatedAt: string;
|
|
319
|
+
}
|
|
320
|
+
export interface DestinationCatalogItem {
|
|
321
|
+
id: string;
|
|
322
|
+
active: boolean;
|
|
323
|
+
destinationKey: string;
|
|
324
|
+
destinationType: string;
|
|
325
|
+
displayName: string;
|
|
326
|
+
shortName: string;
|
|
327
|
+
description?: string;
|
|
328
|
+
url: string;
|
|
329
|
+
fields?: any;
|
|
330
|
+
createdAt: string;
|
|
331
|
+
updatedAt: string;
|
|
332
|
+
}
|
|
333
|
+
export interface DestinationCatalogFields {
|
|
334
|
+
component_type: string;
|
|
335
|
+
name: string;
|
|
336
|
+
description: string;
|
|
337
|
+
label: string;
|
|
338
|
+
type: string;
|
|
339
|
+
required: boolean;
|
|
340
|
+
order: number;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
}
|
|
344
|
+
declare module '@adtrackify/at-service-common/types/db/destinations' {
|
|
345
|
+
export enum DESTINATIONS {
|
|
346
|
+
FACEBOOK = "facebook",
|
|
347
|
+
TIKTOK = "tiktok",
|
|
348
|
+
GOOGLE_ADS = "googleAds",
|
|
349
|
+
GOOGLE_ANALYTICS_4 = "googleAnalytics4"
|
|
350
|
+
}
|
|
351
|
+
|
|
235
352
|
}
|
|
236
353
|
declare module '@adtrackify/at-service-common/types/db/index' {
|
|
237
354
|
export * from '@adtrackify/at-service-common/types/db/shopify-app-install';
|
|
355
|
+
export * from '@adtrackify/at-service-common/types/db/destination';
|
|
356
|
+
export * from '@adtrackify/at-service-common/types/db/destinations';
|
|
238
357
|
|
|
239
358
|
}
|
|
240
359
|
declare module '@adtrackify/at-service-common/types/db/shopify-app-install' {
|
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(info4) {
|
|
240272
240272
|
var upload = this._managedUpload;
|
|
240273
240273
|
if (this.operation === "putObject") {
|
|
240274
|
-
|
|
240275
|
-
|
|
240274
|
+
info4.part = 1;
|
|
240275
|
+
info4.key = this.params.Key;
|
|
240276
240276
|
} else {
|
|
240277
|
-
upload.totalUploadedBytes +=
|
|
240278
|
-
this._lastUploadedBytes =
|
|
240279
|
-
|
|
240277
|
+
upload.totalUploadedBytes += info4.loaded - this._lastUploadedBytes;
|
|
240278
|
+
this._lastUploadedBytes = info4.loaded;
|
|
240279
|
+
info4 = {
|
|
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", [info4]);
|
|
240287
240287
|
}
|
|
240288
240288
|
});
|
|
240289
240289
|
AWS3.util.mixin(AWS3.S3.ManagedUpload, AWS3.SequentialExecutor);
|
|
@@ -627932,7 +627932,7 @@ var require_dist2 = __commonJS({
|
|
|
627932
627932
|
}
|
|
627933
627933
|
});
|
|
627934
627934
|
|
|
627935
|
-
// src/clients/dynamodb-client.ts
|
|
627935
|
+
// src/clients/generic/dynamodb-client.ts
|
|
627936
627936
|
var import_aws_sdk = __toESM(require_aws());
|
|
627937
627937
|
import * as log from "lambda-log";
|
|
627938
627938
|
var client = new import_aws_sdk.default.DynamoDB.DocumentClient();
|
|
@@ -628028,7 +628028,7 @@ __publicField(DynamoDbClient, "scan", (params) => client.scan(params).promise())
|
|
|
628028
628028
|
__publicField(DynamoDbClient, "update", (params) => client.update(params).promise());
|
|
628029
628029
|
__publicField(DynamoDbClient, "delete", (params) => client.delete(params).promise());
|
|
628030
628030
|
|
|
628031
|
-
// src/clients/eventbridge-client.ts
|
|
628031
|
+
// src/clients/generic/eventbridge-client.ts
|
|
628032
628032
|
var import_aws_sdk2 = __toESM(require_aws());
|
|
628033
628033
|
|
|
628034
628034
|
// node_modules/uuid/wrapper.mjs
|
|
@@ -628055,7 +628055,7 @@ var getCurrentDate = () => {
|
|
|
628055
628055
|
return getDateFromTimestamp(getCurrentTimestamp());
|
|
628056
628056
|
};
|
|
628057
628057
|
|
|
628058
|
-
// src/clients/eventbridge-client.ts
|
|
628058
|
+
// src/clients/generic/eventbridge-client.ts
|
|
628059
628059
|
var EventBridgeClient = class {
|
|
628060
628060
|
eventBridge;
|
|
628061
628061
|
EVENT_BUS_NAME;
|
|
@@ -628085,7 +628085,7 @@ var EventBridgeClient = class {
|
|
|
628085
628085
|
};
|
|
628086
628086
|
};
|
|
628087
628087
|
|
|
628088
|
-
// src/clients/http-client.ts
|
|
628088
|
+
// src/clients/generic/http-client.ts
|
|
628089
628089
|
import axios from "axios";
|
|
628090
628090
|
import axiosRetry from "axios-retry";
|
|
628091
628091
|
import https from "https";
|
|
@@ -628097,16 +628097,16 @@ var httpResponse = (res = {}) => {
|
|
|
628097
628097
|
status: res?.status || 0
|
|
628098
628098
|
};
|
|
628099
628099
|
};
|
|
628100
|
+
var handleAxiosError = (error2) => {
|
|
628101
|
+
if (!error2?.response && !error2?.request)
|
|
628102
|
+
throw error2;
|
|
628103
|
+
return error2.response ? httpResponse(error2.response) : httpResponse({ status: 500, data: { error: error2.request } });
|
|
628104
|
+
};
|
|
628100
628105
|
var axiosHttpService = (config = {}) => {
|
|
628101
628106
|
config.adapter = httpAdapter;
|
|
628102
628107
|
config.httpsAgent = new https.Agent({ keepAlive: true });
|
|
628103
628108
|
const axiosService = axios.create(config);
|
|
628104
628109
|
axiosRetry(axiosService, { retryDelay: axiosRetry.exponentialDelay, retries: 3 });
|
|
628105
|
-
const handleAxiosError = (error2) => {
|
|
628106
|
-
if (!error2?.response && !error2?.request)
|
|
628107
|
-
throw error2;
|
|
628108
|
-
return error2.response ? httpResponse(error2.response) : httpResponse({ status: 500, data: { error: error2.request } });
|
|
628109
|
-
};
|
|
628110
628110
|
return {
|
|
628111
628111
|
instance: () => axiosService,
|
|
628112
628112
|
get: (url, config2) => axiosService.get(url, config2).then(httpResponse, handleAxiosError),
|
|
@@ -628118,6 +628118,43 @@ 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
|
+
var DestinationsClient = class {
|
|
628124
|
+
BASE_API_URL;
|
|
628125
|
+
DESTINATIONS_API_KEY;
|
|
628126
|
+
constructor(baseApiUrl, destinationsApiKey) {
|
|
628127
|
+
this.BASE_API_URL = baseApiUrl;
|
|
628128
|
+
this.DESTINATIONS_API_KEY = destinationsApiKey;
|
|
628129
|
+
}
|
|
628130
|
+
getConfig = () => {
|
|
628131
|
+
const SERVICE_API_ROOT_URL = `${this.BASE_API_URL}/destinations`;
|
|
628132
|
+
return {
|
|
628133
|
+
baseURL: SERVICE_API_ROOT_URL,
|
|
628134
|
+
headers: {
|
|
628135
|
+
common: {
|
|
628136
|
+
"x-api-key": this.DESTINATIONS_API_KEY
|
|
628137
|
+
}
|
|
628138
|
+
}
|
|
628139
|
+
};
|
|
628140
|
+
};
|
|
628141
|
+
getClient = async () => {
|
|
628142
|
+
return axiosHttpService(this.getConfig());
|
|
628143
|
+
};
|
|
628144
|
+
createDestination = async (createDestinationRequest) => {
|
|
628145
|
+
const client2 = await this.getClient();
|
|
628146
|
+
const createDestinationResponse = await client2.post("/", createDestinationRequest);
|
|
628147
|
+
log2.info("createDestinationResponse", { createDestinationResponse });
|
|
628148
|
+
return createDestinationResponse;
|
|
628149
|
+
};
|
|
628150
|
+
getPixelDestinations = async (pixelId) => {
|
|
628151
|
+
const client2 = await this.getClient();
|
|
628152
|
+
const pixelDestinationsResponse = await client2.get(`/?pixelId=${pixelId}`);
|
|
628153
|
+
log2.info("pixelDestinationsResponse", { pixelDestinationsResponse });
|
|
628154
|
+
return pixelDestinationsResponse;
|
|
628155
|
+
};
|
|
628156
|
+
};
|
|
628157
|
+
|
|
628121
628158
|
// src/libs/http-error.ts
|
|
628122
628159
|
import { strict as assert } from "assert";
|
|
628123
628160
|
var deepClone = (o = {}) => JSON.parse(JSON.stringify(o));
|
|
@@ -628200,11 +628237,11 @@ __publicField(HttpError, "serviceUnavailable", (headers) => new _HttpError(503,
|
|
|
628200
628237
|
__publicField(HttpError, "gatewayTimeout", () => new _HttpError(504));
|
|
628201
628238
|
|
|
628202
628239
|
// src/helpers/input-validation-helper.ts
|
|
628203
|
-
import * as
|
|
628240
|
+
import * as log3 from "lambda-log";
|
|
628204
628241
|
var validateInput = (schema, input) => {
|
|
628205
628242
|
const { error: error2, value } = schema.validate(input);
|
|
628206
628243
|
if (error2) {
|
|
628207
|
-
|
|
628244
|
+
log3.info("", { error: error2 });
|
|
628208
628245
|
const httperr = HttpError.badRequest("Input Validation Failure", {
|
|
628209
628246
|
errors: error2.details.map((detail) => ({
|
|
628210
628247
|
message: detail?.message,
|
|
@@ -628212,21 +628249,21 @@ var validateInput = (schema, input) => {
|
|
|
628212
628249
|
path: detail?.path
|
|
628213
628250
|
}))
|
|
628214
628251
|
});
|
|
628215
|
-
|
|
628252
|
+
log3.info("", { httperr });
|
|
628216
628253
|
throw httperr;
|
|
628217
628254
|
}
|
|
628218
628255
|
return value;
|
|
628219
628256
|
};
|
|
628220
628257
|
|
|
628221
628258
|
// src/helpers/logging-helper.ts
|
|
628222
|
-
import * as
|
|
628259
|
+
import * as log4 from "lambda-log";
|
|
628223
628260
|
var stage = process?.env?.STAGE;
|
|
628224
628261
|
var configureLogger = (event, context, debug = true) => {
|
|
628225
|
-
|
|
628226
|
-
|
|
628227
|
-
|
|
628228
|
-
|
|
628229
|
-
|
|
628262
|
+
log4.options.meta.stage = stage;
|
|
628263
|
+
log4.options.meta.source_name = context?.functionName || "unknown";
|
|
628264
|
+
log4.options.meta.awsRequestId = context?.awsRequestId || "unknown";
|
|
628265
|
+
log4.options.meta.lambdaEvent = event;
|
|
628266
|
+
log4.options.debug = debug;
|
|
628230
628267
|
};
|
|
628231
628268
|
|
|
628232
628269
|
// src/helpers/response-helper.ts
|
|
@@ -628331,7 +628368,18 @@ var HttpStatusCodes = /* @__PURE__ */ ((HttpStatusCodes2) => {
|
|
|
628331
628368
|
HttpStatusCodes2[HttpStatusCodes2["NETWORK_AUTHENTICATION_REQUIRED"] = 511] = "NETWORK_AUTHENTICATION_REQUIRED";
|
|
628332
628369
|
return HttpStatusCodes2;
|
|
628333
628370
|
})(HttpStatusCodes || {});
|
|
628371
|
+
|
|
628372
|
+
// src/types/db/destinations.ts
|
|
628373
|
+
var DESTINATIONS = /* @__PURE__ */ ((DESTINATIONS2) => {
|
|
628374
|
+
DESTINATIONS2["FACEBOOK"] = "facebook";
|
|
628375
|
+
DESTINATIONS2["TIKTOK"] = "tiktok";
|
|
628376
|
+
DESTINATIONS2["GOOGLE_ADS"] = "googleAds";
|
|
628377
|
+
DESTINATIONS2["GOOGLE_ANALYTICS_4"] = "googleAnalytics4";
|
|
628378
|
+
return DESTINATIONS2;
|
|
628379
|
+
})(DESTINATIONS || {});
|
|
628334
628380
|
export {
|
|
628381
|
+
DESTINATIONS,
|
|
628382
|
+
DestinationsClient,
|
|
628335
628383
|
DynamoDbClient,
|
|
628336
628384
|
EventBridgeClient,
|
|
628337
628385
|
HttpError,
|