@adtrackify/at-service-common 3.0.40 → 3.0.42

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.
@@ -5,3 +5,4 @@ export * from './s3-client.js';
5
5
  export * from './cognito-client.js';
6
6
  export * from './sqs-client.js';
7
7
  export * from './location-client.js';
8
+ export * from './singlestore-db-client.js';
@@ -21,4 +21,5 @@ __exportStar(require("./s3-client.js"), exports);
21
21
  __exportStar(require("./cognito-client.js"), exports);
22
22
  __exportStar(require("./sqs-client.js"), exports);
23
23
  __exportStar(require("./location-client.js"), exports);
24
+ __exportStar(require("./singlestore-db-client.js"), exports);
24
25
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/clients/generic/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,uDAAqC;AACrC,0DAAwC;AACxC,mDAAiC;AACjC,iDAA+B;AAC/B,sDAAoC;AACpC,kDAAgC;AAChC,uDAAqC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/clients/generic/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,uDAAqC;AACrC,0DAAwC;AACxC,mDAAiC;AACjC,iDAA+B;AAC/B,sDAAoC;AACpC,kDAAgC;AAChC,uDAAqC;AACrC,6DAA2C"}
@@ -0,0 +1,14 @@
1
+ import * as mysql from 'mysql2/promise';
2
+ export declare const getPool: () => mysql.Pool;
3
+ export declare class SingleStoreDBClient {
4
+ conn: mysql.Connection;
5
+ constructor();
6
+ private getConnection;
7
+ executeQuery(query: string, values?: any): Promise<{
8
+ rows: mysql.QueryResult;
9
+ success: boolean;
10
+ } | {
11
+ success: boolean;
12
+ rows?: undefined;
13
+ }>;
14
+ }
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.SingleStoreDBClient = exports.getPool = void 0;
27
+ const mysql = __importStar(require("mysql2/promise"));
28
+ const helpers_1 = require("../../helpers");
29
+ const host = process.env.SINGLESTORE_HOST;
30
+ const user = process.env.SINGLESTORE_USER;
31
+ const password = process.env.SINGLESTORE_PASSWORD;
32
+ const database = process.env.SINGLESTORE_DATABASE;
33
+ const port = process.env.PORT;
34
+ const getPool = () => {
35
+ let pool = null;
36
+ pool = mysql.createPool({
37
+ host: host,
38
+ port: +port,
39
+ user: user,
40
+ password: password,
41
+ database: database,
42
+ multipleStatements: true,
43
+ });
44
+ return pool;
45
+ };
46
+ exports.getPool = getPool;
47
+ const _pool = (0, exports.getPool)();
48
+ class SingleStoreDBClient {
49
+ conn;
50
+ constructor() {
51
+ if (!host || !user || !password || !database || !port) {
52
+ throw new Error('SingleStore env values not found');
53
+ }
54
+ }
55
+ async getConnection() {
56
+ return _pool;
57
+ }
58
+ async executeQuery(query, values) {
59
+ try {
60
+ const pool = await this.getConnection();
61
+ helpers_1.Logger.debug('executing query', { query, values });
62
+ const [rows, fields] = await pool.query(query, values);
63
+ helpers_1.Logger.debug('query response', { rows, fields });
64
+ return { rows, success: true };
65
+ }
66
+ catch (error) {
67
+ helpers_1.Logger.error('Error executing query', { query, error });
68
+ return { success: false };
69
+ }
70
+ }
71
+ }
72
+ exports.SingleStoreDBClient = SingleStoreDBClient;
73
+ //# sourceMappingURL=singlestore-db-client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"singlestore-db-client.js","sourceRoot":"","sources":["../../../../src/clients/generic/singlestore-db-client.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,sDAAwC;AACxC,2CAAuC;AAEvC,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,gBAA0B,CAAC;AACpD,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,gBAA0B,CAAC;AACpD,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,oBAA8B,CAAC;AAC5D,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,oBAA8B,CAAC;AAC5D,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,IAAc,CAAC;AAEjC,MAAM,OAAO,GAAG,GAAG,EAAE;IAC1B,IAAI,IAAI,GAAG,IAAI,CAAC;IAChB,IAAI,GAAG,KAAK,CAAC,UAAU,CAAC;QACtB,IAAI,EAAE,IAAI;QACV,IAAI,EAAE,CAAC,IAAI;QACX,IAAI,EAAE,IAAI;QACV,QAAQ,EAAE,QAAQ;QAClB,QAAQ,EAAE,QAAQ;QAClB,kBAAkB,EAAE,IAAI;KACzB,CAAC,CAAC;IACH,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAXW,QAAA,OAAO,WAWlB;AAEF,MAAM,KAAK,GAAG,IAAA,eAAO,GAAE,CAAC;AAExB,MAAa,mBAAmB;IAC9B,IAAI,CAAoB;IAExB;QACE,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI,IAAI,CAAC,QAAQ,IAAI,CAAC,QAAQ,IAAI,CAAC,IAAI,EAAE;YACrD,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;SACrD;IACH,CAAC;IAEO,KAAK,CAAC,aAAa;QACzB,OAAO,KAAK,CAAC;IACf,CAAC;IAED,KAAK,CAAC,YAAY,CAAC,KAAa,EAAE,MAAY;QAC5C,IAAI;YACF,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,aAAa,EAAE,CAAC;YACxC,gBAAM,CAAC,KAAK,CAAC,iBAAiB,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC;YACnD,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;YACvD,gBAAM,CAAC,KAAK,CAAC,gBAAgB,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC;YAEjD,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;SAChC;QAAC,OAAO,KAAK,EAAE;YACd,gBAAM,CAAC,KAAK,CAAC,uBAAuB,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;YACxD,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;SAC3B;IACH,CAAC;CACF;AA1BD,kDA0BC"}
@@ -3,3 +3,4 @@ export * from './log-events-db-service.js';
3
3
  export * from './purchased-contacts-db-service.js';
