@adtrackify/at-service-common 1.0.25 → 1.0.27

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
@@ -77,6 +77,16 @@ declare module '@adtrackify/at-service-common/clients/index' {
77
77
  }
78
78
  declare module '@adtrackify/at-service-common/clients/internal-api/accounts-client' {
79
79
  import { ApiResponse } from '@adtrackify/at-service-common/types/api-response';
80
+ import { Destination } from '@adtrackify/at-service-common/types/db/destination';
81
+ export interface IsAuthorizedUserResponseData {
82
+ isAccountUser: boolean;
83
+ [key: string]: any;
84
+ }
85
+ export interface PixelConfigResponseData {
86
+ id: string;
87
+ destinations: Destination[];
88
+ [key: string]: any;
89
+ }
80
90
  export class AccountsClient {
81
91
  BASE_API_URL: string;
82
92
  ACCOUNTS_API_KEY: string;
@@ -119,16 +129,21 @@ declare module '@adtrackify/at-service-common/clients/internal-api/accounts-clie
119
129
  setBaseUrl: (url: string) => boolean;
120
130
  }>;
121
131
  isAuthorizedUser: (userId: string, accountId: string, pixelId: string) => Promise<ApiResponse<IsAuthorizedUserResponseData>>;
122
- }
123
- export interface IsAuthorizedUserResponseData {
124
- isAccountUser: boolean;
125
- [key: string]: any;
132
+ getPixelConfigById: (pixelId: string) => Promise<ApiResponse<PixelConfigResponseData>>;
126
133
  }
127
134
 
128
135
  }
129
136
  declare module '@adtrackify/at-service-common/clients/internal-api/destinations-client' {
130
137
  import { ApiResponse } from '@adtrackify/at-service-common/types/api-response';
131
138
  import { Destination } from '@adtrackify/at-service-common/types/db/destination';
139
+ export interface GetDestinationsResponseData {
140
+ destinations: Destination[];
141
+ [key: string]: any;
142
+ }
143
+ export interface CreateDestinationResponseData {
144
+ destination: Destination;
145
+ [key: string]: any;
146
+ }
132
147
  export class DestinationsClient {
133
148
  BASE_API_URL: string;
134
149
  DESTINATIONS_API_KEY: string;
@@ -173,20 +188,89 @@ declare module '@adtrackify/at-service-common/clients/internal-api/destinations-
173
188
  createDestination: (createDestinationRequest: any) => Promise<ApiResponse<CreateDestinationResponseData>>;
174
189
  getPixelDestinations: (pixelId: string) => Promise<ApiResponse<GetDestinationsResponseData>>;
175
190
  }
176
- export interface GetDestinationsResponseData {
177
- destinations: Destination[];
178
- [key: string]: any;
179
- }
180
- export interface CreateDestinationResponseData {
181
- destination: Destination;
182
- [key: string]: any;
183
- }
184
191
 
185
192
  }
