@drawbridge/drawbridge-utils 0.0.18 → 0.0.19
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/shopify.cjs +21 -1
- package/dist/shopify.d.cts +32 -1
- package/dist/shopify.d.ts +32 -1
- package/dist/shopify.js +21 -1
- package/package.json +1 -1
package/dist/shopify.cjs
CHANGED
|
@@ -65,6 +65,7 @@ var decrypt = (value) => {
|
|
|
65
65
|
};
|
|
66
66
|
|
|
67
67
|
// shopify.js
|
|
68
|
+
var SHOPIFY_ADMIN_API_VERSION = "2025-01";
|
|
68
69
|
var shopifyOAuthFetch = async (url, body) => {
|
|
69
70
|
const response = await fetch(url, {
|
|
70
71
|
method: "POST",
|
|
@@ -75,10 +76,28 @@ var shopifyOAuthFetch = async (url, body) => {
|
|
|
75
76
|
});
|
|
76
77
|
if (!response.ok) {
|
|
77
78
|
const text = await response.text().catch(() => "");
|
|
78
|
-
|
|
79
|
+
const error = new Error(response.status + ": " + text);
|
|
80
|
+
error.status = response.status;
|
|
81
|
+
throw error;
|
|
79
82
|
}
|
|
80
83
|
return response.json();
|
|
81
84
|
};
|
|
85
|
+
var pingShop = async ({ adminAccessToken, domain }) => {
|
|
86
|
+
const response = await fetch(
|
|
87
|
+
`https://${domain}/admin/api/${SHOPIFY_ADMIN_API_VERSION}/shop.json`,
|
|
88
|
+
{
|
|
89
|
+
headers: {
|
|
90
|
+
"X-Shopify-Access-Token": adminAccessToken
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
);
|
|
94
|
+
if (!response.ok) {
|
|
95
|
+
const text = await response.text().catch(() => "");
|
|
96
|
+
const error = new Error(response.status + ": " + text);
|
|
97
|
+
error.status = response.status;
|
|
98
|
+
throw error;
|
|
99
|
+
}
|
|
100
|
+
};
|
|
82
101
|
var refreshAdminToken = async ({ connection, controller }) => {
|
|
83
102
|
const settings = decrypt(connection.settings);
|
|
84
103
|
const { domain, refreshToken } = settings;
|
|
@@ -95,6 +114,7 @@ var refreshAdminToken = async ({ connection, controller }) => {
|
|
|
95
114
|
const newRefreshToken = data.refresh_token;
|
|
96
115
|
const expiresIn = data.expires_in;
|
|
97
116
|
const tokenExpiresAt = expiresIn ? new Date(Date.now() + expiresIn * 1e3) : null;
|
|
117
|
+
await pingShop({ adminAccessToken, domain });
|
|
98
118
|
const tokenWorkflow = await controller.get({
|
|
99
119
|
collection: "workflow",
|
|
100
120
|
query: {
|
package/dist/shopify.d.cts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { decrypt, encrypt } from './encrypt.cjs';
|
|
2
2
|
import 'crypto';
|
|
3
3
|
|
|
4
|
+
const SHOPIFY_ADMIN_API_VERSION = '2025-01';
|
|
5
|
+
|
|
4
6
|
const shopifyOAuthFetch = async ( url, body ) => {
|
|
5
7
|
|
|
6
8
|
const response = await fetch( url, {
|
|
@@ -14,8 +16,11 @@ const shopifyOAuthFetch = async ( url, body ) => {
|
|
|
14
16
|
if( ! response.ok ){
|
|
15
17
|
|
|
16
18
|
const text = await response.text().catch( () => '' );
|
|
19
|
+
const error = new Error( response.status + ': ' + text );
|
|
20
|
+
|
|
21
|
+
error.status = response.status;
|
|
17
22
|
|
|
18
|
-
throw
|
|
23
|
+
throw error;
|
|
19
24
|
|
|
20
25
|
}
|
|
21
26
|
|
|
@@ -23,6 +28,30 @@ const shopifyOAuthFetch = async ( url, body ) => {
|
|
|
23
28
|
|
|
24
29
|
};
|
|
25
30
|
|
|
31
|
+
const pingShop = async ({ adminAccessToken, domain }) => {
|
|
32
|
+
|
|
33
|
+
const response = await fetch(
|
|
34
|
+
`https://${ domain }/admin/api/${ SHOPIFY_ADMIN_API_VERSION }/shop.json`,
|
|
35
|
+
{
|
|
36
|
+
headers : {
|
|
37
|
+
'X-Shopify-Access-Token' : adminAccessToken
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
if( ! response.ok ){
|
|
43
|
+
|
|
44
|
+
const text = await response.text().catch( () => '' );
|
|
45
|
+
const error = new Error( response.status + ': ' + text );
|
|
46
|
+
|
|
47
|
+
error.status = response.status;
|
|
48
|
+
|
|
49
|
+
throw error;
|
|
50
|
+
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
};
|
|
54
|
+
|
|
26
55
|
const refreshAdminToken = async ({ connection, controller }) => {
|
|
27
56
|
|
|
28
57
|
const settings = decrypt( connection.settings );
|
|
@@ -43,6 +72,8 @@ const refreshAdminToken = async ({ connection, controller }) => {
|
|
|
43
72
|
const expiresIn = data.expires_in;
|
|
44
73
|
const tokenExpiresAt = expiresIn ? new Date( Date.now() + ( expiresIn * 1000 ) ) : null;
|
|
45
74
|
|
|
75
|
+
await pingShop({ adminAccessToken, domain });
|
|
76
|
+
|
|
46
77
|
const tokenWorkflow = await controller.get({
|
|
47
78
|
collection : 'workflow',
|
|
48
79
|
query : {
|
package/dist/shopify.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { decrypt, encrypt } from './encrypt.js';
|
|
2
2
|
import 'crypto';
|
|
3
3
|
|
|
4
|
+
const SHOPIFY_ADMIN_API_VERSION = '2025-01';
|
|
5
|
+
|
|
4
6
|
const shopifyOAuthFetch = async ( url, body ) => {
|
|
5
7
|
|
|
6
8
|
const response = await fetch( url, {
|
|
@@ -14,8 +16,11 @@ const shopifyOAuthFetch = async ( url, body ) => {
|
|
|
14
16
|
if( ! response.ok ){
|
|
15
17
|
|
|
16
18
|
const text = await response.text().catch( () => '' );
|
|
19
|
+
const error = new Error( response.status + ': ' + text );
|
|
20
|
+
|
|
21
|
+
error.status = response.status;
|
|
17
22
|
|
|
18
|
-
throw
|
|
23
|
+
throw error;
|
|
19
24
|
|
|
20
25
|
}
|
|
21
26
|
|
|
@@ -23,6 +28,30 @@ const shopifyOAuthFetch = async ( url, body ) => {
|
|
|
23
28
|
|
|
24
29
|
};
|
|
25
30
|
|
|
31
|
+
const pingShop = async ({ adminAccessToken, domain }) => {
|
|
32
|
+
|
|
33
|
+
const response = await fetch(
|
|
34
|
+
`https://${ domain }/admin/api/${ SHOPIFY_ADMIN_API_VERSION }/shop.json`,
|
|
35
|
+
{
|
|
36
|
+
headers : {
|
|
37
|
+
'X-Shopify-Access-Token' : adminAccessToken
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
if( ! response.ok ){
|
|
43
|
+
|
|
44
|
+
const text = await response.text().catch( () => '' );
|
|
45
|
+
const error = new Error( response.status + ': ' + text );
|
|
46
|
+
|
|
47
|
+
error.status = response.status;
|
|
48
|
+
|
|
49
|
+
throw error;
|
|
50
|
+
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
};
|
|
54
|
+
|
|
26
55
|
const refreshAdminToken = async ({ connection, controller }) => {
|
|
27
56
|
|
|
28
57
|
const settings = decrypt( connection.settings );
|
|
@@ -43,6 +72,8 @@ const refreshAdminToken = async ({ connection, controller }) => {
|
|
|
43
72
|
const expiresIn = data.expires_in;
|
|
44
73
|
const tokenExpiresAt = expiresIn ? new Date( Date.now() + ( expiresIn * 1000 ) ) : null;
|
|
45
74
|
|
|
75
|
+
await pingShop({ adminAccessToken, domain });
|
|
76
|
+
|
|
46
77
|
const tokenWorkflow = await controller.get({
|
|
47
78
|
collection : 'workflow',
|
|
48
79
|
query : {
|
package/dist/shopify.js
CHANGED
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
} from "./chunk-CUUQCM5T.js";
|
|
5
5
|
|
|
6
6
|
// shopify.js
|
|
7
|
+
var SHOPIFY_ADMIN_API_VERSION = "2025-01";
|
|
7
8
|
var shopifyOAuthFetch = async (url, body) => {
|
|
8
9
|
const response = await fetch(url, {
|
|
9
10
|
method: "POST",
|
|
@@ -14,10 +15,28 @@ var shopifyOAuthFetch = async (url, body) => {
|
|
|
14
15
|
});
|
|
15
16
|
if (!response.ok) {
|
|
16
17
|
const text = await response.text().catch(() => "");
|
|
17
|
-
|
|
18
|
+
const error = new Error(response.status + ": " + text);
|
|
19
|
+
error.status = response.status;
|
|
20
|
+
throw error;
|
|
18
21
|
}
|
|
19
22
|
return response.json();
|
|
20
23
|
};
|
|
24
|
+
var pingShop = async ({ adminAccessToken, domain }) => {
|
|
25
|
+
const response = await fetch(
|
|
26
|
+
`https://${domain}/admin/api/${SHOPIFY_ADMIN_API_VERSION}/shop.json`,
|
|
27
|
+
{
|
|
28
|
+
headers: {
|
|
29
|
+
"X-Shopify-Access-Token": adminAccessToken
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
);
|
|
33
|
+
if (!response.ok) {
|
|
34
|
+
const text = await response.text().catch(() => "");
|
|
35
|
+
const error = new Error(response.status + ": " + text);
|
|
36
|
+
error.status = response.status;
|
|
37
|
+
throw error;
|
|
38
|
+
}
|
|
39
|
+
};
|
|
21
40
|
var refreshAdminToken = async ({ connection, controller }) => {
|
|
22
41
|
const settings = decrypt(connection.settings);
|
|
23
42
|
const { domain, refreshToken } = settings;
|
|
@@ -34,6 +53,7 @@ var refreshAdminToken = async ({ connection, controller }) => {
|
|
|
34
53
|
const newRefreshToken = data.refresh_token;
|
|
35
54
|
const expiresIn = data.expires_in;
|
|
36
55
|
const tokenExpiresAt = expiresIn ? new Date(Date.now() + expiresIn * 1e3) : null;
|
|
56
|
+
await pingShop({ adminAccessToken, domain });
|
|
37
57
|
const tokenWorkflow = await controller.get({
|
|
38
58
|
collection: "workflow",
|
|
39
59
|
query: {
|
package/package.json
CHANGED