@adtrackify/at-service-common 1.0.30 → 1.0.32

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 CHANGED
@@ -22,6 +22,7 @@ declare module '@adtrackify/at-service-common/clients/generic/eventbridge-client
22
22
  eventBridge: EventBridge;
23
23
  EVENT_BUS_NAME: string;
24
24
  constructor(eventBusName: string);
25
+ buildAndSendEvent: (eventSource: string, eventType: string, eventData: any) => Promise<import("aws-sdk/lib/request").PromiseResult<EventBridge.PutEventsResponse, import("aws-sdk").AWSError>>;
25
26
  buildEvent: (eventType: string, eventData: any, eventId?: string, eventTime?: string) => {
26
27
  eventId: string;
27
28
  eventType: string;
@@ -122,7 +123,22 @@ declare module '@adtrackify/at-service-common/clients/internal-api/accounts-clie
122
123
  }>;
123
124
  setBaseUrl: (url: string) => boolean;
124
125
  }>;
125
- isAuthorizedUser: (userId: string, accountId: string, pixelId: string) => Promise<ApiResponse<IsAuthorizedUserResponseData>>;
126
+ createAccount: (createAccountRequest: any) => Promise<{
127
+ headers: any;
128
+ data: any;
129
+ status: any;
130
+ }>;
131
+ addOwner: (accountId: string, userId: string) => Promise<{
132
+ headers: any;
133
+ data: any;
134
+ status: any;
135
+ }>;
136
+ isAuthorizedUser: (userId: string, accountId: string, pixelId?: string) => Promise<ApiResponse<IsAuthorizedUserResponseData>>;
137
+ adminDeleteAccount: (accountId: string) => Promise<{
138
+ headers: any;
139
+ data: any;
140
+ status: any;
141
+ }>;
126
142
  getPixelConfigById: (pixelId: string) => Promise<ApiResponse<PixelConfigResponseData>>;
127
143
  }
128
144
 
@@ -187,6 +203,61 @@ declare module '@adtrackify/at-service-common/clients/internal-api/destinations-
187
203
  declare module '@adtrackify/at-service-common/clients/internal-api/index' {
188
204
  export * from '@adtrackify/at-service-common/clients/internal-api/destinations-client';
189
205
  export * from '@adtrackify/at-service-common/clients/internal-api/accounts-client';
206
+ export * from '@adtrackify/at-service-common/clients/internal-api/users-auth-client';
207
+
208
+ }
209
+ declare module '@adtrackify/at-service-common/clients/internal-api/users-auth-client' {
210
+ export class UsersAuthClient {
211
+ SERVICE_API_ROOT_URL: string;
212
+ BASE_API_URL: string;
213
+ USERS_AUTH_API_KEY: string;
214
+ constructor(baseApiUrl: string, usersAuthApiKey?: string);
215
+ getConfig: () => {
216
+ baseURL: string;
217
+ headers: {
218
+ common: {};
219
+ };
220
+ };
221
+ getClient: () => Promise<{
222
+ instance: () => import("axios").AxiosInstance;
223
+ get: (url: string, config?: any) => Promise<{
224
+ headers: any;
225
+ data: any;
226
+ status: any;
227
+ }>;
228
+ post: (url: string, data?: any, config?: any) => Promise<{
229
+ headers: any;
230
+ data: any;
231
+ status: any;
232
+ }>;
233
+ delete: (url: string, config?: any) => Promise<{
234
+ headers: any;
235
+ data: any;
236
+ status: any;
237
+ }>;
238
+ put: (url: string, data?: any, config?: any) => Promise<{
239
+ headers: any;
240
+ data: any;
241
+ status: any;
242
+ }>;
243
+ patch: (url: string, data?: any, config?: any) => Promise<{
244
+ headers: any;
245
+ data: any;
246
+ status: any;
247
+ }>;
248
+ setBaseUrl: (url: string) => boolean;
249
+ }>;
250
+ signupUser: (userSignupRequest: any) => Promise<{
251
+ headers: any;
252
+ data: any;
253
+ status: any;
254
+ }>;
255
+ getUserByEmail: (email: string) => Promise<{
256
+ headers: any;
257
+ data: any;
258
+ status: any;
259
+ }>;
260
+ }
190
261
 
191
262
  }