186
193
  declare module '@adtrackify/at-service-common/clients/internal-api/index' {
187
194
  export * from '@adtrackify/at-service-common/clients/internal-api/destinations-client';
188
195
  export * from '@adtrackify/at-service-common/clients/internal-api/accounts-client';
189
196
 
197
+ }
198
+ declare module '@adtrackify/at-service-common/clients/third-party/shopify-client' {
199
+ export class ShopifyClient {
200
+ getConfig: (shopifyDomain: string, accessToken: string) => {
201
+ baseURL: string;
202
+ headers: {
203
+ common: {
204
+ 'X-Shopify-Access-Token': string;
205
+ };
206
+ };
207
+ };
208
+ getClient: (shopifyDomain: string, accessToken: string) => {
209
+ instance: () => import("axios").AxiosInstance;
210
+ get: (url: string, config?: any) => Promise<{
211
+ headers: any;
212
+ data: any;
213
+ status: any;
214
+ }>;
215
+ post: (url: string, data?: any, config?: any) => Promise<{
216
+ headers: any;
217
+ data: any;
218
+ status: any;
219
+ }>;
220
+ delete: (url: string, config?: any) => Promise<{
221
+ headers: any;
222
+ data: any;
223
+ status: any;
224
+ }>;
225
+ put: (url: string, data?: any, config?: any) => Promise<{
226
+ headers: any;
227
+ data: any;
228
+ status: any;
229
+ }>;
230
+ patch: (url: string, data?: any, config?: any) => Promise<{
231
+ headers: any;
232
+ data: any;
233
+ status: any;
234
+ }>;
235
+ setBaseUrl: (url: string) => boolean;
236
+ };
237
+ registerApp: (shop: string, code: string, appKey: string, appSecret: string) => Promise<{
238
+ headers: any;
239
+ data: any;
240
+ status: any;
241
+ }>;
242
+ registerWebhookTopic: (shop: string, accessToken: string, eventBridgeArn: string, topic: string) => Promise<{
243
+ headers: any;
244
+ data: any;
245
+ status: any;
246
+ }>;
247
+ updateShopifyAppMetafield: (shop: string, accessToken: string, pixelId: string) => Promise<{
248
+ headers: any;
249
+ data: any;
250
+ status: any;
251
+ }>;
252
+ getShopifyStoreProperties: (shop: string, accessToken: string) => Promise<{
253
+ headers: any;
254
+ data: any;
255
+ status: any;
256
+ }>;
257
+ genericShopifyPost: (url: string, accessToken: string, payload: any) => Promise<{
258
+ headers: any;
259
+ data: any;
260
+ status: any;
261
+ }>;
262
+ genericShopifyGet: (url: string, accessToken: string) => Promise<{
263
+ headers: any;
264
+ data: any;
265
+ status: any;
266
+ }>;
267
+ genericShopifyPut: (url: string, accessToken: string, payload: any) => Promise<{
268
+ headers: any;
269
+ data: any;
270
+ status: any;
271
+ }>;
272
+ }
273
+
190
274
  }