4
4
  export * from './tracking-events-db-service.js';
5
5
  export * from './shopify-products-cache-db-service.js';
6
+ export * from './shopify-app-installs-db-service.js';
@@ -19,4 +19,5 @@ __exportStar(require("./log-events-db-service.js"), exports);
19
19
  __exportStar(require("./purchased-contacts-db-service.js"), exports);
20
20
  __exportStar(require("./tracking-events-db-service.js"), exports);
21
21
  __exportStar(require("./shopify-products-cache-db-service.js"), exports);
22
+ __exportStar(require("./shopify-app-installs-db-service.js"), exports);
22
23
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/services/db/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4DAA0C;AAC1C,6DAA2C;AAC3C,qEAAmD;AACnD,kEAAgD;AAChD,yEAAuD"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/services/db/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4DAA0C;AAC1C,6DAA2C;AAC3C,qEAAmD;AACnD,kEAAgD;AAChD,yEAAuD;AACvD,uEAAqD"}
@@ -0,0 +1,7 @@
1
+ import { ShopifyAppInstall } from '@adtrackify/at-tracking-event-types';
2
+ export declare class ShopifyAppInstallsDbService {
3
+ TABLE_NAME: string;
4
+ constructor(tableName: string);
5
+ getShopifyAppInstallByShop: (indexName: string, shop: string) => Promise<ShopifyAppInstall | null>;
6
+ getShopifyAppInstallByPixelId: (indexName: string, pixelId: string) => Promise<ShopifyAppInstall | null>;
7
+ }
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ShopifyAppInstallsDbService = void 0;
4
+ const clients_1 = require("../../clients");
5
+ const helpers_1 = require("../../helpers");
6
+ class ShopifyAppInstallsDbService {
7
+ TABLE_NAME;
8
+ constructor(tableName) {
9
+ this.TABLE_NAME = tableName;
10
+ }
11
+ getShopifyAppInstallByShop = async (indexName, shop) => {
12
+ try {
13
+ const values = {
14
+ ':shop': shop
15
+ };
16
+ const query = {
17
+ TableName: this.TABLE_NAME,
18
+ IndexName: indexName,
19
+ KeyConditionExpression: 'shop = :shop',
20
+ ExpressionAttributeValues: values
21
+ };
22
+ const shopifyAppInstalls = await clients_1.DynamoDbClient.queryAll(query);
23
+ if (shopifyAppInstalls && shopifyAppInstalls.length > 0) {
24
+ return shopifyAppInstalls[0];
25
+ }
26
+ return null;
27
+ }
28
+ catch (error) {
29
+ helpers_1.Logger.error('failed to shopifyAppInstall by shop', { error, indexName, shop });
30
+ return null;
31
+ }
32
+ };
33
+ getShopifyAppInstallByPixelId = async (indexName, pixelId) => {
34
+ try {
35
+ const shopifyAppInstalls = await clients_1.DynamoDbClient.safeQueryByGSI(this.TABLE_NAME, indexName, 'pixelId', pixelId);
36
+ if (shopifyAppInstalls && shopifyAppInstalls?.length > 0) {
37
+ return shopifyAppInstalls[0];
38
+ }
39
+ return null;
40
+ }
41
+ catch (error) {
42
+ helpers_1.Logger.error('failed to fetch shopifyAppInstall by pixelId', { error, indexName, pixelId });
43
+ return null;
44
+ }
45
+ };
46
+ }
47
+ exports.ShopifyAppInstallsDbService = ShopifyAppInstallsDbService;
48
+ //# sourceMappingURL=shopify-app-installs-db-service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shopify-app-installs-db-service.js","sourceRoot":"","sources":["../../../../src/services/db/shopify-app-installs-db-service.ts"],"names":[],"mappings":";;;AACA,2CAA+C;AAC/C,2CAAuC;AAEvC,MAAa,2BAA2B;IAC/B,UAAU,CAAS;IAE1B,YAAY,SAAiB;QAC3B,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;IAC9B,CAAC;IAEM,0BAA0B,GAAG,KAAK,EAAE,SAAiB,EAAE,IAAY,EAAqC,EAAE;QAC/G,IAAI;YACF,MAAM,MAAM,GAAG;gBACb,OAAO,EAAE,IAAI;aACd,CAAC;YACF,MAAM,KAAK,GAAG;gBACZ,SAAS,EAAE,IAAI,CAAC,UAAU;gBAC1B,SAAS,EAAE,SAAS;gBACpB,sBAAsB,EAAE,cAAc;gBACtC,yBAAyB,EAAE,MAAM;aAClC,CAAC;YACF,MAAM,kBAAkB,GAAG,MAAM,wBAAc,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;YAChE,IAAI,kBAAkB,IAAI,kBAAkB,CAAC,MAAM,GAAG,CAAC,EAAE;gBACvD,OAAO,kBAAkB,CAAC,CAAC,CAAC,CAAC;aAC9B;YACD,OAAO,IAAI,CAAC;SACb;QAAC,OAAO,KAAK,EAAE;YACd,gBAAM,CAAC,KAAK,CAAC,qCAAqC,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;YAChF,OAAO,IAAI,CAAC;SACb;IACH,CAAC,CAAC;IAEK,6BAA6B,GAAG,KAAK,EAAE,SAAiB,EAAE,OAAe,EAAqC,EAAE;QACrH,IAAI;YACF,MAAM,kBAAkB,GAAG,MAAM,wBAAc,CAAC,cAAc,CAAC,IAAI,CAAC,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;YAC/G,IAAI,kBAAkB,IAAI,kBAAkB,EAAE,MAAM,GAAG,CAAC,EAAE;gBACxD,OAAO,kBAAkB,CAAC,CAAC,CAAC,CAAC;aAC9B;YACD,OAAO,IAAI,CAAC;SACb;QAAC,OAAO,KAAK,EAAE;YACd,gBAAM,CAAC,KAAK,CAAC,8CAA8C,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC,CAAC;YAC5F,OAAO,IAAI,CAAC;SACb;IACH,CAAC,CAAC;CACH;AAzCD,kEAyCC"}
@@ -5,3 +5,4 @@ export * from './s3-client.js';
5
5
  export * from './cognito-client.js';