192
263
  declare module '@adtrackify/at-service-common/clients/third-party/index' {
@@ -538,6 +609,21 @@ declare module '@adtrackify/at-service-common/types/db/shopify-app-install' {
538
609
  }
539
610
  declare module '@adtrackify/at-service-common/types/index' {
540
611
  export * from '@adtrackify/at-service-common/types/db/index';
612
+ export * from '@adtrackify/at-service-common/types/internal-events/index';
613
+
614
+ }
615
+ declare module '@adtrackify/at-service-common/types/internal-events/event-detail-types' {
616
+ export enum ADTRACKIFY_EVENT_TYPES {
617
+ NOTIFY_SHOPIFY_SUBSCRIPTION_CREATED = "shopifySubscriptionCreated",
618
+ REQUEST_SET_ACCOUNT_SUBSCRIPTION_ID = "setAccountSubscriptionId"
619
+ }
620
+ export enum ADTRACKIFY_EVENT_SOURCES {
621
+ SUBSCRIPTIONS = "subscriptions"
622
+ }
623
+
624
+ }
625
+ declare module '@adtrackify/at-service-common/types/internal-events/index' {
626
+ export * from '@adtrackify/at-service-common/types/internal-events/event-detail-types';
541
627
 
542
628
  }
543
629
  declare module '@adtrackify/at-service-common' {
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(info5) {
240271
+ progress: function progress(info6) {
240272
240272
  var upload = this._managedUpload;
240273
240273
  if (this.operation === "putObject") {
240274
- info5.part = 1;
240275
- info5.key = this.params.Key;
240274
+ info6.part = 1;
240275
+ info6.key = this.params.Key;
240276
240276
  } else {
240277
- upload.totalUploadedBytes += info5.loaded - this._lastUploadedBytes;
240278
- this._lastUploadedBytes = info5.loaded;
240279
- info5 = {
240277
+ upload.totalUploadedBytes += info6.loaded - this._lastUploadedBytes;
240278
+ this._lastUploadedBytes = info6.loaded;
240279
+ info6 = {
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", [info5]);
240286
+ upload.emit("httpUploadProgress", [info6]);
240287
240287
  }
240288
240288
  });
240289
240289
  AWS3.util.mixin(AWS3.S3.ManagedUpload, AWS3.SequentialExecutor);
@@ -628056,6 +628056,7 @@ var getCurrentDate = () => {
628056
628056
  };
628057
628057
 
628058
628058
  // src/clients/generic/eventbridge-client.ts
628059
+ import * as log2 from "lambda-log";
628059
628060
  var EventBridgeClient = class {
628060
628061
  eventBridge;
628061
628062
  EVENT_BUS_NAME;
@@ -628063,6 +628064,10 @@ var EventBridgeClient = class {
628063
628064
  this.eventBridge = new import_aws_sdk2.EventBridge();
628064
628065
  this.EVENT_BUS_NAME = eventBusName;
628065
628066
  }
628067
+ buildAndSendEvent = async (eventSource, eventType, eventData) => {
628068
+ const event = this.buildEvent(eventType, eventData);
628069
+ return await this.putEvent(eventSource, eventType, event);
628070
+ };
628066
628071
  buildEvent = (eventType, eventData, eventId = v4(), eventTime = getCurrentTimestamp()) => {
628067
628072
  return {
628068
628073
  eventId,
@@ -628081,7 +628086,18 @@ var EventBridgeClient = class {
628081
628086
  Time: new Date()
628082
628087
  }]
628083
628088
  };
628084
- return await this.eventBridge.putEvents(params).promise();
628089
+ const response = await this.eventBridge.putEvents(params).promise();
628090
+ log2.debug(
628091
+ "EventBus Event Published",
628092
+ {
628093
+ eventBusName: this.EVENT_BUS_NAME,
628094
+ eventSource: source,
628095
+ eventType: detailType,
628096
+ event: data,
628097
+ response
628098
+ }
628099
+ );
628100
+ return response;
628085
628101
  };
628086
628102
  };
628087
628103
 
@@ -628119,7 +628135,7 @@ var axiosHttpService = (config = {}) => {
628119
628135
  };
628120
628136
 
628121
628137
  // src/clients/internal-api/destinations-client.ts
628122
- import * as log2 from "lambda-log";
628138
+ import * as log3 from "lambda-log";
628123
628139
  var DestinationsClient = class {
628124
628140
  BASE_API_URL;
628125
628141
  DESTINATIONS_API_KEY;
@@ -628144,19 +628160,19 @@ var DestinationsClient = class {
628144
628160
  createDestination = async (createDestinationRequest) => {
628145
628161
  const client2 = await this.getClient();
628146
628162
  const response = await client2.post("/", createDestinationRequest);
628147
- log2.info("createDestinationResponse", { response });
628163
+ log3.info("createDestinationResponse", { response });
628148
628164
  return response;
628149
628165
  };
628150
628166
  getPixelDestinations = async (pixelId) => {
628151
628167
  const client2 = await this.getClient();
628152
628168
  const response = await client2.get(`/?pixelId=${pixelId}`);
628153
- log2.info("getPixelResponse", { response });
628169
+ log3.info("getPixelResponse", { response });
628154
628170
  return response;
628155
628171
  };
628156
628172
  };
628157
628173
 
628158
628174
  // src/clients/internal-api/accounts-client.ts
628159
- import * as log3 from "lambda-log";
628175
+ import * as log4 from "lambda-log";
628160
628176
  var AccountsClient = class {
628161
628177
  BASE_API_URL;
628162
628178
  ACCOUNTS_API_KEY;
@@ -628181,6 +628197,18 @@ var AccountsClient = class {
628181
628197
  getClient = async () => {
628182
628198
  return axiosHttpService(this.getConfig());
628183
628199
  };
628200
+ createAccount = async (createAccountRequest) => {
628201
+ const client2 = await this.getClient();
628202
+ const createAccountResponse = await client2.post("", createAccountRequest);
628203
+ log4.info("createAccountResponse", { createAccountResponse });
628204
+ return createAccountResponse;
628205
+ };
628206
+ addOwner = async (accountId, userId) => {
628207
+ const client2 = await this.getClient();
628208
+ const addOwnerResponse = await client2.post("/addOwner", { accountId, userId });
628209
+ log4.info("addOwnerResponse", { addOwnerResponse });
628210
+ return addOwnerResponse;
628211
+ };
628184
628212
  isAuthorizedUser = async (userId, accountId, pixelId) => {
628185
628213
  const client2 = await this.getClient();
628186
628214
  const body = {
@@ -628189,19 +628217,68 @@ var AccountsClient = class {
628189
628217
  pixelId
628190
628218
  };
628191
628219
  const response = await client2.post("/checkUserAuthorization", body);
628192
- log3.info("checkUserAuthorization", { response });
628220
+ log4.info("checkUserAuthorization", { response });
628193
628221
  return response;
628194
628222
  };
628223
+ adminDeleteAccount = async (accountId) => {
628224
+ const client2 = await this.getClient();
628225
+ const success2 = await client2.delete(`/${accountId}`);
628226
+ log4.info("adminDeleteAccount");
628227
+ return success2;
628228
+ };
628195
628229
  getPixelConfigById = async (pixelId) => {
628196
628230
  const client2 = await this.getClient();
628197
628231
  const pixelResponse = await client2.get(`/px/${pixelId}/config`);
628198
- log3.debug("pixelResponse", { pixelResponse });
628232
+ log4.debug("pixelResponse", { pixelResponse });
628199
628233
  return pixelResponse;
628200
628234
  };
628201
628235
  };
628202
628236
 
628237
+ // src/clients/internal-api/users-auth-client.ts
628238
+ import * as log5 from "lambda-log";
628239
+ var UsersAuthClient = class {
628240
+ SERVICE_API_ROOT_URL;
628241
+ BASE_API_URL;
628242
+ USERS_AUTH_API_KEY;
628243
+ constructor(baseApiUrl, usersAuthApiKey) {
628244
+ this.BASE_API_URL = baseApiUrl;
628245
+ this.USERS_AUTH_API_KEY = usersAuthApiKey;
628246
+ this.SERVICE_API_ROOT_URL = `${this.BASE_API_URL}/auth`;
628247
+ }
628248
+ getConfig = () => {
628249
+ return {
628250
+ baseURL: this.SERVICE_API_ROOT_URL,
628251
+ headers: {
628252
+ common: {}
628253
+ }
628254
+ };
628255
+ };
628256
+ getClient = async () => {
628257
+ return axiosHttpService(this.getConfig());
628258
+ };
628259
+ signupUser = async (userSignupRequest) => {
628260
+ const client2 = await this.getClient();
628261
+ const signupUserResponse = await client2.post("/signup", userSignupRequest);
628262
+ log5.info("signupUser response", { signupUserResponse });
628263
+ return signupUserResponse;
628264
+ };
628265
+ getUserByEmail = async (email) => {
628266
+ const client2 = await this.getClient();
628267
+ const getUserResponse = await client2.get("/lookup", {
628268
+ headers: {
628269
+ "x-api-key": this.USERS_AUTH_API_KEY
628270
+ },
628271
+ params: {
628272
+ email
628273
+ }
628274
+ });
628275
+ log5.info("getUserResponse", { getUserResponse });
628276
+ return getUserResponse;
628277
+ };
628278
+ };
628279
+
628203
628280
  // src/clients/third-party/shopify-client.ts
628204
- import * as log4 from "lambda-log";
628281
+ import * as log6 from "lambda-log";
628205
628282
  var _shopify_api_version = process.env.SHOPIFY_API_VERSION;
628206
628283
  var _ShopifyClient = class {
628207
628284
  };
@@ -628245,9 +628322,9 @@ __publicField(ShopifyClient, "registerWebhookTopic", async (shop, accessToken, e
628245
628322
  };
628246
628323
  const res = await client2.post(url, payload2, { headers: { "X-Shopify-Access-Token": accessToken } });
628247
628324
  if (res.status >= 400) {
628248
- log4.error("Failed to register Webhook Topic", { shop, accessToken, eventBridgeArn, topic, url, payload: payload2 });
628325
+ log6.error("Failed to register Webhook Topic", { shop, accessToken, eventBridgeArn, topic, url, payload: payload2 });
628249
628326
  }
628250
- log4.debug("Shopify Client Webhook Registration Response", { registrationResponse: res });
628327
+ log6.debug("Shopify Client Webhook Registration Response", { registrationResponse: res });
628251
628328
  return res;
628252
628329
  });
628253
628330
  __publicField(ShopifyClient, "updateShopifyAppMetafield", async (shop, accessToken, pixelId) => {
@@ -628262,7 +628339,7 @@ __publicField(ShopifyClient, "updateShopifyAppMetafield", async (shop, accessTok
628262
628339
  };
628263
628340
  const res = await _ShopifyClient.genericShopifyPost(url, accessToken, payload2);
628264
628341
  if (res.status >= 400) {
628265
- log4.error("Failed to register Webhook Topic", { shop, accessToken, url, payload: payload2 });
628342
+ log6.error("Failed to register Webhook Topic", { shop, accessToken, url, payload: payload2 });
628266
628343
  }
628267
628344
  return res;
628268
628345
  });
@@ -628270,26 +628347,26 @@ __publicField(ShopifyClient, "getShopifyStoreProperties", async (shop, accessTok
628270
628347
  const url = `https://${shop}/admin/api/${_shopify_api_version}/shop.json`;
628271
628348
  const res = await _ShopifyClient.genericShopifyGet(url, accessToken);
628272
628349
  if (res.status >= 400) {
628273
- log4.error("Failed to get Shopify Store Properties", { shop, accessToken, url });
628350
+ log6.error("Failed to get Shopify Store Properties", { shop, accessToken, url });
628274
628351
  }
628275
628352
  return res;
628276
628353
  });
628277
628354
  __publicField(ShopifyClient, "genericShopifyPost", async (url, accessToken, payload2) => {
628278
628355
  const client2 = axiosHttpService();
628279
628356
  const res = await client2.post(url, payload2, { headers: { "X-Shopify-Access-Token": accessToken } });
628280
- log4.debug("Shopify Client Response", { res });
628357
+ log6.debug("Shopify Client Response", { res });
628281
628358
  return res;
628282
628359
  });
628283
628360
  __publicField(ShopifyClient, "genericShopifyGet", async (url, accessToken) => {
628284
628361
  const client2 = axiosHttpService();
628285
628362
  const res = await client2.get(url, { headers: { "X-Shopify-Access-Token": accessToken } });
628286
- log4.debug("Shopify Client Response", { res });
628363
+ log6.debug("Shopify Client Response", { res });
628287
628364
  return res;
628288
628365
  });
628289
628366
  __publicField(ShopifyClient, "genericShopifyPut", async (url, accessToken, payload2) => {
628290
628367
  const client2 = axiosHttpService();
628291
628368
  const res = await client2.put(url, payload2, { headers: { "X-Shopify-Access-Token": accessToken } });
628292
- log4.debug("Shopify Client Response", { res });
628369
+ log6.debug("Shopify Client Response", { res });
628293
628370
  return res;
628294
628371
  });
628295
628372
 
@@ -628375,11 +628452,11 @@ __publicField(HttpError, "serviceUnavailable", (headers) => new _HttpError(503,
628375
628452
  __publicField(HttpError, "gatewayTimeout", () => new _HttpError(504));
628376
628453
 
628377
628454
  // src/helpers/input-validation-helper.ts
628378
- import * as log5 from "lambda-log";
628455
+ import * as log7 from "lambda-log";
628379
628456
  var validateInput = (schema, input) => {
628380
628457
  const { error: error3, value } = schema.validate(input);
628381
628458
  if (error3) {
628382
- log5.info("", { error: error3 });
628459
+ log7.info("", { error: error3 });
628383
628460
  const httperr = HttpError.badRequest("Input Validation Failure", {
628384
628461
  errors: error3.details.map((detail) => ({
628385
628462
  message: detail?.message,
@@ -628387,21 +628464,21 @@ var validateInput = (schema, input) => {
628387
628464
  path: detail?.path
628388
628465
  }))
628389
628466
  });
628390
- log5.info("", { httperr });
628467
+ log7.info("", { httperr });
628391
628468
  throw httperr;
628392
628469
  }
628393
628470
  return value;
628394
628471
  };
628395
628472
 
628396
628473
  // src/helpers/logging-helper.ts
628397
- import * as log6 from "lambda-log";
628474
+ import * as log8 from "lambda-log";
628398
628475
  var stage = process?.env?.STAGE;
628399
- var configureLogger = (event, context, debug3 = true) => {
628400
- log6.options.meta.stage = stage;
628401
- log6.options.meta.source_name = context?.functionName || "unknown";
628402
- log6.options.meta.awsRequestId = context?.awsRequestId || "unknown";
628403
- log6.options.meta.lambdaEvent = event;
628404
- log6.options.debug = debug3;
628476
+ var configureLogger = (event, context, debug4 = true) => {
628477
+ log8.options.meta.stage = stage;
628478
+ log8.options.meta.source_name = context?.functionName || "unknown";
628479
+ log8.options.meta.awsRequestId = context?.awsRequestId || "unknown";
628480
+ log8.options.meta.lambdaEvent = event;
628481
+ log8.options.debug = debug4;
628405
628482
  };
628406
628483
 
628407
628484
  // src/helpers/response-helper.ts
@@ -628515,7 +628592,20 @@ var DESTINATIONS = /* @__PURE__ */ ((DESTINATIONS2) => {
628515
628592
  DESTINATIONS2["GOOGLE_ANALYTICS_4"] = "googleAnalytics4";
628516
628593
  return DESTINATIONS2;
628517
628594
  })(DESTINATIONS || {});
628595
+
628596
+ // src/types/internal-events/event-detail-types.ts
628597
+ var ADTRACKIFY_EVENT_TYPES = /* @__PURE__ */ ((ADTRACKIFY_EVENT_TYPES2) => {
628598
+ ADTRACKIFY_EVENT_TYPES2["NOTIFY_SHOPIFY_SUBSCRIPTION_CREATED"] = "shopifySubscriptionCreated";
628599
+ ADTRACKIFY_EVENT_TYPES2["REQUEST_SET_ACCOUNT_SUBSCRIPTION_ID"] = "setAccountSubscriptionId";
628600
+ return ADTRACKIFY_EVENT_TYPES2;
628601
+ })(ADTRACKIFY_EVENT_TYPES || {});
628602
+ var ADTRACKIFY_EVENT_SOURCES = /* @__PURE__ */ ((ADTRACKIFY_EVENT_SOURCES2) => {
628603
+ ADTRACKIFY_EVENT_SOURCES2["SUBSCRIPTIONS"] = "subscriptions";
628604
+ return ADTRACKIFY_EVENT_SOURCES2;
628605
+ })(ADTRACKIFY_EVENT_SOURCES || {});
628518
628606
  export {
628607
+ ADTRACKIFY_EVENT_SOURCES,
628608
+ ADTRACKIFY_EVENT_TYPES,
628519
628609
  AccountsClient,
628520
628610
  DESTINATIONS,
628521
628611
  DestinationsClient,
@@ -628524,6 +628614,7 @@ export {
628524
628614
  HttpError,
628525
628615
  HttpStatusCodes,
628526
628616
  ShopifyClient,
628617
+ UsersAuthClient,
628527
628618
  axiosHttpService,
628528
628619
  buildResponse,
628529
628620
  configureLogger,