191
275
  declare module '@adtrackify/at-service-common/helpers/index' {
192
276
  export * from '@adtrackify/at-service-common/helpers/input-validation-helper';
@@ -243,7 +327,7 @@ declare module '@adtrackify/at-service-common/helpers/response-helper' {
243
327
 
244
328
  }
245
329
  declare module '@adtrackify/at-service-common/index' {
246
- export * from '@adtrackify/at-service-common/clients/generic/index';
330
+ export * from '@adtrackify/at-service-common/clients/index';
247
331
  export * from '@adtrackify/at-service-common/helpers/index';
248
332
  export * from '@adtrackify/at-service-common/libs/index';
249
333
  export * from '@adtrackify/at-service-common/types/index';
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(info3) {
240271
+ progress: function progress(info5) {
240272
240272
  var upload = this._managedUpload;
240273
240273
  if (this.operation === "putObject") {
240274
- info3.part = 1;
240275
- info3.key = this.params.Key;
240274
+ info5.part = 1;
240275
+ info5.key = this.params.Key;
240276
240276
  } else {
240277
- upload.totalUploadedBytes += info3.loaded - this._lastUploadedBytes;
240278
- this._lastUploadedBytes = info3.loaded;
240279
- info3 = {
240277
+ upload.totalUploadedBytes += info5.loaded - this._lastUploadedBytes;
240278
+ this._lastUploadedBytes = info5.loaded;
240279
+ info5 = {
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", [info3]);
240286
+ upload.emit("httpUploadProgress", [info5]);
240287
240287
  }
240288
240288
  });
240289
240289
  AWS3.util.mixin(AWS3.S3.ManagedUpload, AWS3.SequentialExecutor);
@@ -628118,6 +628118,85 @@ 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 response = await client2.post("/", createDestinationRequest);
628147
+ log2.info("createDestinationResponse", { response });
628148
+ return response;
628149
+ };
628150
+ getPixelDestinations = async (pixelId) => {
628151
+ const client2 = await this.getClient();
628152
+ const response = await client2.get(`/?pixelId=${pixelId}`);
628153
+ log2.info("getPixelResponse", { response });
628154
+ return response;
628155
+ };
628156
+ };
628157
+
628158
+ // src/clients/internal-api/accounts-client.ts
628159
+ import * as log3 from "lambda-log";
628160
+ var AccountsClient = class {
628161
+ BASE_API_URL;
628162
+ ACCOUNTS_API_KEY;
628163
+ constructor(baseApiUrl, accountsApiKey) {
628164
+ this.BASE_API_URL = baseApiUrl;
628165
+ this.ACCOUNTS_API_KEY = accountsApiKey;
628166
+ }
628167
+ getConfig = () => {
628168
+ const SERVICE_API_ROOT_URL = `${this.BASE_API_URL}/accounts`;
628169
+ return {
628170
+ baseURL: SERVICE_API_ROOT_URL,
628171
+ headers: {
628172
+ common: {
628173
+ "x-api-key": this.ACCOUNTS_API_KEY
628174
+ }
628175
+ }
628176
+ };
628177
+ };
628178
+ getClient = async () => {
628179
+ return axiosHttpService(this.getConfig());
628180
+ };
628181
+ isAuthorizedUser = async (userId, accountId, pixelId) => {
628182
+ const client2 = await this.getClient();
628183
+ const body = {
628184
+ userId,
628185
+ accountId,
628186
+ pixelId
628187
+ };
628188
+ const response = await client2.post("/checkUserAuthorization", body);
628189
+ log3.info("checkUserAuthorization", { response });
628190
+ return response;
628191
+ };
628192
+ getPixelConfigById = async (pixelId) => {
628193
+ const client2 = await this.getClient();
628194
+ const pixelResponse = await client2.get(`/px/${pixelId}/config`);
628195
+ log3.debug("pixelResponse", { pixelResponse });
628196
+ return pixelResponse;
628197
+ };
628198
+ };
628199
+
628121
628200
  // src/libs/http-error.ts
628122
628201
  import { strict as assert } from "assert";
628123
628202
  var deepClone = (o = {}) => JSON.parse(JSON.stringify(o));
@@ -628200,11 +628279,11 @@ __publicField(HttpError, "serviceUnavailable", (headers) => new _HttpError(503,
628200
628279
  __publicField(HttpError, "gatewayTimeout", () => new _HttpError(504));
628201
628280
 
628202
628281
  // src/helpers/input-validation-helper.ts
628203
- import * as log2 from "lambda-log";
628282
+ import * as log4 from "lambda-log";
628204
628283
  var validateInput = (schema, input) => {
628205
628284
  const { error: error2, value } = schema.validate(input);
628206
628285
  if (error2) {
628207
- log2.info("", { error: error2 });
628286
+ log4.info("", { error: error2 });
628208
628287
  const httperr = HttpError.badRequest("Input Validation Failure", {
628209
628288
  errors: error2.details.map((detail) => ({
628210
628289
  message: detail?.message,
@@ -628212,21 +628291,21 @@ var validateInput = (schema, input) => {
628212
628291
  path: detail?.path
628213
628292
  }))
628214
628293
  });
628215
- log2.info("", { httperr });
628294
+ log4.info("", { httperr });
628216
628295
  throw httperr;
628217
628296
  }
628218
628297
  return value;
628219
628298
  };
628220
628299
 
628221
628300
  // src/helpers/logging-helper.ts
628222
- import * as log3 from "lambda-log";
628301
+ import * as log5 from "lambda-log";
628223
628302
  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;
628303
+ var configureLogger = (event, context, debug2 = true) => {
628304
+ log5.options.meta.stage = stage;
628305
+ log5.options.meta.source_name = context?.functionName || "unknown";
628306
+ log5.options.meta.awsRequestId = context?.awsRequestId || "unknown";
628307
+ log5.options.meta.lambdaEvent = event;
628308
+ log5.options.debug = debug2;
628230
628309
  };
628231
628310
 
628232
628311
  // src/helpers/response-helper.ts
@@ -628341,7 +628420,9 @@ var DESTINATIONS = /* @__PURE__ */ ((DESTINATIONS2) => {
628341
628420
  return DESTINATIONS2;
628342
628421
  })(DESTINATIONS || {});
628343
628422
  export {
628423
+ AccountsClient,
628344
628424
  DESTINATIONS,
628425
+ DestinationsClient,
628345
628426
  DynamoDbClient,
628346
628427
  EventBridgeClient,
628347
628428
  HttpError,