6
6
  export * from './sqs-client.js';
7
7
  export * from './location-client.js';
8
+ export * from './singlestore-db-client.js';
@@ -5,4 +5,5 @@ export * from './s3-client.js';
5
5
  export * from './cognito-client.js';
6
6
  export * from './sqs-client.js';
7
7
  export * from './location-client.js';
8
+ export * from './singlestore-db-client.js';
8
9
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/clients/generic/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AACxC,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,sBAAsB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/clients/generic/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AACxC,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,sBAAsB,CAAC;AACrC,cAAc,4BAA4B,CAAC"}
@@ -0,0 +1,14 @@
1
+ import * as mysql from 'mysql2/promise';
2
+ export declare const getPool: () => mysql.Pool;
3
+ export declare class SingleStoreDBClient {
4
+ conn: mysql.Connection;
5
+ constructor();
6
+ private getConnection;
7
+ executeQuery(query: string, values?: any): Promise<{
8
+ rows: mysql.QueryResult;
9
+ success: boolean;
10
+ } | {
11
+ success: boolean;
12
+ rows?: undefined;
13
+ }>;
14
+ }
@@ -0,0 +1,45 @@
1
+ import * as mysql from 'mysql2/promise';
2
+ import { Logger } from '../../helpers';
3
+ const host = process.env.SINGLESTORE_HOST;
4
+ const user = process.env.SINGLESTORE_USER;
5
+ const password = process.env.SINGLESTORE_PASSWORD;
6
+ const database = process.env.SINGLESTORE_DATABASE;
7
+ const port = process.env.PORT;
8
+ export const getPool = () => {
9
+ let pool = null;
10
+ pool = mysql.createPool({
11
+ host: host,
12
+ port: +port,
13
+ user: user,
14
+ password: password,
15
+ database: database,
16
+ multipleStatements: true,
17
+ });
18
+ return pool;
19
+ };
20
+ const _pool = getPool();
21
+ export class SingleStoreDBClient {
22
+ conn;
23
+ constructor() {
24
+ if (!host || !user || !password || !database || !port) {
25
+ throw new Error('SingleStore env values not found');
26
+ }
27
+ }
28
+ async getConnection() {
29
+ return _pool;
30
+ }
31
+ async executeQuery(query, values) {
32
+ try {
33
+ const pool = await this.getConnection();
34
+ Logger.debug('executing query', { query, values });
35
+ const [rows, fields] = await pool.query(query, values);
36
+ Logger.debug('query response', { rows, fields });
37
+ return { rows, success: true };
38
+ }
39
+ catch (error) {
40
+ Logger.error('Error executing query', { query, error });
41
+ return { success: false };
42
+ }
43
+ }
44
+ }
45
+ //# sourceMappingURL=singlestore-db-client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"singlestore-db-client.js","sourceRoot":"","sources":["../../../../src/clients/generic/singlestore-db-client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAEvC,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,gBAA0B,CAAC;AACpD,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,gBAA0B,CAAC;AACpD,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,oBAA8B,CAAC;AAC5D,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,oBAA8B,CAAC;AAC5D,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,IAAc,CAAC;AAExC,MAAM,CAAC,MAAM,OAAO,GAAG,GAAG,EAAE;IAC1B,IAAI,IAAI,GAAG,IAAI,CAAC;IAChB,IAAI,GAAG,KAAK,CAAC,UAAU,CAAC;QACtB,IAAI,EAAE,IAAI;QACV,IAAI,EAAE,CAAC,IAAI;QACX,IAAI,EAAE,IAAI;QACV,QAAQ,EAAE,QAAQ;QAClB,QAAQ,EAAE,QAAQ;QAClB,kBAAkB,EAAE,IAAI;KACzB,CAAC,CAAC;IACH,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAEF,MAAM,KAAK,GAAG,OAAO,EAAE,CAAC;AAExB,MAAM,OAAO,mBAAmB;IAC9B,IAAI,CAAoB;IAExB;QACE,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI,IAAI,CAAC,QAAQ,IAAI,CAAC,QAAQ,IAAI,CAAC,IAAI,EAAE;YACrD,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;SACrD;IACH,CAAC;IAEO,KAAK,CAAC,aAAa;QACzB,OAAO,KAAK,CAAC;IACf,CAAC;IAED,KAAK,CAAC,YAAY,CAAC,KAAa,EAAE,MAAY;QAC5C,IAAI;YACF,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,aAAa,EAAE,CAAC;YACxC,MAAM,CAAC,KAAK,CAAC,iBAAiB,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC;YACnD,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;YACvD,MAAM,CAAC,KAAK,CAAC,gBAAgB,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC;YAEjD,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;SAChC;QAAC,OAAO,KAAK,EAAE;YACd,MAAM,CAAC,KAAK,CAAC,uBAAuB,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;YACxD,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;SAC3B;IACH,CAAC;CACF"}
@@ -3,3 +3,4 @@ export * from './log-events-db-service.js';
3
3
  export * from './purchased-contacts-db-service.js';
