@adtrackify/at-service-common 1.0.29 → 1.0.30
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 +9 -9
- package/dist/index.js +82 -81
- package/dist/index.js.map +2 -2
- package/package.json +1 -1
- package/src/clients/third-party/shopify-client.ts +9 -9
package/dist/index.d.ts
CHANGED
|
@@ -195,7 +195,7 @@ declare module '@adtrackify/at-service-common/clients/third-party/index' {
|
|
|
195
195
|
}
|
|
196
196
|
declare module '@adtrackify/at-service-common/clients/third-party/shopify-client' {
|
|
197
197
|
export class ShopifyClient {
|
|
198
|
-
getConfig: (shopifyDomain: string, accessToken: string) => {
|
|
198
|
+
static getConfig: (shopifyDomain: string, accessToken: string) => {
|
|
199
199
|
baseURL: string;
|
|
200
200
|
headers: {
|
|
201
201
|
common: {
|
|
@@ -203,7 +203,7 @@ declare module '@adtrackify/at-service-common/clients/third-party/shopify-client
|
|
|
203
203
|
};
|
|
204
204
|
};
|
|
205
205
|
};
|
|
206
|
-
getClient: (shopifyDomain: string, accessToken: string) => {
|
|
206
|
+
static getClient: (shopifyDomain: string, accessToken: string) => {
|
|
207
207
|
instance: () => import("axios").AxiosInstance;
|
|
208
208
|
get: (url: string, config?: any) => Promise<{
|
|
209
209
|
headers: any;
|
|
@@ -232,37 +232,37 @@ declare module '@adtrackify/at-service-common/clients/third-party/shopify-client
|
|
|
232
232
|
}>;
|
|
233
233
|
setBaseUrl: (url: string) => boolean;
|
|
234
234
|
};
|
|
235
|
-
registerApp: (shop: string, code: string, appKey: string, appSecret: string) => Promise<{
|
|
235
|
+
static registerApp: (shop: string, code: string, appKey: string, appSecret: string) => Promise<{
|
|
236
236
|
headers: any;
|
|
237
237
|
data: any;
|
|
238
238
|
status: any;
|
|
239
239
|
}>;
|
|
240
|
-
registerWebhookTopic: (shop: string, accessToken: string, eventBridgeArn: string, topic: string) => Promise<{
|
|
240
|
+
static registerWebhookTopic: (shop: string, accessToken: string, eventBridgeArn: string, topic: string) => Promise<{
|
|
241
241
|
headers: any;
|
|
242
242
|
data: any;
|
|
243
243
|
status: any;
|
|
244
244
|
}>;
|
|
245
|
-
updateShopifyAppMetafield: (shop: string, accessToken: string, pixelId: string) => Promise<{
|
|
245
|
+
static updateShopifyAppMetafield: (shop: string, accessToken: string, pixelId: string) => Promise<{
|
|
246
246
|
headers: any;
|
|
247
247
|
data: any;
|
|
248
248
|
status: any;
|
|
249
249
|
}>;
|
|
250
|
-
getShopifyStoreProperties: (shop: string, accessToken: string) => Promise<{
|
|
250
|
+
static getShopifyStoreProperties: (shop: string, accessToken: string) => Promise<{
|
|
251
251
|
headers: any;
|
|
252
252
|
data: any;
|
|
253
253
|
status: any;
|
|
254
254
|
}>;
|
|
255
|
-
genericShopifyPost: (url: string, accessToken: string, payload: any) => Promise<{
|
|
255
|
+
static genericShopifyPost: (url: string, accessToken: string, payload: any) => Promise<{
|
|
256
256
|
headers: any;
|
|
257
257
|
data: any;
|
|
258
258
|
status: any;
|
|
259
259
|
}>;
|
|
260
|
-
genericShopifyGet: (url: string, accessToken: string) => Promise<{
|
|
260
|
+
static genericShopifyGet: (url: string, accessToken: string) => Promise<{
|
|
261
261
|
headers: any;
|
|
262
262
|
data: any;
|
|
263
263
|
status: any;
|
|
264
264
|
}>;
|
|
265
|
-
genericShopifyPut: (url: string, accessToken: string, payload: any) => Promise<{
|
|
265
|
+
static genericShopifyPut: (url: string, accessToken: string, payload: any) => Promise<{
|
|
266
266
|
headers: any;
|
|
267
267
|
data: any;
|
|
268
268
|
status: any;
|
package/dist/index.js
CHANGED
|
@@ -628203,94 +628203,95 @@ var AccountsClient = class {
|
|
|
628203
628203
|
// src/clients/third-party/shopify-client.ts
|
|
628204
628204
|
import * as log4 from "lambda-log";
|
|
628205
628205
|
var _shopify_api_version = process.env.SHOPIFY_API_VERSION;
|
|
628206
|
-
var
|
|
628207
|
-
|
|
628208
|
-
|
|
628209
|
-
|
|
628210
|
-
|
|
628211
|
-
|
|
628212
|
-
|
|
628213
|
-
|
|
628214
|
-
|
|
628215
|
-
};
|
|
628216
|
-
return config;
|
|
628217
|
-
};
|
|
628218
|
-
getClient = (shopifyDomain, accessToken) => {
|
|
628219
|
-
return axiosHttpService(
|
|
628220
|
-
this.getConfig(shopifyDomain, accessToken)
|
|
628221
|
-
);
|
|
628222
|
-
};
|
|
628223
|
-
registerApp = async (shop, code, appKey, appSecret) => {
|
|
628224
|
-
const client2 = axiosHttpService();
|
|
628225
|
-
const url = "https://" + shop + "/admin/oauth/access_token";
|
|
628226
|
-
const payload2 = {
|
|
628227
|
-
client_id: appKey,
|
|
628228
|
-
client_secret: appSecret,
|
|
628229
|
-
code
|
|
628230
|
-
};
|
|
628231
|
-
const res = await client2.post(url, payload2);
|
|
628232
|
-
return res;
|
|
628233
|
-
};
|
|
628234
|
-
registerWebhookTopic = async (shop, accessToken, eventBridgeArn, topic) => {
|
|
628235
|
-
const client2 = axiosHttpService();
|
|
628236
|
-
const url = `https://${shop}/admin/api/${_shopify_api_version}/webhooks.json`;
|
|
628237
|
-
const payload2 = {
|
|
628238
|
-
webhook: {
|
|
628239
|
-
topic,
|
|
628240
|
-
address: eventBridgeArn,
|
|
628241
|
-
format: "json"
|
|
628206
|
+
var _ShopifyClient = class {
|
|
628207
|
+
};
|
|
628208
|
+
var ShopifyClient = _ShopifyClient;
|
|
628209
|
+
__publicField(ShopifyClient, "getConfig", (shopifyDomain, accessToken) => {
|
|
628210
|
+
const config = {
|
|
628211
|
+
baseURL: `https://${shopifyDomain}/admin/api/${_shopify_api_version}`,
|
|
628212
|
+
headers: {
|
|
628213
|
+
common: {
|
|
628214
|
+
"X-Shopify-Access-Token": accessToken
|
|
628242
628215
|
}
|
|
628243
|
-
};
|
|
628244
|
-
const res = await client2.post(url, payload2, { headers: { "X-Shopify-Access-Token": accessToken } });
|
|
628245
|
-
if (res.status >= 400) {
|
|
628246
|
-
log4.error("Failed to register Webhook Topic", { shop, accessToken, eventBridgeArn, topic, url, payload: payload2 });
|
|
628247
628216
|
}
|
|
628248
|
-
log4.debug("Shopify Client Webhook Registration Response", { registrationResponse: res });
|
|
628249
|
-
return res;
|
|
628250
628217
|
};
|
|
628251
|
-
|
|
628252
|
-
|
|
628253
|
-
|
|
628254
|
-
|
|
628255
|
-
|
|
628256
|
-
|
|
628257
|
-
|
|
628258
|
-
|
|
628259
|
-
|
|
628260
|
-
|
|
628261
|
-
|
|
628262
|
-
|
|
628263
|
-
|
|
628264
|
-
|
|
628265
|
-
return res;
|
|
628218
|
+
return config;
|
|
628219
|
+
});
|
|
628220
|
+
__publicField(ShopifyClient, "getClient", (shopifyDomain, accessToken) => {
|
|
628221
|
+
return axiosHttpService(
|
|
628222
|
+
_ShopifyClient.getConfig(shopifyDomain, accessToken)
|
|
628223
|
+
);
|
|
628224
|
+
});
|
|
628225
|
+
__publicField(ShopifyClient, "registerApp", async (shop, code, appKey, appSecret) => {
|
|
628226
|
+
const client2 = axiosHttpService();
|
|
628227
|
+
const url = "https://" + shop + "/admin/oauth/access_token";
|
|
628228
|
+
const payload2 = {
|
|
628229
|
+
client_id: appKey,
|
|
628230
|
+
client_secret: appSecret,
|
|
628231
|
+
code
|
|
628266
628232
|
};
|
|
628267
|
-
|
|
628268
|
-
|
|
628269
|
-
|
|
628270
|
-
|
|
628271
|
-
|
|
628233
|
+
const res = await client2.post(url, payload2);
|
|
628234
|
+
return res;
|
|
628235
|
+
});
|
|
628236
|
+
__publicField(ShopifyClient, "registerWebhookTopic", async (shop, accessToken, eventBridgeArn, topic) => {
|
|
628237
|
+
const client2 = axiosHttpService();
|
|
628238
|
+
const url = `https://${shop}/admin/api/${_shopify_api_version}/webhooks.json`;
|
|
628239
|
+
const payload2 = {
|
|
628240
|
+
webhook: {
|
|
628241
|
+
topic,
|
|
628242
|
+
address: eventBridgeArn,
|
|
628243
|
+
format: "json"
|
|
628272
628244
|
}
|
|
628273
|
-
return res;
|
|
628274
|
-
};
|
|
628275
|
-
genericShopifyPost = async (url, accessToken, payload2) => {
|
|
628276
|
-
const client2 = axiosHttpService();
|
|
628277
|
-
const res = await client2.post(url, payload2, { headers: { "X-Shopify-Access-Token": accessToken } });
|
|
628278
|
-
log4.debug("Shopify Client Response", { res });
|
|
628279
|
-
return res;
|
|
628280
628245
|
};
|
|
628281
|
-
|
|
628282
|
-
|
|
628283
|
-
|
|
628284
|
-
|
|
628285
|
-
|
|
628286
|
-
|
|
628287
|
-
|
|
628288
|
-
|
|
628289
|
-
|
|
628290
|
-
|
|
628291
|
-
|
|
628246
|
+
const res = await client2.post(url, payload2, { headers: { "X-Shopify-Access-Token": accessToken } });
|
|
628247
|
+
if (res.status >= 400) {
|
|
628248
|
+
log4.error("Failed to register Webhook Topic", { shop, accessToken, eventBridgeArn, topic, url, payload: payload2 });
|
|
628249
|
+
}
|
|
628250
|
+
log4.debug("Shopify Client Webhook Registration Response", { registrationResponse: res });
|
|
628251
|
+
return res;
|
|
628252
|
+
});
|
|
628253
|
+
__publicField(ShopifyClient, "updateShopifyAppMetafield", async (shop, accessToken, pixelId) => {
|
|
628254
|
+
const url = `https://${shop}/admin/api/${_shopify_api_version}/metafields.json`;
|
|
628255
|
+
const payload2 = {
|
|
628256
|
+
metafield: {
|
|
628257
|
+
namespace: "adtr",
|
|
628258
|
+
key: "adtr.config",
|
|
628259
|
+
value: pixelId,
|
|
628260
|
+
type: "single_line_text_field"
|
|
628261
|
+
}
|
|
628292
628262
|
};
|
|
628293
|
-
|
|
628263
|
+
const res = await _ShopifyClient.genericShopifyPost(url, accessToken, payload2);
|
|
628264
|
+
if (res.status >= 400) {
|
|
628265
|
+
log4.error("Failed to register Webhook Topic", { shop, accessToken, url, payload: payload2 });
|
|
628266
|
+
}
|
|
628267
|
+
return res;
|
|
628268
|
+
});
|
|
628269
|
+
__publicField(ShopifyClient, "getShopifyStoreProperties", async (shop, accessToken) => {
|
|
628270
|
+
const url = `https://${shop}/admin/api/${_shopify_api_version}/shop.json`;
|
|
628271
|
+
const res = await _ShopifyClient.genericShopifyGet(url, accessToken);
|
|
628272
|
+
if (res.status >= 400) {
|
|
628273
|
+
log4.error("Failed to get Shopify Store Properties", { shop, accessToken, url });
|
|
628274
|
+
}
|
|
628275
|
+
return res;
|
|
628276
|
+
});
|
|
628277
|
+
__publicField(ShopifyClient, "genericShopifyPost", async (url, accessToken, payload2) => {
|
|
628278
|
+
const client2 = axiosHttpService();
|
|
628279
|
+
const res = await client2.post(url, payload2, { headers: { "X-Shopify-Access-Token": accessToken } });
|
|
628280
|
+
log4.debug("Shopify Client Response", { res });
|
|
628281
|
+
return res;
|
|
628282
|
+
});
|
|
628283
|
+
__publicField(ShopifyClient, "genericShopifyGet", async (url, accessToken) => {
|
|
628284
|
+
const client2 = axiosHttpService();
|
|
628285
|
+
const res = await client2.get(url, { headers: { "X-Shopify-Access-Token": accessToken } });
|
|
628286
|
+
log4.debug("Shopify Client Response", { res });
|
|
628287
|
+
return res;
|
|
628288
|
+
});
|
|
628289
|
+
__publicField(ShopifyClient, "genericShopifyPut", async (url, accessToken, payload2) => {
|
|
628290
|
+
const client2 = axiosHttpService();
|
|
628291
|
+
const res = await client2.put(url, payload2, { headers: { "X-Shopify-Access-Token": accessToken } });
|
|
628292
|
+
log4.debug("Shopify Client Response", { res });
|
|
628293
|
+
return res;
|
|
628294
|
+
});
|
|
628294
628295
|
|
|
628295
628296
|
// src/libs/http-error.ts
|
|
628296
628297
|
import { strict as assert } from "assert";
|