@shopify/shopify-app-remix 1.0.0-rc.1 → 1.0.0
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/README.md +73 -18
- package/build/cjs/adapters/node/index.js +10 -0
- package/build/cjs/auth/admin/authenticate.js +25 -30
- package/build/cjs/auth/const.js +0 -8
- package/build/cjs/auth/helpers/add-response-headers.js +13 -50
- package/build/cjs/auth/helpers/app-bridge-url.js +16 -0
- package/build/cjs/auth/helpers/ensure-cors-headers.js +24 -0
- package/build/cjs/auth/helpers/redirect-with-app-bridge-headers.js +3 -9
- package/build/cjs/auth/helpers/respond-to-options-request.js +19 -0
- package/build/cjs/auth/login/login.js +0 -6
- package/build/cjs/auth/public/authenticate.js +5 -1
- package/build/cjs/billing/request.js +1 -1
- package/build/cjs/boundary/error.js +12 -0
- package/build/cjs/boundary/headers.js +18 -0
- package/build/cjs/index.js +57 -8
- package/build/cjs/types.js +1 -0
- package/build/cjs/version.js +1 -1
- package/build/ts/adapters/node/index.js +6 -0
- package/build/ts/adapters/node/index.js.map +1 -1
- package/build/ts/auth/admin/authenticate.d.ts +0 -2
- package/build/ts/auth/admin/authenticate.d.ts.map +1 -1
- package/build/ts/auth/admin/authenticate.js +13 -25
- package/build/ts/auth/admin/authenticate.js.map +1 -1
- package/build/ts/auth/admin/types.d.ts +32 -13
- package/build/ts/auth/admin/types.d.ts.map +1 -1
- package/build/ts/auth/const.d.ts +1 -2
- package/build/ts/auth/const.d.ts.map +1 -1
- package/build/ts/auth/const.js +2 -3
- package/build/ts/auth/const.js.map +1 -1
- package/build/ts/auth/helpers/add-response-headers.d.ts +2 -3
- package/build/ts/auth/helpers/add-response-headers.d.ts.map +1 -1
- package/build/ts/auth/helpers/add-response-headers.js +16 -49
- package/build/ts/auth/helpers/add-response-headers.js.map +1 -1
- package/build/ts/auth/helpers/app-bridge-url.d.ts +3 -0
- package/build/ts/auth/helpers/app-bridge-url.d.ts.map +1 -0
- package/build/ts/auth/helpers/app-bridge-url.js +14 -0
- package/build/ts/auth/helpers/app-bridge-url.js.map +1 -0
- package/build/ts/auth/helpers/ensure-cors-headers.d.ts +6 -0
- package/build/ts/auth/helpers/ensure-cors-headers.d.ts.map +1 -0
- package/build/ts/auth/helpers/ensure-cors-headers.js +19 -0
- package/build/ts/auth/helpers/ensure-cors-headers.js.map +1 -0
- package/build/ts/auth/helpers/index.d.ts +11 -7
- package/build/ts/auth/helpers/index.d.ts.map +1 -1
- package/build/ts/auth/helpers/index.js +12 -15
- package/build/ts/auth/helpers/index.js.map +1 -1
- package/build/ts/auth/helpers/redirect-with-app-bridge-headers.d.ts +1 -1
- package/build/ts/auth/helpers/redirect-with-app-bridge-headers.d.ts.map +1 -1
- package/build/ts/auth/helpers/redirect-with-app-bridge-headers.js +3 -7
- package/build/ts/auth/helpers/redirect-with-app-bridge-headers.js.map +1 -1
- package/build/ts/auth/helpers/respond-to-options-request.d.ts +3 -0
- package/build/ts/auth/helpers/respond-to-options-request.d.ts.map +1 -0
- package/build/ts/auth/helpers/respond-to-options-request.js +17 -0
- package/build/ts/auth/helpers/respond-to-options-request.js.map +1 -0
- package/build/ts/auth/login/login.d.ts.map +1 -1
- package/build/ts/auth/login/login.js +0 -4
- package/build/ts/auth/login/login.js.map +1 -1
- package/build/ts/auth/public/authenticate.d.ts.map +1 -1
- package/build/ts/auth/public/authenticate.js +2 -0
- package/build/ts/auth/public/authenticate.js.map +1 -1
- package/build/ts/auth/public/types.d.ts +25 -2
- package/build/ts/auth/public/types.d.ts.map +1 -1
- package/build/ts/billing/request.js +1 -1
- package/build/ts/billing/request.js.map +1 -1
- package/build/ts/billing/types.d.ts +20 -12
- package/build/ts/billing/types.d.ts.map +1 -1
- package/build/ts/boundary/error.d.ts +2 -0
- package/build/ts/boundary/error.d.ts.map +1 -0
- package/build/ts/boundary/error.js +11 -0
- package/build/ts/boundary/error.js.map +1 -0
- package/build/ts/boundary/headers.d.ts +3 -0
- package/build/ts/boundary/headers.d.ts.map +1 -0
- package/build/ts/boundary/headers.js +13 -0
- package/build/ts/boundary/headers.js.map +1 -0
- package/build/ts/boundary/types.d.ts +4 -0
- package/build/ts/boundary/types.d.ts.map +1 -0
- package/build/ts/boundary/types.js +3 -0
- package/build/ts/boundary/types.js.map +1 -0
- package/build/ts/config-types.d.ts +28 -18
- package/build/ts/config-types.d.ts.map +1 -1
- package/build/ts/index.d.ts +39 -1
- package/build/ts/index.d.ts.map +1 -1
- package/build/ts/index.js +56 -10
- package/build/ts/index.js.map +1 -1
- package/build/ts/types.d.ts +88 -122
- package/build/ts/types.d.ts.map +1 -1
- package/build/ts/types.js.map +1 -1
- package/build/ts/version.d.ts +1 -1
- package/build/ts/version.d.ts.map +1 -1
- package/build/ts/version.js +1 -1
- package/build/ts/version.js.map +1 -1
- package/build/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -23,10 +23,11 @@ export interface AppConfigArg<Resources extends ShopifyRestResources = ShopifyRe
|
|
|
23
23
|
*
|
|
24
24
|
* import prisma from "~/db.server";
|
|
25
25
|
*
|
|
26
|
-
*
|
|
26
|
+
* const shopify = shopifyApp({
|
|
27
27
|
* // ... etc
|
|
28
28
|
* sessionStorage: new PrismaSessionStorage(prisma),
|
|
29
29
|
* });
|
|
30
|
+
* export default shopify;
|
|
30
31
|
* ```
|
|
31
32
|
*/
|
|
32
33
|
sessionStorage: Storage;
|
|
@@ -53,7 +54,7 @@ export interface AppConfigArg<Resources extends ShopifyRestResources = ShopifyRe
|
|
|
53
54
|
* // app/shopify.server.ts
|
|
54
55
|
* import { DeliveryMethod, shopifyApp } from "@shopify/shopify-app-remix";
|
|
55
56
|
*
|
|
56
|
-
*
|
|
57
|
+
* const shopify = shopifyApp({
|
|
57
58
|
* webhooks: {
|
|
58
59
|
* APP_UNINSTALLED: {
|
|
59
60
|
* deliveryMethod: DeliveryMethod.Http,
|
|
@@ -67,15 +68,17 @@ export interface AppConfigArg<Resources extends ShopifyRestResources = ShopifyRe
|
|
|
67
68
|
* },
|
|
68
69
|
* // ...etc
|
|
69
70
|
* });
|
|
71
|
+
* export default shopify;
|
|
72
|
+
* export const authenticate = shopify.authenticate;
|
|
70
73
|
*
|
|
71
74
|
* // app/routes/webhooks.jsx
|
|
72
75
|
* import { ActionArgs } from "@remix-run/node";
|
|
73
76
|
*
|
|
74
|
-
* import {
|
|
77
|
+
* import { authenticate } from "../shopify.server";
|
|
75
78
|
* import db from "../db.server";
|
|
76
79
|
*
|
|
77
80
|
* export const action = async ({ request }: ActionArgs) => {
|
|
78
|
-
* const { topic, shop } = await
|
|
81
|
+
* const { topic, shop } = await authenticate.webhook(request);
|
|
79
82
|
*
|
|
80
83
|
* switch (topic) {
|
|
81
84
|
* case "APP_UNINSTALLED":
|
|
@@ -103,7 +106,7 @@ export interface AppConfigArg<Resources extends ShopifyRestResources = ShopifyRe
|
|
|
103
106
|
* import { DeliveryMethod, shopifyApp } from "@shopify/shopify-app-remix";
|
|
104
107
|
* import { seedStoreData } from "~/db/seeds"
|
|
105
108
|
*
|
|
106
|
-
*
|
|
109
|
+
* const shopify = shopifyApp({
|
|
107
110
|
* hooks: {
|
|
108
111
|
* afterAuth: async ({ session }) => {
|
|
109
112
|
* seedStoreData({session})
|
|
@@ -140,7 +143,7 @@ export interface AppConfigArg<Resources extends ShopifyRestResources = ShopifyRe
|
|
|
140
143
|
* ```ts
|
|
141
144
|
* import { LATEST_API_VERSION, shopifyApp } from "@shopify/shopify-app-remix";
|
|
142
145
|
*
|
|
143
|
-
*
|
|
146
|
+
* const shopify = shopifyApp({
|
|
144
147
|
* // ...etc
|
|
145
148
|
* apiVersion: LATEST_API_VERSION,
|
|
146
149
|
* });
|
|
@@ -160,17 +163,19 @@ export interface AppConfigArg<Resources extends ShopifyRestResources = ShopifyRe
|
|
|
160
163
|
* // app/shopify.server.ts
|
|
161
164
|
* import { LATEST_API_VERSION, shopifyApp } from "@shopify/shopify-app-remix";
|
|
162
165
|
*
|
|
163
|
-
*
|
|
166
|
+
* const shopify = shopifyApp({
|
|
164
167
|
* // ...etc
|
|
165
168
|
* apiVersion: LATEST_API_VERSION,
|
|
166
169
|
* });
|
|
170
|
+
* export default shopify;
|
|
171
|
+
* export const authenticate = shopify.authenticate;
|
|
167
172
|
*
|
|
168
173
|
* // app/routes/auth/$.jsx
|
|
169
174
|
* import { LoaderArgs } from "@remix-run/node";
|
|
170
|
-
* import {
|
|
175
|
+
* import { authenticate } from "../../shopify.server";
|
|
171
176
|
*
|
|
172
177
|
* export async function loader({ request }: LoaderArgs) {
|
|
173
|
-
* await
|
|
178
|
+
* await authenticate.admin(request);
|
|
174
179
|
*
|
|
175
180
|
* return null
|
|
176
181
|
* }
|
|
@@ -210,7 +215,7 @@ interface HooksConfig {
|
|
|
210
215
|
* import { DeliveryMethod, shopifyApp } from "@shopify/shopify-app-remix";
|
|
211
216
|
* import { seedStoreData } from "~/db/seeds"
|
|
212
217
|
*
|
|
213
|
-
*
|
|
218
|
+
* const shopify = shopifyApp({
|
|
214
219
|
* hooks: {
|
|
215
220
|
* afterAuth: async ({ session }) => {
|
|
216
221
|
* shopify.registerWebhooks({ session });
|
|
@@ -246,19 +251,21 @@ export interface AdminApiContext<Resources extends ShopifyRestResources = Shopif
|
|
|
246
251
|
* ```ts
|
|
247
252
|
* // app/shopify.server.ts
|
|
248
253
|
* import { shopifyApp } from "@shopify/shopify-app-remix";
|
|
249
|
-
* import { restResources } from "@shopify/shopify-api/rest/admin/2023-
|
|
254
|
+
* import { restResources } from "@shopify/shopify-api/rest/admin/2023-07";
|
|
250
255
|
*
|
|
251
|
-
*
|
|
256
|
+
* const shopify = shopifyApp({
|
|
252
257
|
* restResources,
|
|
253
258
|
* // ...etc
|
|
254
259
|
* });
|
|
260
|
+
* export default shopify;
|
|
261
|
+
* export const authenticate = shopify.authenticate;
|
|
255
262
|
*
|
|
256
263
|
* // app/routes/**\/.ts
|
|
257
264
|
* import { LoaderArgs, json } from "@remix-run/node";
|
|
258
|
-
* import {
|
|
265
|
+
* import { authenticate } from "../shopify.server";
|
|
259
266
|
*
|
|
260
267
|
* export const loader = async ({ request }: LoaderArgs) => {
|
|
261
|
-
* const { admin, session } = await
|
|
268
|
+
* const { admin, session } = await authenticate.admin(request);
|
|
262
269
|
* return json(admin.rest.resources.Order.count({ session }));
|
|
263
270
|
* };
|
|
264
271
|
* ```
|
|
@@ -270,16 +277,19 @@ export interface AdminApiContext<Resources extends ShopifyRestResources = Shopif
|
|
|
270
277
|
* import { shopifyApp } from "@shopify/shopify-app-remix";
|
|
271
278
|
* import { restResources } from "@shopify/shopify-api/rest/admin/2023-04";
|
|
272
279
|
*
|
|
273
|
-
*
|
|
280
|
+
* const shopify = shopifyApp({
|
|
274
281
|
* restResources,
|
|
275
282
|
* // ...etc
|
|
276
283
|
* });
|
|
284
|
+
* export default shopify;
|
|
285
|
+
* export const authenticate = shopify.authenticate;
|
|
277
286
|
*
|
|
278
287
|
* // app/routes/**\/.ts
|
|
279
288
|
* import { LoaderArgs, json } from "@remix-run/node";
|
|
280
|
-
* import {
|
|
289
|
+
* import { authenticate } from "../shopify.server";
|
|
281
290
|
*
|
|
282
291
|
* export const loader = async ({ request }: LoaderArgs) => {
|
|
292
|
+
* const { admin, session } = await authenticate.admin(request);
|
|
283
293
|
* const response = await admin.rest.get({ path: "/customers/count.json" });
|
|
284
294
|
* const customers = await response.json();
|
|
285
295
|
* return json({ customers });
|
|
@@ -297,10 +307,10 @@ export interface AdminApiContext<Resources extends ShopifyRestResources = Shopif
|
|
|
297
307
|
* Creating a new product
|
|
298
308
|
* ```ts
|
|
299
309
|
* import { ActionArgs } from "@remix-run/node";
|
|
300
|
-
* import {
|
|
310
|
+
* import { authenticate } from "../shopify.server";
|
|
301
311
|
*
|
|
302
312
|
* export async function action({ request }: ActionArgs) {
|
|
303
|
-
* const { admin } = await
|
|
313
|
+
* const { admin } = await authenticate.admin(request);
|
|
304
314
|
*
|
|
305
315
|
* const response = await admin.graphql(
|
|
306
316
|
* `#graphql
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-types.d.ts","sourceRoot":"","sources":["../../src/config-types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,IAAI,YAAY,EAC5B,eAAe,IAAI,SAAS,EAC5B,oBAAoB,EACpB,OAAO,EACP,UAAU,EACV,cAAc,EACf,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAC,cAAc,EAAC,MAAM,sCAAsC,CAAC;AAEpE,OAAO,KAAK,EAAC,oBAAoB,EAAC,MAAM,6BAA6B,CAAC;AACtE,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAC,eAAe,EAAC,MAAM,SAAS,CAAC;AAExC,MAAM,WAAW,YAAY,CAC3B,SAAS,SAAS,oBAAoB,GAAG,oBAAoB,EAC7D,OAAO,SAAS,cAAc,GAAG,cAAc,CAC/C,SAAQ,IAAI,CACV,YAAY,CAAC,SAAS,CAAC,EACrB,UAAU,GACV,YAAY,GACZ,eAAe,GACf,YAAY,GACZ,kBAAkB,CACrB;IACD;;;;OAIG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf
|
|
1
|
+
{"version":3,"file":"config-types.d.ts","sourceRoot":"","sources":["../../src/config-types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,IAAI,YAAY,EAC5B,eAAe,IAAI,SAAS,EAC5B,oBAAoB,EACpB,OAAO,EACP,UAAU,EACV,cAAc,EACf,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAC,cAAc,EAAC,MAAM,sCAAsC,CAAC;AAEpE,OAAO,KAAK,EAAC,oBAAoB,EAAC,MAAM,6BAA6B,CAAC;AACtE,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAC,eAAe,EAAC,MAAM,SAAS,CAAC;AAExC,MAAM,WAAW,YAAY,CAC3B,SAAS,SAAS,oBAAoB,GAAG,oBAAoB,EAC7D,OAAO,SAAS,c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M,GAAG,cAAc,GAAG,cAAc,EAAE,CAAC;CAClD;AAED,UAAU,WAAW;IACnB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA6BG;IACH,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,gBAAgB,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACjE;AAED,MAAM,WAAW,gBAAgB,CAC/B,CAAC,SAAS,oBAAoB,GAAG,oBAAoB;IAErD,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,eAAe,CAAC,CAAC,CAAC,CAAC;CAC3B;AAED,MAAM,WAAW,eAAe,CAC9B,SAAS,SAAS,oBAAoB,GAAG,oBAAoB;IAE7D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAwDG;IACH,IAAI,EAAE,eAAe,CAAC,SAAS,CAAC,CAAC;IAEjC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA+BG;IACH,OAAO,EAAE,oBAAoB,CAAC;CAC/B"}
|
package/build/ts/index.d.ts
CHANGED
|
@@ -3,6 +3,8 @@ import { ShopifyRestResources } from '@shopify/shopify-api';
|
|
|
3
3
|
import { SessionStorage } from '@shopify/shopify-app-session-storage';
|
|
4
4
|
import { type AppConfigArg } from './config-types';
|
|
5
5
|
import { type ShopifyApp } from './types';
|
|
6
|
+
import { headersBoundary } from './boundary/headers';
|
|
7
|
+
import { errorBoundary } from './boundary/error';
|
|
6
8
|
export type { ShopifyApp, LoginError } from './types';
|
|
7
9
|
export { LoginErrorType, AppDistribution } from './types';
|
|
8
10
|
export { LATEST_API_VERSION, LogSeverity, DeliveryMethod, BillingInterval, } from '@shopify/shopify-api';
|
|
@@ -17,13 +19,49 @@ export { LATEST_API_VERSION, LogSeverity, DeliveryMethod, BillingInterval, } fro
|
|
|
17
19
|
* ```ts
|
|
18
20
|
* import { shopifyApp } from "@shopify/shopify-app-remix";
|
|
19
21
|
*
|
|
20
|
-
*
|
|
22
|
+
* const shopify = shopifyApp({
|
|
21
23
|
* apiKey: process.env.SHOPIFY_API_KEY!,
|
|
22
24
|
* apiSecretKey: process.env.SHOPIFY_API_SECRET!,
|
|
23
25
|
* scopes: process.env.SCOPES?.split(",")!,
|
|
24
26
|
* appUrl: process.env.SHOPIFY_APP_URL!,
|
|
25
27
|
* });
|
|
28
|
+
* export default shopify;
|
|
26
29
|
* ```
|
|
27
30
|
*/
|
|
28
31
|
export declare function shopifyApp<Config extends AppConfigArg<Resources, Storage>, Resources extends ShopifyRestResources, Storage extends SessionStorage>(appConfig: Config): ShopifyApp<Config>;
|
|
32
|
+
/**
|
|
33
|
+
* A collection of functions that handle the necessary code for error boundaries in routes using authenticate.admin.
|
|
34
|
+
*/
|
|
35
|
+
export declare const boundary: {
|
|
36
|
+
/**
|
|
37
|
+
* A function that handles errors or thrown responses.
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* Catching errors in a route
|
|
41
|
+
* ```ts
|
|
42
|
+
* // app/routes/admin/widgets.ts
|
|
43
|
+
* import { boundary } from "@shopify/shopify-app-remix";
|
|
44
|
+
*
|
|
45
|
+
* export function ErrorBoundary() {
|
|
46
|
+
* return boundary.error(useRouteError());
|
|
47
|
+
* }
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
error: typeof errorBoundary;
|
|
51
|
+
/**
|
|
52
|
+
* A function that sets the appropriate document repsonse headers.
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* Catching errors in a route
|
|
56
|
+
* ```ts
|
|
57
|
+
* // app/routes/admin/widgets.ts
|
|
58
|
+
* import { boundary } from "@shopify/shopify-app-remix";
|
|
59
|
+
*
|
|
60
|
+
* export const headers = (headersArgs) => {
|
|
61
|
+
* return boundary.headers(headersArgs);
|
|
62
|
+
* };
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
65
|
+
headers: typeof headersBoundary;
|
|
66
|
+
};
|
|
29
67
|
//# sourceMappingURL=index.d.ts.map
|
package/build/ts/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,uCAAuC,CAAC;AAC/C,OAAO,EAML,oBAAoB,EAErB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAC,cAAc,EAAC,MAAM,sCAAsC,CAAC;AAEpE,OAAO,EAAiB,KAAK,YAAY,EAAC,MAAM,gBAAgB,CAAC;AACjE,OAAO,EAIL,KAAK,UAAU,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,uCAAuC,CAAC;AAC/C,OAAO,EAML,oBAAoB,EAErB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAC,cAAc,EAAC,MAAM,sCAAsC,CAAC;AAEpE,OAAO,EAAiB,KAAK,YAAY,EAAC,MAAM,gBAAgB,CAAC;AACjE,OAAO,EAIL,KAAK,UAAU,EAKhB,MAAM,SAAS,CAAC;AASjB,OAAO,EAAC,eAAe,EAAC,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAC,aAAa,EAAC,MAAM,kBAAkB,CAAC;AAE/C,YAAY,EAAC,UAAU,EAAE,UAAU,EAAC,MAAM,SAAS,CAAC;AACpD,OAAO,EAAC,cAAc,EAAE,eAAe,EAAC,MAAM,SAAS,CAAC;AAExD,OAAO,EACL,kBAAkB,EAClB,WAAW,EACX,cAAc,EACd,eAAe,GAChB,MAAM,sBAAsB,CAAC;AAM9B;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,UAAU,CACxB,MAAM,SAAS,YAAY,CAAC,SAAS,EAAE,OAAO,CAAC,EAC/C,SAAS,SAAS,oBAAoB,EACtC,OAAO,SAAS,cAAc,EAC9B,SAAS,EAAE,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC,CAqCvC;AAED;;GAEG;AACH,eAAO,MAAM,QAAQ;IACnB;;;;;;;;;;;;;OAaG;;IAGH;;;;;;;;;;;;;OAaG;;CAEJ,CAAC"}
|
package/build/ts/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.shopifyApp = exports.BillingInterval = exports.DeliveryMethod = exports.LogSeverity = exports.LATEST_API_VERSION = exports.AppDistribution = exports.LoginErrorType = void 0;
|
|
3
|
+
exports.boundary = exports.shopifyApp = exports.BillingInterval = exports.DeliveryMethod = exports.LogSeverity = exports.LATEST_API_VERSION = exports.AppDistribution = exports.LoginErrorType = void 0;
|
|
4
4
|
var tslib_1 = require("tslib");
|
|
5
5
|
require("@shopify/shopify-api/adapters/web-api");
|
|
6
6
|
var shopify_api_1 = require("@shopify/shopify-api");
|
|
@@ -12,8 +12,10 @@ var authenticate_1 = require("./auth/admin/authenticate");
|
|
|
12
12
|
var authenticate_2 = require("./auth/webhooks/authenticate");
|
|
13
13
|
var authenticate_3 = require("./auth/public/authenticate");
|
|
14
14
|
var override_logger_1 = require("./override-logger");
|
|
15
|
-
var
|
|
15
|
+
var helpers_1 = require("./auth/helpers");
|
|
16
16
|
var login_1 = require("./auth/login/login");
|
|
17
|
+
var headers_1 = require("./boundary/headers");
|
|
18
|
+
var error_1 = require("./boundary/error");
|
|
17
19
|
var types_2 = require("./types");
|
|
18
20
|
Object.defineProperty(exports, "LoginErrorType", { enumerable: true, get: function () { return types_2.LoginErrorType; } });
|
|
19
21
|
Object.defineProperty(exports, "AppDistribution", { enumerable: true, get: function () { return types_2.AppDistribution; } });
|
|
@@ -36,38 +38,82 @@ Object.defineProperty(exports, "BillingInterval", { enumerable: true, get: funct
|
|
|
36
38
|
* ```ts
|
|
37
39
|
* import { shopifyApp } from "@shopify/shopify-app-remix";
|
|
38
40
|
*
|
|
39
|
-
*
|
|
41
|
+
* const shopify = shopifyApp({
|
|
40
42
|
* apiKey: process.env.SHOPIFY_API_KEY!,
|
|
41
43
|
* apiSecretKey: process.env.SHOPIFY_API_SECRET!,
|
|
42
44
|
* scopes: process.env.SCOPES?.split(",")!,
|
|
43
45
|
* appUrl: process.env.SHOPIFY_APP_URL!,
|
|
44
46
|
* });
|
|
47
|
+
* export default shopify;
|
|
45
48
|
* ```
|
|
46
49
|
*/
|
|
47
50
|
function shopifyApp(appConfig) {
|
|
48
51
|
var api = deriveApi(appConfig);
|
|
49
52
|
var config = deriveConfig(appConfig, api.config);
|
|
50
53
|
var logger = (0, override_logger_1.overrideLogger)(api.logger);
|
|
51
|
-
(0, add_response_headers_1.installGlobalResponseHeaders)(config.isEmbeddedApp);
|
|
52
54
|
if (appConfig.webhooks) {
|
|
53
55
|
api.webhooks.addHandlers(appConfig.webhooks);
|
|
54
56
|
}
|
|
55
57
|
var params = { api: api, config: config, logger: logger };
|
|
56
58
|
var oauth = new authenticate_1.AuthStrategy(params);
|
|
57
|
-
|
|
59
|
+
var shopify = {
|
|
58
60
|
sessionStorage: config.sessionStorage,
|
|
59
|
-
|
|
60
|
-
addResponseHeaders: (0, add_response_headers_1.addResponseHeadersFactory)(params),
|
|
61
|
+
addDocumentResponseHeaders: (0, helpers_1.addDocumentResponseHeadersFactory)(params),
|
|
61
62
|
registerWebhooks: (0, webhooks_1.registerWebhooksFactory)(params),
|
|
62
|
-
login: (0, login_1.loginFactory)(params),
|
|
63
63
|
authenticate: {
|
|
64
64
|
admin: oauth.authenticateAdmin.bind(oauth),
|
|
65
65
|
public: (0, authenticate_3.authenticatePublicFactory)(params),
|
|
66
66
|
webhook: (0, authenticate_2.authenticateWebhookFactory)(params),
|
|
67
67
|
},
|
|
68
68
|
};
|
|
69
|
+
if (isAppStoreApp(shopify, appConfig) ||
|
|
70
|
+
isSingleMerchantApp(shopify, appConfig)) {
|
|
71
|
+
shopify.login = (0, login_1.loginFactory)(params);
|
|
72
|
+
}
|
|
73
|
+
return shopify;
|
|
69
74
|
}
|
|
70
75
|
exports.shopifyApp = shopifyApp;
|
|
76
|
+
/**
|
|
77
|
+
* A collection of functions that handle the necessary code for error boundaries in routes using authenticate.admin.
|
|
78
|
+
*/
|
|
79
|
+
exports.boundary = {
|
|
80
|
+
/**
|
|
81
|
+
* A function that handles errors or thrown responses.
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* Catching errors in a route
|
|
85
|
+
* ```ts
|
|
86
|
+
* // app/routes/admin/widgets.ts
|
|
87
|
+
* import { boundary } from "@shopify/shopify-app-remix";
|
|
88
|
+
*
|
|
89
|
+
* export function ErrorBoundary() {
|
|
90
|
+
* return boundary.error(useRouteError());
|
|
91
|
+
* }
|
|
92
|
+
* ```
|
|
93
|
+
*/
|
|
94
|
+
error: error_1.errorBoundary,
|
|
95
|
+
/**
|
|
96
|
+
* A function that sets the appropriate document repsonse headers.
|
|
97
|
+
*
|
|
98
|
+
* @example
|
|
99
|
+
* Catching errors in a route
|
|
100
|
+
* ```ts
|
|
101
|
+
* // app/routes/admin/widgets.ts
|
|
102
|
+
* import { boundary } from "@shopify/shopify-app-remix";
|
|
103
|
+
*
|
|
104
|
+
* export const headers = (headersArgs) => {
|
|
105
|
+
* return boundary.headers(headersArgs);
|
|
106
|
+
* };
|
|
107
|
+
* ```
|
|
108
|
+
*/
|
|
109
|
+
headers: headers_1.headersBoundary,
|
|
110
|
+
};
|
|
111
|
+
function isAppStoreApp(_shopify, config) {
|
|
112
|
+
return config.distribution === types_1.AppDistribution.AppStore;
|
|
113
|
+
}
|
|
114
|
+
function isSingleMerchantApp(_shopify, config) {
|
|
115
|
+
return config.distribution === types_1.AppDistribution.SingleMerchant;
|
|
116
|
+
}
|
|
71
117
|
function deriveApi(appConfig) {
|
|
72
118
|
var _a, _b;
|
|
73
119
|
var appUrl;
|
|
@@ -96,8 +142,8 @@ function deriveConfig(appConfig, apiConfig) {
|
|
|
96
142
|
throw new shopify_api_1.ShopifyError('Please provide a valid session storage. See https://github.com/Shopify/shopify-app-js/blob/main/README.md#session-storage-options for options.');
|
|
97
143
|
}
|
|
98
144
|
var authPathPrefix = appConfig.authPathPrefix || '/auth';
|
|
99
|
-
|
|
100
|
-
return tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({}, appConfig), apiConfig), { canUseLoginForm: distribution !== types_1.AppDistribution.ShopifyAdmin, useOnlineTokens: (_b = appConfig.useOnlineTokens) !== null && _b !== void 0 ? _b : false, hooks: (_c = appConfig.hooks) !== null && _c !== void 0 ? _c : {}, sessionStorage: appConfig.sessionStorage, auth: {
|
|
145
|
+
appConfig.distribution = (_a = appConfig.distribution) !== null && _a !== void 0 ? _a : types_1.AppDistribution.AppStore;
|
|
146
|
+
return tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({}, appConfig), apiConfig), { canUseLoginForm: appConfig.distribution !== types_1.AppDistribution.ShopifyAdmin, useOnlineTokens: (_b = appConfig.useOnlineTokens) !== null && _b !== void 0 ? _b : false, hooks: (_c = appConfig.hooks) !== null && _c !== void 0 ? _c : {}, sessionStorage: appConfig.sessionStorage, auth: {
|
|
101
147
|
path: authPathPrefix,
|
|
102
148
|
callbackPath: "".concat(authPathPrefix, "/callback"),
|
|
103
149
|
patchSessionTokenPath: "".concat(authPathPrefix, "/session-token"),
|
package/build/ts/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;AAAA,iDAA+C;AAC/C,oDAQ8B;AAC9B,wDAAsE;AAItE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;AAAA,iDAA+C;AAC/C,oDAQ8B;AAC9B,wDAAsE;AAItE,iCASiB;AACjB,qCAAwD;AACxD,4CAAwD;AACxD,0DAAuD;AACvD,6DAAwE;AACxE,2DAAqE;AACrE,qDAAiD;AACjD,0CAAiE;AACjE,4CAAgD;AAChD,8CAAmD;AACnD,0CAA+C;AAG/C,iCAAwD;AAAhD,uGAAA,c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