4
4
  export * from './tracking-events-db-service.js';
5
5
  export * from './shopify-products-cache-db-service.js';
6
+ export * from './shopify-app-installs-db-service.js';
@@ -3,4 +3,5 @@ export * from './log-events-db-service.js';
3
3
  export * from './purchased-contacts-db-service.js';
4
4
  export * from './tracking-events-db-service.js';
5
5
  export * from './shopify-products-cache-db-service.js';
6
+ export * from './shopify-app-installs-db-service.js';
6
7
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/services/db/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC;AAC1C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,oCAAoC,CAAC;AACnD,cAAc,iCAAiC,CAAC;AAChD,cAAc,wCAAwC,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/services/db/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC;AAC1C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,oCAAoC,CAAC;AACnD,cAAc,iCAAiC,CAAC;AAChD,cAAc,wCAAwC,CAAC;AACvD,cAAc,sCAAsC,CAAC"}
@@ -0,0 +1,7 @@
1
+ import { ShopifyAppInstall } from '@adtrackify/at-tracking-event-types';
2
+ export declare class ShopifyAppInstallsDbService {
3
+ TABLE_NAME: string;
4
+ constructor(tableName: string);
5
+ getShopifyAppInstallByShop: (indexName: string, shop: string) => Promise<ShopifyAppInstall | null>;
6
+ getShopifyAppInstallByPixelId: (indexName: string, pixelId: string) => Promise<ShopifyAppInstall | null>;
7
+ }
@@ -0,0 +1,44 @@
1
+ import { DynamoDbClient } from '../../clients';
2
+ import { Logger } from '../../helpers';
3
+ export class ShopifyAppInstallsDbService {
4
+ TABLE_NAME;
5
+ constructor(tableName) {
6
+ this.TABLE_NAME = tableName;
7
+ }
8
+ getShopifyAppInstallByShop = async (indexName, shop) => {
9
+ try {
10
+ const values = {
11
+ ':shop': shop
12
+ };
13
+ const query = {
14
+ TableName: this.TABLE_NAME,
15
+ IndexName: indexName,
16
+ KeyConditionExpression: 'shop = :shop',
17
+ ExpressionAttributeValues: values
18
+ };
19
+ const shopifyAppInstalls = await DynamoDbClient.queryAll(query);
20
+ if (shopifyAppInstalls && shopifyAppInstalls.length > 0) {
21
+ return shopifyAppInstalls[0];
22
+ }
23
+ return null;
24
+ }
25
+ catch (error) {
26
+ Logger.error('failed to shopifyAppInstall by shop', { error, indexName, shop });
27
+ return null;
28
+ }
29
+ };
30
+ getShopifyAppInstallByPixelId = async (indexName, pixelId) => {
31
+ try {
32
+ const shopifyAppInstalls = await DynamoDbClient.safeQueryByGSI(this.TABLE_NAME, indexName, 'pixelId', pixelId);
33
+ if (shopifyAppInstalls && shopifyAppInstalls?.length > 0) {
34
+ return shopifyAppInstalls[0];
35
+ }
36
+ return null;
37
+ }
38
+ catch (error) {
39
+ Logger.error('failed to fetch shopifyAppInstall by pixelId', { error, indexName, pixelId });
40
+ return null;
41
+ }
42
+ };
43
+ }
44
+ //# sourceMappingURL=shopify-app-installs-db-service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shopify-app-installs-db-service.js","sourceRoot":"","sources":["../../../../src/services/db/shopify-app-installs-db-service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAEvC,MAAM,OAAO,2BAA2B;IAC/B,UAAU,CAAS;IAE1B,YAAY,SAAiB;QAC3B,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;IAC9B,CAAC;IAEM,0BAA0B,GAAG,KAAK,EAAE,SAAiB,EAAE,IAAY,EAAqC,EAAE;QAC/G,IAAI;YACF,MAAM,MAAM,GAAG;gBACb,OAAO,EAAE,IAAI;aACd,CAAC;YACF,MAAM,KAAK,GAAG;gBACZ,SAAS,EAAE,IAAI,CAAC,UAAU;gBAC1B,SAAS,EAAE,SAAS;gBACpB,sBAAsB,EAAE,cAAc;gBACtC,yBAAyB,EAAE,MAAM;aAClC,CAAC;YACF,MAAM,kBAAkB,GAAG,MAAM,cAAc,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;YAChE,IAAI,kBAAkB,IAAI,kBAAkB,CAAC,MAAM,GAAG,CAAC,EAAE;gBACvD,OAAO,kBAAkB,CAAC,CAAC,CAAC,CAAC;aAC9B;YACD,OAAO,IAAI,CAAC;SACb;QAAC,OAAO,KAAK,EAAE;YACd,MAAM,CAAC,KAAK,CAAC,qCAAqC,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;YAChF,OAAO,IAAI,CAAC;SACb;IACH,CAAC,CAAC;IAEK,6BAA6B,GAAG,KAAK,EAAE,SAAiB,EAAE,OAAe,EAAqC,EAAE;QACrH,IAAI;YACF,MAAM,kBAAkB,GAAG,MAAM,cAAc,CAAC,cAAc,CAAC,IAAI,CAAC,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;YAC/G,IAAI,kBAAkB,IAAI,kBAAkB,EAAE,MAAM,GAAG,CAAC,EAAE;gBACxD,OAAO,kBAAkB,CAAC,CAAC,CAAC,CAAC;aAC9B;YACD,OAAO,IAAI,CAAC;SACb;QAAC,OAAO,KAAK,EAAE;YACd,MAAM,CAAC,KAAK,CAAC,8CAA8C,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC,CAAC;YAC5F,OAAO,IAAI,CAAC;SACb;IACH,CAAC,CAAC;CACH"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adtrackify/at-service-common",
3
- "version": "3.0.40",
3
+ "version": "3.0.42",
4
4
  "description": "",
5
5
  "files": [
6
6
  "dist/*"
@@ -48,10 +48,11 @@
48
48
  "luxon": "^3.0.3",
49
49
  "postmark": "^3.0.14",
50
50
  "ua-parser-js": "^1.0.2",
51
- "uuid": "^9.0.0"
51
+ "uuid": "^9.0.0",
52
+ "mysql2": "^3.11.0"
52
53
  },
53
54
  "devDependencies": {
54
- "@adtrackify/at-tracking-event-types": "^3.0.86",
55
+ "@adtrackify/at-tracking-event-types": "^3.0.98",
55
56
  "@aws-sdk/client-cognito-identity-provider": "^3.345.0",
56
57
  "@aws-sdk/client-dynamodb": "^3.345.0",
57
58
  "@aws-sdk/client-eventbridge": "^3.345.0",