@shopify/shopify-app-remix 3.3.0 → 3.3.2
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/cjs/server/unauthenticated/admin/factory.js +2 -2
- package/dist/cjs/server/unauthenticated/admin/factory.js.map +1 -1
- package/dist/cjs/server/unauthenticated/storefront/factory.js +2 -2
- package/dist/cjs/server/unauthenticated/storefront/factory.js.map +1 -1
- package/dist/cjs/server/version.js +1 -1
- package/dist/esm/server/unauthenticated/admin/factory.mjs +2 -2
- package/dist/esm/server/unauthenticated/admin/factory.mjs.map +1 -1
- package/dist/esm/server/unauthenticated/storefront/factory.mjs +2 -2
- package/dist/esm/server/unauthenticated/storefront/factory.mjs.map +1 -1
- package/dist/esm/server/version.mjs +1 -1
- package/dist/ts/server/authenticate/admin/billing/types.d.ts +60 -36
- package/dist/ts/server/authenticate/admin/billing/types.d.ts.map +1 -1
- package/dist/ts/server/authenticate/webhooks/types.d.ts +32 -0
- package/dist/ts/server/authenticate/webhooks/types.d.ts.map +1 -1
- package/dist/ts/server/config-types.d.ts +42 -28
- package/dist/ts/server/config-types.d.ts.map +1 -1
- package/dist/ts/server/types.d.ts +64 -40
- package/dist/ts/server/types.d.ts.map +1 -1
- package/dist/ts/server/unauthenticated/admin/factory.d.ts.map +1 -1
- package/dist/ts/server/unauthenticated/storefront/factory.d.ts.map +1 -1
- package/dist/ts/server/version.d.ts +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +10 -10
- package/dist/cjs/server/unauthenticated/helpers/get-offline-session.js +0 -11
- package/dist/cjs/server/unauthenticated/helpers/get-offline-session.js.map +0 -1
- package/dist/esm/server/unauthenticated/helpers/get-offline-session.mjs +0 -9
- package/dist/esm/server/unauthenticated/helpers/get-offline-session.mjs.map +0 -1
- package/dist/ts/server/unauthenticated/helpers/get-offline-session.d.ts +0 -4
- package/dist/ts/server/unauthenticated/helpers/get-offline-session.d.ts.map +0 -1
- package/dist/ts/server/unauthenticated/helpers/index.d.ts +0 -2
- package/dist/ts/server/unauthenticated/helpers/index.d.ts.map +0 -1
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var createOrLoadOfflineSession = require('../../authenticate/helpers/create-or-load-offline-session.js');
|
|
3
4
|
var errors = require('../../errors.js');
|
|
4
5
|
var factory = require('../../clients/admin/factory.js');
|
|
5
|
-
var getOfflineSession = require('../helpers/get-offline-session.js');
|
|
6
6
|
|
|
7
7
|
function unauthenticatedAdminContextFactory(params) {
|
|
8
8
|
return async (shop) => {
|
|
9
|
-
const session = await
|
|
9
|
+
const session = await createOrLoadOfflineSession.createOrLoadOfflineSession(shop, params);
|
|
10
10
|
if (!session) {
|
|
11
11
|
throw new errors.SessionNotFoundError(`Could not find a session for shop ${shop} when creating unauthenticated admin context`);
|
|
12
12
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"factory.js","sources":["../../../../../../src/server/unauthenticated/admin/factory.ts"],"sourcesContent":[null],"names":["
|
|
1
|
+
{"version":3,"file":"factory.js","sources":["../../../../../../src/server/unauthenticated/admin/factory.ts"],"sourcesContent":[null],"names":["createOrLoadOfflineSession","SessionNotFoundError","adminClientFactory"],"mappings":";;;;;;AASM,SAAU,kCAAkC,CAEhD,MAAmB,EAAA;AACnB,IAAA,OAAO,OACL,IAAY,KACuC;QACnD,MAAM,OAAO,GAAG,MAAMA,qDAA0B,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QAE/D,IAAI,CAAC,OAAO,EAAE;AACZ,YAAA,MAAM,IAAIC,2BAAoB,CAC5B,qCAAqC,IAAI,CAAA,4CAAA,CAA8C,CACxF,CAAC;SACH;QAED,OAAO;YACL,OAAO;YACP,KAAK,EAAEC,0BAAkB,CAAY,EAAC,MAAM,EAAE,OAAO,EAAC,CAAC;SACxD,CAAC;AACJ,KAAC,CAAC;AACJ;;;;"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var createOrLoadOfflineSession = require('../../authenticate/helpers/create-or-load-offline-session.js');
|
|
3
4
|
var errors = require('../../errors.js');
|
|
4
5
|
var factory = require('../../clients/storefront/factory.js');
|
|
5
|
-
var getOfflineSession = require('../helpers/get-offline-session.js');
|
|
6
6
|
|
|
7
7
|
function unauthenticatedStorefrontContextFactory(params) {
|
|
8
8
|
return async (shop) => {
|
|
9
|
-
const session = await
|
|
9
|
+
const session = await createOrLoadOfflineSession.createOrLoadOfflineSession(shop, params);
|
|
10
10
|
if (!session) {
|
|
11
11
|
throw new errors.SessionNotFoundError(`Could not find a session for shop ${shop} when creating unauthenticated storefront context`);
|
|
12
12
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"factory.js","sources":["../../../../../../src/server/unauthenticated/storefront/factory.ts"],"sourcesContent":[null],"names":["
|
|
1
|
+
{"version":3,"file":"factory.js","sources":["../../../../../../src/server/unauthenticated/storefront/factory.ts"],"sourcesContent":[null],"names":["createOrLoadOfflineSession","SessionNotFoundError","storefrontClientFactory"],"mappings":";;;;;;AAUM,SAAU,uCAAuC,CACrD,MAAmB,EAAA;AAEnB,IAAA,OAAO,OAAO,IAAY,KAA+C;QACvE,MAAM,OAAO,GAAG,MAAMA,qDAA0B,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QAE/D,IAAI,CAAC,OAAO,EAAE;AACZ,YAAA,MAAM,IAAIC,2BAAoB,CAC5B,qCAAqC,IAAI,CAAA,iDAAA,CAAmD,CAC7F,CAAC;SACH;QAED,OAAO;YACL,OAAO;YACP,UAAU,EAAEC,+BAAuB,CAAC,EAAC,MAAM,EAAE,OAAO,EAAC,CAAC;SACvD,CAAC;AACJ,KAAC,CAAC;AACJ;;;;"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import { createOrLoadOfflineSession } from '../../authenticate/helpers/create-or-load-offline-session.mjs';
|
|
1
2
|
import { SessionNotFoundError } from '../../errors.mjs';
|
|
2
3
|
import { adminClientFactory } from '../../clients/admin/factory.mjs';
|
|
3
|
-
import { getOfflineSession } from '../helpers/get-offline-session.mjs';
|
|
4
4
|
|
|
5
5
|
function unauthenticatedAdminContextFactory(params) {
|
|
6
6
|
return async (shop) => {
|
|
7
|
-
const session = await
|
|
7
|
+
const session = await createOrLoadOfflineSession(shop, params);
|
|
8
8
|
if (!session) {
|
|
9
9
|
throw new SessionNotFoundError(`Could not find a session for shop ${shop} when creating unauthenticated admin context`);
|
|
10
10
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"factory.mjs","sources":["../../../../../../src/server/unauthenticated/admin/factory.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;AASM,SAAU,kCAAkC,CAEhD,MAAmB,EAAA;AACnB,IAAA,OAAO,OACL,IAAY,KACuC;QACnD,MAAM,OAAO,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"factory.mjs","sources":["../../../../../../src/server/unauthenticated/admin/factory.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;AASM,SAAU,kCAAkC,CAEhD,MAAmB,EAAA;AACnB,IAAA,OAAO,OACL,IAAY,KACuC;QACnD,MAAM,OAAO,GAAG,MAAM,0BAA0B,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QAE/D,IAAI,CAAC,OAAO,EAAE;AACZ,YAAA,MAAM,IAAI,oBAAoB,CAC5B,qCAAqC,IAAI,CAAA,4CAAA,CAA8C,CACxF,CAAC;SACH;QAED,OAAO;YACL,OAAO;YACP,KAAK,EAAE,kBAAkB,CAAY,EAAC,MAAM,EAAE,OAAO,EAAC,CAAC;SACxD,CAAC;AACJ,KAAC,CAAC;AACJ;;;;"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import { createOrLoadOfflineSession } from '../../authenticate/helpers/create-or-load-offline-session.mjs';
|
|
1
2
|
import { SessionNotFoundError } from '../../errors.mjs';
|
|
2
3
|
import { storefrontClientFactory } from '../../clients/storefront/factory.mjs';
|
|
3
|
-
import { getOfflineSession } from '../helpers/get-offline-session.mjs';
|
|
4
4
|
|
|
5
5
|
function unauthenticatedStorefrontContextFactory(params) {
|
|
6
6
|
return async (shop) => {
|
|
7
|
-
const session = await
|
|
7
|
+
const session = await createOrLoadOfflineSession(shop, params);
|
|
8
8
|
if (!session) {
|
|
9
9
|
throw new SessionNotFoundError(`Could not find a session for shop ${shop} when creating unauthenticated storefront context`);
|
|
10
10
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"factory.mjs","sources":["../../../../../../src/server/unauthenticated/storefront/factory.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;AAUM,SAAU,uCAAuC,CACrD,MAAmB,EAAA;AAEnB,IAAA,OAAO,OAAO,IAAY,KAA+C;QACvE,MAAM,OAAO,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"factory.mjs","sources":["../../../../../../src/server/unauthenticated/storefront/factory.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;AAUM,SAAU,uCAAuC,CACrD,MAAmB,EAAA;AAEnB,IAAA,OAAO,OAAO,IAAY,KAA+C;QACvE,MAAM,OAAO,GAAG,MAAM,0BAA0B,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QAE/D,IAAI,CAAC,OAAO,EAAE;AACZ,YAAA,MAAM,IAAI,oBAAoB,CAC5B,qCAAqC,IAAI,CAAA,iDAAA,CAAmD,CAC7F,CAAC;SACH;QAED,OAAO;YACL,OAAO;YACP,UAAU,EAAE,uBAAuB,CAAC,EAAC,MAAM,EAAE,OAAO,EAAC,CAAC;SACvD,CAAC;AACJ,KAAC,CAAC;AACJ;;;;"}
|
|
@@ -109,9 +109,11 @@ export interface BillingContext<Config extends AppConfigArg> {
|
|
|
109
109
|
* billing: {
|
|
110
110
|
* [MONTHLY_PLAN]: {
|
|
111
111
|
* lineItems: [
|
|
112
|
-
*
|
|
113
|
-
*
|
|
114
|
-
*
|
|
112
|
+
* {
|
|
113
|
+
* amount: 5,
|
|
114
|
+
* currencyCode: 'USD',
|
|
115
|
+
* interval: BillingInterval.Every30Days,
|
|
116
|
+
* }
|
|
115
117
|
* ],
|
|
116
118
|
* },
|
|
117
119
|
* }
|
|
@@ -154,16 +156,20 @@ export interface BillingContext<Config extends AppConfigArg> {
|
|
|
154
156
|
* billing: {
|
|
155
157
|
* [MONTHLY_PLAN]: {
|
|
156
158
|
* lineItems: [
|
|
157
|
-
*
|
|
158
|
-
*
|
|
159
|
-
*
|
|
159
|
+
* {
|
|
160
|
+
* amount: 5,
|
|
161
|
+
* currencyCode: 'USD',
|
|
162
|
+
* interval: BillingInterval.Every30Days,
|
|
163
|
+
* }
|
|
160
164
|
* ],
|
|
161
165
|
* },
|
|
162
166
|
* [ANNUAL_PLAN]: {
|
|
163
167
|
* lineItems: [
|
|
164
|
-
*
|
|
165
|
-
*
|
|
166
|
-
*
|
|
168
|
+
* {
|
|
169
|
+
* amount: 50,
|
|
170
|
+
* currencyCode: 'USD',
|
|
171
|
+
* interval: BillingInterval.Annual,
|
|
172
|
+
* }
|
|
167
173
|
* ],
|
|
168
174
|
* },
|
|
169
175
|
* }
|
|
@@ -209,16 +215,20 @@ export interface BillingContext<Config extends AppConfigArg> {
|
|
|
209
215
|
* billing: {
|
|
210
216
|
* [MONTHLY_PLAN]: {
|
|
211
217
|
* lineItems: [
|
|
212
|
-
*
|
|
213
|
-
*
|
|
214
|
-
*
|
|
218
|
+
* {
|
|
219
|
+
* amount: 5,
|
|
220
|
+
* currencyCode: 'USD',
|
|
221
|
+
* interval: BillingInterval.Every30Days,
|
|
222
|
+
* }
|
|
215
223
|
* ],
|
|
216
224
|
* },
|
|
217
225
|
* [ANNUAL_PLAN]: {
|
|
218
226
|
* lineItems: [
|
|
219
|
-
*
|
|
220
|
-
*
|
|
221
|
-
*
|
|
227
|
+
* {
|
|
228
|
+
* amount: 50,
|
|
229
|
+
* currencyCode: 'USD',
|
|
230
|
+
* interval: BillingInterval.Annual,
|
|
231
|
+
* }
|
|
222
232
|
* ],
|
|
223
233
|
* },
|
|
224
234
|
* }
|
|
@@ -285,16 +295,20 @@ export interface BillingContext<Config extends AppConfigArg> {
|
|
|
285
295
|
* billing: {
|
|
286
296
|
* [MONTHLY_PLAN]: {
|
|
287
297
|
* lineItems: [
|
|
288
|
-
*
|
|
289
|
-
*
|
|
290
|
-
*
|
|
298
|
+
* {
|
|
299
|
+
* amount: 5,
|
|
300
|
+
* currencyCode: 'USD',
|
|
301
|
+
* interval: BillingInterval.Every30Days,
|
|
302
|
+
* }
|
|
291
303
|
* ],
|
|
292
304
|
* },
|
|
293
305
|
* [ANNUAL_PLAN]: {
|
|
294
306
|
* lineItems: [
|
|
295
|
-
*
|
|
296
|
-
*
|
|
297
|
-
*
|
|
307
|
+
* {
|
|
308
|
+
* amount: 50,
|
|
309
|
+
* currencyCode: 'USD',
|
|
310
|
+
* interval: BillingInterval.Annual,
|
|
311
|
+
* }
|
|
298
312
|
* ],
|
|
299
313
|
* },
|
|
300
314
|
* }
|
|
@@ -343,16 +357,20 @@ export interface BillingContext<Config extends AppConfigArg> {
|
|
|
343
357
|
* billing: {
|
|
344
358
|
* [MONTHLY_PLAN]: {
|
|
345
359
|
* lineItems: [
|
|
346
|
-
*
|
|
347
|
-
*
|
|
348
|
-
*
|
|
360
|
+
* {
|
|
361
|
+
* amount: 5,
|
|
362
|
+
* currencyCode: 'USD',
|
|
363
|
+
* interval: BillingInterval.Every30Days,
|
|
364
|
+
* }
|
|
349
365
|
* ],
|
|
350
366
|
* },
|
|
351
367
|
* [ANNUAL_PLAN]: {
|
|
352
368
|
* lineItems: [
|
|
353
|
-
*
|
|
354
|
-
*
|
|
355
|
-
*
|
|
369
|
+
* {
|
|
370
|
+
* amount: 50,
|
|
371
|
+
* currencyCode: 'USD',
|
|
372
|
+
* interval: BillingInterval.Annual,
|
|
373
|
+
* }
|
|
356
374
|
* ],
|
|
357
375
|
* },
|
|
358
376
|
* }
|
|
@@ -404,16 +422,20 @@ export interface BillingContext<Config extends AppConfigArg> {
|
|
|
404
422
|
* billing: {
|
|
405
423
|
* [MONTHLY_PLAN]: {
|
|
406
424
|
* lineItems: [
|
|
407
|
-
*
|
|
408
|
-
*
|
|
409
|
-
*
|
|
425
|
+
* {
|
|
426
|
+
* amount: 5,
|
|
427
|
+
* currencyCode: 'USD',
|
|
428
|
+
* interval: BillingInterval.Every30Days,
|
|
429
|
+
* }
|
|
410
430
|
* ],
|
|
411
431
|
* },
|
|
412
432
|
* [ANNUAL_PLAN]: {
|
|
413
433
|
* lineItems: [
|
|
414
|
-
*
|
|
415
|
-
*
|
|
416
|
-
*
|
|
434
|
+
* {
|
|
435
|
+
* amount: 50,
|
|
436
|
+
* currencyCode: 'USD',
|
|
437
|
+
* interval: BillingInterval.Annual,
|
|
438
|
+
* }
|
|
417
439
|
* ],
|
|
418
440
|
* },
|
|
419
441
|
* }
|
|
@@ -463,9 +485,11 @@ export interface BillingContext<Config extends AppConfigArg> {
|
|
|
463
485
|
* billing: {
|
|
464
486
|
* [USAGE_PLAN]: {
|
|
465
487
|
* lineItems: [
|
|
466
|
-
*
|
|
467
|
-
*
|
|
468
|
-
*
|
|
488
|
+
* {
|
|
489
|
+
* amount: 5,
|
|
490
|
+
* currencyCode: 'USD',
|
|
491
|
+
* interval: BillingInterval.Usage,
|
|
492
|
+
* }
|
|
469
493
|
* ],
|
|
470
494
|
* },
|
|
471
495
|
* }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../../src/server/authenticate/admin/billing/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,kBAAkB,EAClB,0BAA0B,EAC1B,oBAAoB,EACpB,WAAW,EACZ,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAC,cAAc,EAAC,MAAM,uBAAuB,CAAC;AACrD,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,uBAAuB,CAAC;AAExD,MAAM,WAAW,qBA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G;IACH,MAAM,EAAE,OAAO,CAAC;IAIhB,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAIhC,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,cAAc,CAAC,MAAM,SAAS,YAAY;IACzD
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../../src/server/authenticate/admin/billing/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,kBAAkB,EAClB,0BAA0B,EAC1B,oBAAoB,EACpB,WAAW,EACZ,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAC,cAAc,EAAC,MAAM,uBAAuB,CAAC;AACrD,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,uBAAuB,CAAC;AAExD,MAAM,WAAW,qBAAqB,CAAC,MAAM,SAAS,YAAY,CAChE,SAAQ,IAAI,CAAC,kBAAkB,EAAE,SAAS,GAAG,OAAO,GAAG,cAAc,CAAC;IACtE;;OAEG;IACH,KAAK,EAAE,CAAC,MAAM,MAAM,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC;IACnC;;OAEG;IACH,SAAS,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;CAC9C;AAED,MAAM,WAAW,mBAAmB,CAAC,MAAM,SAAS,YAAY,CAC9D,SAAQ,IAAI,CAAC,kBAAkB,EAAE,SAAS,GAAG,OAAO,GAAG,cAAc,CAAC;IACtE;;OAEG;IACH,KAAK,CAAC,EAAE,CAAC,MAAM,MAAM,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC;CACrC;AAED,MAAM,WAAW,qBAAqB,CAAC,MAAM,SAAS,YAAY,CAChE,SAAQ,IAAI,CACV,oBAAoB,CAAC,cAAc,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,EACtD,SAAS,GAAG,MAAM,GAAG,cAAc,CACpC;IACD;;OAEG;IACH,IAAI,EAAE,MAAM,MAAM,CAAC,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA0HG;IACH,OAAO,EAAE,CAAC,OAAO,EAAE,qBAAqB,CAAC,MAAM,CAAC,KAAK,OAAO,CAAC,KAAK,CAAC,CAAC;IAEpE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA+DG;IACH,MAAM,EAAE,CAAC,OAAO,EAAE,oBAAoB,KAAK,OAAO,CAAC,eAAe,CAAC,CAAC;IAEpE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAoDG;IACH,iBAAiB,EAAE,CACjB,OAAO,EAAE,wBAAwB,KAC9B,OAAO,CAAC,WAAW,CAAC,CAAC;CAC3B"}
|
|
@@ -133,6 +133,32 @@ export interface WebhookContextWithSession<Resources extends ShopifyRestResource
|
|
|
133
133
|
* A session with an offline token for the shop.
|
|
134
134
|
*
|
|
135
135
|
* Returned only if there is a session for the shop.
|
|
136
|
+
* Webhook requests can trigger after an app is uninstalled
|
|
137
|
+
* If the app is already uninstalled, the session may be undefined.
|
|
138
|
+
* Therefore, you should check for the session before using it.
|
|
139
|
+
*
|
|
140
|
+
* @example
|
|
141
|
+
* <caption>Protecting against uninstalled apps.</caption>
|
|
142
|
+
* ```ts
|
|
143
|
+
* // /app/routes/webhooks.tsx
|
|
144
|
+
* import type { ActionFunctionArgs } from "@remix-run/node";
|
|
145
|
+
* import { authenticate } from "~/shopify.server";
|
|
146
|
+
|
|
147
|
+
* export const action = async ({ request }: ActionFunctionArgs) => {
|
|
148
|
+
* const { session } = await authenticate.webhook(request);
|
|
149
|
+
*
|
|
150
|
+
* // Webhook requests can trigger after an app is uninstalled
|
|
151
|
+
* // If the app is already uninstalled, the session may be undefined.
|
|
152
|
+
* if (!session) {
|
|
153
|
+
* throw new Response();
|
|
154
|
+
* }
|
|
155
|
+
*
|
|
156
|
+
* // Handle webhook request
|
|
157
|
+
* console.log("Received webhook webhook");
|
|
158
|
+
*
|
|
159
|
+
* return new Response();
|
|
160
|
+
* };
|
|
161
|
+
* ```
|
|
136
162
|
*/
|
|
137
163
|
session: Session;
|
|
138
164
|
/**
|
|
@@ -151,6 +177,12 @@ export interface WebhookContextWithSession<Resources extends ShopifyRestResource
|
|
|
151
177
|
* export async function action({ request }: ActionFunctionArgs) {
|
|
152
178
|
* const { admin } = await authenticate.webhook(request);
|
|
153
179
|
*
|
|
180
|
+
* // Webhook requests can trigger after an app is uninstalled
|
|
181
|
+
* // If the app is already uninstalled, the session may be undefined.
|
|
182
|
+
* if (!session) {
|
|
183
|
+
* throw new Response();
|
|
184
|
+
* }
|
|
185
|
+
*
|
|
154
186
|
* const response = await admin?.graphql(
|
|
155
187
|
* `#graphql
|
|
156
188
|
* mutation populateProduct($input: ProductInput!) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/server/authenticate/webhooks/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAE,oBAAoB,EAAC,MAAM,sBAAsB,CAAC;AAEnE,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,eAAe,CAAC;AAEnD,MAAM,WAAW,uBAAuB;IACtC;;OAEG;IACH,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,UAAU,OAAO,CAAC,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM;IACjD;;;;;;;;;;;;;;;;OAgBG;IACH,UAAU,EAAE,MAAM,CAAC;IAEnB;;;;;;;;;;;;;;;;OAgBG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;;;;;;;;;;;;;;;OAgBG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB;;;;;;;;;;;;;;;;OAgBG;IACH,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAE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AM,CAC7E,SAAQ,OAAO,CAAC,MAAM,CAAC;IACvB,OAAO,EAAE,SAAS,CAAC;IACnB,KAAK,EAAE,SAAS,CAAC;CAClB;AAED,MAAM,WAAW,yBAAyB,CACxC,SAAS,SAAS,oBAAoB,EACtC,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CACjC,SAAQ,OAAO,CAAC,MAAM,CAAC;IACvB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA8BG;IACH,OAAO,EAAE,OAAO,CAAC;IAEjB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAsCG;IACH,KAAK,EAAE,eAAe,CAAC,SAAS,CAAC,CAAC;CACnC;AAED,MAAM,MAAM,cAAc,CACxB,SAAS,SAAS,oBAAoB,EACtC,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,IAE/B,4BAA4B,CAAC,MAAM,CAAC,GACpC,yBAAyB,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;AAEjD,MAAM,MAAM,mBAAmB,CAC7B,SAAS,SAAS,oBAAoB,EACtC,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,IAC/B,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,cAAc,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC,CAAC"}
|
|
@@ -48,27 +48,32 @@ export interface AppConfigArg<Resources extends ShopifyRestResources = ShopifyRe
|
|
|
48
48
|
*/
|
|
49
49
|
useOnlineTokens?: boolean;
|
|
50
50
|
/**
|
|
51
|
-
* The config for the
|
|
51
|
+
* The config for the shop-specific webhooks your app needs.
|
|
52
52
|
*
|
|
53
|
-
*
|
|
53
|
+
* Use this to configure shop-specific webhooks. In many cases defining app-specific webhooks in the `shopify.app.toml` will be sufficient and easier to manage. Please see:
|
|
54
54
|
*
|
|
55
|
-
*
|
|
55
|
+
* {@link https://shopify.dev/docs/apps/build/webhooks/subscribe#app-specific-vs-shop-specific-subscriptions}
|
|
56
|
+
*
|
|
57
|
+
* You should only use this if you need shop-specific webhooks. If you do need shop-specific webhooks this can be in used in conjunction with the afterAuth hook, loaders or processes such as background jobs.
|
|
56
58
|
*
|
|
57
59
|
* @example
|
|
58
|
-
* <caption>Registering
|
|
60
|
+
* <caption>Registering shop-specific webhooks.</caption>
|
|
59
61
|
* ```ts
|
|
60
|
-
* //
|
|
62
|
+
* // app/shopify.server.ts
|
|
61
63
|
* import { DeliveryMethod, shopifyApp } from "@shopify/shopify-app-remix/server";
|
|
62
64
|
*
|
|
63
65
|
* const shopify = shopifyApp({
|
|
64
66
|
* webhooks: {
|
|
65
|
-
*
|
|
67
|
+
* PRODUCTS_CREATE: {
|
|
66
68
|
* deliveryMethod: DeliveryMethod.Http,
|
|
67
|
-
* callbackUrl: "/webhooks",
|
|
69
|
+
* callbackUrl: "/webhooks/products/create",
|
|
68
70
|
* },
|
|
69
71
|
* },
|
|
70
72
|
* hooks: {
|
|
71
73
|
* afterAuth: async ({ session }) => {
|
|
74
|
+
* // Register webhooks for the shop
|
|
75
|
+
* // In this example, every shop will have these webhooks
|
|
76
|
+
* // But you could wrap this in some custom shop specific conditional logic
|
|
72
77
|
* shopify.registerWebhooks({ session });
|
|
73
78
|
* }
|
|
74
79
|
* },
|
|
@@ -76,26 +81,42 @@ export interface AppConfigArg<Resources extends ShopifyRestResources = ShopifyRe
|
|
|
76
81
|
* });
|
|
77
82
|
* export default shopify;
|
|
78
83
|
* export const authenticate = shopify.authenticate;
|
|
84
|
+
* ```
|
|
79
85
|
*
|
|
80
|
-
*
|
|
81
|
-
*
|
|
86
|
+
* @example
|
|
87
|
+
* <caption>Registering app-specific webhooks (Recommended)</caption>
|
|
88
|
+
* ```toml
|
|
89
|
+
* # shopify.app.toml
|
|
90
|
+
* [webhooks]
|
|
91
|
+
* api_version = "2024-07"
|
|
92
|
+
|
|
93
|
+
* [[webhooks.subscriptions]]
|
|
94
|
+
* topics = ["products/create"]
|
|
95
|
+
* uri = "/webhooks/products/create"
|
|
82
96
|
*
|
|
97
|
+
* ```
|
|
98
|
+
*
|
|
99
|
+
* @example
|
|
100
|
+
* <caption>Authenticating a webhook request</caption>
|
|
101
|
+
*
|
|
102
|
+
* ```ts
|
|
103
|
+
* // /app/routes/webhooks.ts
|
|
104
|
+
* import { ActionFunctionArgs } from "@remix-run/node";
|
|
83
105
|
* import { authenticate } from "../shopify.server";
|
|
84
106
|
* import db from "../db.server";
|
|
85
107
|
*
|
|
86
108
|
* export const action = async ({ request }: ActionFunctionArgs) => {
|
|
87
|
-
* const { topic, shop } = await authenticate.webhook(request);
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
*
|
|
92
|
-
*
|
|
93
|
-
* case "CUSTOMERS_DATA_REQUEST":
|
|
94
|
-
* case "CUSTOMERS_REDACT":
|
|
95
|
-
* case "SHOP_REDACT":
|
|
96
|
-
* default:
|
|
97
|
-
* throw new Response("Unhandled webhook topic", { status: 404 });
|
|
109
|
+
* const { topic, shop, session, payload } = await authenticate.webhook(request);
|
|
110
|
+
*
|
|
111
|
+
* // Webhook requests can trigger after an app is uninstalled
|
|
112
|
+
* // If the app is already uninstalled, the session may be undefined.
|
|
113
|
+
* if (!session) {
|
|
114
|
+
* throw new Response();
|
|
98
115
|
* }
|
|
116
|
+
*
|
|
117
|
+
* // Handle the webhook
|
|
118
|
+
* console.log(`${TOPIC} webhook received with`, JSON.stringify(payload))
|
|
119
|
+
*
|
|
99
120
|
* throw new Response();
|
|
100
121
|
* };
|
|
101
122
|
* ```
|
|
@@ -228,7 +249,7 @@ interface HooksConfig {
|
|
|
228
249
|
* @param context.admin - An object with access to the Shopify Admin API's.
|
|
229
250
|
*
|
|
230
251
|
* @example
|
|
231
|
-
* <caption>
|
|
252
|
+
* <caption>Seeding data when a merchant installs your app.</caption>
|
|
232
253
|
* ```ts
|
|
233
254
|
* import { DeliveryMethod, shopifyApp } from "@shopify/shopify-app-remix/server";
|
|
234
255
|
* import { seedStoreData } from "~/db/seeds"
|
|
@@ -236,16 +257,9 @@ interface HooksConfig {
|
|
|
236
257
|
* const shopify = shopifyApp({
|
|
237
258
|
* hooks: {
|
|
238
259
|
* afterAuth: async ({ session }) => {
|
|
239
|
-
* shopify.registerWebhooks({ session });
|
|
240
260
|
* seedStoreData({session})
|
|
241
261
|
* }
|
|
242
262
|
* },
|
|
243
|
-
* webhooks: {
|
|
244
|
-
* APP_UNINSTALLED: {
|
|
245
|
-
* deliveryMethod: DeliveryMethod.Http,
|
|
246
|
-
* callbackUrl: "/webhooks",
|
|
247
|
-
* },
|
|
248
|
-
* },
|
|
249
263
|
* // ...etc
|
|
250
264
|
* });
|
|
251
265
|
* ```
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-types.d.ts","sourceRoot":"","sources":["../../../src/server/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,EACV,cAAc,EACd,iBAAiB,EACjB,WAAW,EACZ,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,SAAS,CAAC;AAC7C,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAC,wBAAwB,EAAC,MAAM,mDAAmD,CAAC;AAE3F,MAAM,WAAW,YAAY,CAC3B,SAAS,SAAS,oBAAoB,GAAG,oBAAoB,EAC7D,OAAO,SAAS,cAAc,GAAG,cAAc,EAC/C,MAAM,SAAS,iBAAiB,GAAG,iBAAiB,CACpD,SAAQ,IAAI,CACV,YAAY,CAAC,SAAS,EAAE,cAAc,CAAC,MAAM,CAAC,CAAC,EAC7C,UAAU,GACV,YAAY,GACZ,eAAe,GACf,YAAY,GACZ,kB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,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"}
|
|
@@ -164,50 +164,65 @@ interface Authenticate<Config extends AppConfigArg> {
|
|
|
164
164
|
* <caption>Authenticating a webhook request</caption>
|
|
165
165
|
*
|
|
166
166
|
* ```ts
|
|
167
|
-
* //
|
|
167
|
+
* // app/routes/webhooks.ts
|
|
168
|
+
* import { ActionFunctionArgs } from "@remix-run/node";
|
|
169
|
+
* import { authenticate } from "../shopify.server";
|
|
170
|
+
* import db from "../db.server";
|
|
171
|
+
*
|
|
172
|
+
* export const action = async ({ request }: ActionFunctionArgs) => {
|
|
173
|
+
* const { topic, shop, session, payload } = await authenticate.webhook(request);
|
|
174
|
+
*
|
|
175
|
+
* // Webhook requests can trigger after an app is uninstalled
|
|
176
|
+
* // If the app is already uninstalled, the session may be undefined.
|
|
177
|
+
* if (!session) {
|
|
178
|
+
* throw new Response();
|
|
179
|
+
* }
|
|
180
|
+
*
|
|
181
|
+
* // Handle the webhook
|
|
182
|
+
* console.log(`${TOPIC} webhook received with payload:`, JSON.stringify(payload))
|
|
183
|
+
*
|
|
184
|
+
* throw new Response();
|
|
185
|
+
* };
|
|
186
|
+
* ```
|
|
187
|
+
*
|
|
188
|
+
* @example
|
|
189
|
+
* <caption>Registering app-specific webhooks (Recommended)</caption>
|
|
190
|
+
* ```toml
|
|
191
|
+
* # shopify.app.toml
|
|
192
|
+
* [webhooks]
|
|
193
|
+
* api_version = "2024-07"
|
|
194
|
+
|
|
195
|
+
* [[webhooks.subscriptions]]
|
|
196
|
+
* topics = ["products/create"]
|
|
197
|
+
* uri = "/webhooks/products/create"
|
|
198
|
+
*
|
|
199
|
+
* ```
|
|
200
|
+
*
|
|
201
|
+
* @example
|
|
202
|
+
* <caption>Registering shop-specific webhooks.</caption>
|
|
203
|
+
* <description>In many cases you won't need this. Please see: [https://shopify.dev/docs/apps/build/webhooks/subscribe#app-specific-vs-shop-specific-subscriptions](https://shopify.dev/docs/apps/build/webhooks/subscribe#app-specific-vs-shop-specific-subscriptions)
|
|
204
|
+
* </description>
|
|
205
|
+
* ```ts
|
|
206
|
+
* // app/shopify.server.ts
|
|
168
207
|
* import { DeliveryMethod, shopifyApp } from "@shopify/shopify-app-remix/server";
|
|
169
208
|
*
|
|
170
209
|
* const shopify = shopifyApp({
|
|
171
210
|
* webhooks: {
|
|
172
|
-
*
|
|
211
|
+
* PRODUCTS_CREATE: {
|
|
173
212
|
* deliveryMethod: DeliveryMethod.Http,
|
|
174
|
-
* callbackUrl: "/webhooks",
|
|
213
|
+
* callbackUrl: "/webhooks/products/create",
|
|
175
214
|
* },
|
|
176
215
|
* },
|
|
177
216
|
* hooks: {
|
|
178
217
|
* afterAuth: async ({ session }) => {
|
|
218
|
+
* // Register webhooks for the shop
|
|
219
|
+
* // In this example, every shop will have these webhooks
|
|
220
|
+
* // You could wrap this in some custom shop specific conditional logic if needed
|
|
179
221
|
* shopify.registerWebhooks({ session });
|
|
180
222
|
* },
|
|
181
223
|
* },
|
|
182
224
|
* // ...etc
|
|
183
225
|
* });
|
|
184
|
-
* export default shopify;
|
|
185
|
-
* export const authenticate = shopify.authenticate;
|
|
186
|
-
* ```
|
|
187
|
-
* ```ts
|
|
188
|
-
* // /app/routes/webhooks.ts
|
|
189
|
-
* import { ActionFunctionArgs } from "@remix-run/node";
|
|
190
|
-
* import { authenticate } from "../shopify.server";
|
|
191
|
-
* import db from "../db.server";
|
|
192
|
-
*
|
|
193
|
-
* export const action = async ({ request }: ActionFunctionArgs) => {
|
|
194
|
-
* const { topic, shop, session } = await authenticate.webhook(request);
|
|
195
|
-
*
|
|
196
|
-
* switch (topic) {
|
|
197
|
-
* case "APP_UNINSTALLED":
|
|
198
|
-
* if (session) {
|
|
199
|
-
* await db.session.deleteMany({ where: { shop } });
|
|
200
|
-
* }
|
|
201
|
-
* break;
|
|
202
|
-
* case "CUSTOMERS_DATA_REQUEST":
|
|
203
|
-
* case "CUSTOMERS_REDACT":
|
|
204
|
-
* case "SHOP_REDACT":
|
|
205
|
-
* default:
|
|
206
|
-
* throw new Response("Unhandled webhook topic", { status: 404 });
|
|
207
|
-
* }
|
|
208
|
-
*
|
|
209
|
-
* throw new Response();
|
|
210
|
-
* };
|
|
211
226
|
* ```
|
|
212
227
|
*/
|
|
213
228
|
webhook: AuthenticateWebhook<RestResourcesType<Config>, string>;
|
|
@@ -280,25 +295,34 @@ export interface ShopifyAppBase<Config extends AppConfigArg> {
|
|
|
280
295
|
*/
|
|
281
296
|
addDocumentResponseHeaders: AddDocumentResponseHeaders;
|
|
282
297
|
/**
|
|
283
|
-
* Register webhook
|
|
298
|
+
* Register shop-specific webhook subscriptions using the Admin GraphQL API.
|
|
299
|
+
*
|
|
300
|
+
* In many cases defining app-specific webhooks in the `shopify.app.toml` will be sufficient and easier to manage. Please see:
|
|
301
|
+
*
|
|
302
|
+
* {@link https://shopify.dev/docs/apps/build/webhooks/subscribe#app-specific-vs-shop-specific-subscriptions}
|
|
303
|
+
*
|
|
304
|
+
* You should only use this if you need shop-specific webhooks.
|
|
284
305
|
*
|
|
285
306
|
* @example
|
|
286
|
-
* <caption>Registering webhooks after install</caption>
|
|
287
|
-
* <description>Trigger the registration to create the webhook subscriptions after a merchant installs your app using the `afterAuth` hook. Learn more about [subscribing to webhooks.](/docs/api/shopify-app-remix/
|
|
307
|
+
* <caption>Registering shop-specific webhooks after install</caption>
|
|
308
|
+
* <description>Trigger the registration to create the shop-specific webhook subscriptions after a merchant installs your app using the `afterAuth` hook. Learn more about [subscribing to webhooks.](https://shopify.dev/docs/api/shopify-app-remix/v3/guide-webhooks)</description>
|
|
288
309
|
* ```ts
|
|
289
|
-
* //
|
|
310
|
+
* // app/shopify.server.ts
|
|
290
311
|
* import { DeliveryMethod, shopifyApp } from "@shopify/shopify-app-remix/server";
|
|
291
312
|
*
|
|
292
313
|
* const shopify = shopifyApp({
|
|
314
|
+
* webhooks: {
|
|
315
|
+
* PRODUCTS_CREATE: {
|
|
316
|
+
* deliveryMethod: DeliveryMethod.Http,
|
|
317
|
+
* callbackUrl: "/webhooks/products/create",
|
|
318
|
+
* },
|
|
319
|
+
* },
|
|
293
320
|
* hooks: {
|
|
294
321
|
* afterAuth: async ({ session }) => {
|
|
322
|
+
* // Register webhooks for the shop
|
|
323
|
+
* // In this example, every shop will have these webhooks
|
|
324
|
+
* // You could wrap this in some custom shop specific conditional logic if needed
|
|
295
325
|
* shopify.registerWebhooks({ session });
|
|
296
|
-
* }
|
|
297
|
-
* },
|
|
298
|
-
* webhooks: {
|
|
299
|
-
* APP_UNINSTALLED: {
|
|
300
|
-
* deliveryMethod: DeliveryMethod.Http,
|
|
301
|
-
* callbackUrl: "/webhooks",
|
|
302
326
|
* },
|
|
303
327
|
* },
|
|
304
328
|
* // ...etc
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/server/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,OAAO,EACP,oBAAoB,EACrB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAC,cAAc,EAAC,MAAM,sCAAsC,CAAC;AAEpE,OAAO,KAAK,EAAC,SAAS,EAAE,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAC5D,OAAO,KAAK,EACV,mBAAmB,EACnB,uBAAuB,EACxB,MAAM,+BAA+B,CAAC;AACvC,OAAO,KAAK,EAAC,kBAAkB,EAAC,MAAM,6BAA6B,CAAC;AACpE,OAAO,KAAK,EAAC,iBAAiB,EAAC,MAAM,4BAA4B,CAAC;AAClE,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,yBAAyB,CAAC;AAC7D,OAAO,KAAK,EAAC,gB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AM,CAAC,CAAC;AAC3E,MAAM,MAAM,iBAAiB,CAAC,MAAM,SAAS,YAAY,IACvD,cAAc,CAAC,MAAM,CAAC,GAAG,eAAe,CAAC;AAC3C,MAAM,MAAM,WAAW,CAAC,MAAM,SAAS,YAAY,IAAI,cAAc,CAAC,MAAM,CAAC,GAC3E,eAAe,CAAC;AAElB,KAAK,qBAAqB,CAAC,MAAM,SAAS,YAAY,EAAE,IAAI,IAAI,IAAI,GAAG;IACrE,cAAc,EAAE,kBAAkB,CAAC,MAAM,CAAC,CAAC;CAC5C,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,UAAU,CAAC,MAAM,SAAS,YAAY,IAChD,MAAM,CAAC,cAAc,CAAC,SAAS,eAAe,CAAC,YAAY,GACvD,QAAQ,CAAC,MAAM,CAAC,GAChB,MAAM,CAAC,cAAc,CAAC,SAAS,eAAe,CAAC,cAAc,GAC3D,qBAAqB,CAAC,MAAM,EAAE,iBAAiB,CAAC,MAAM,CAAC,CAAC,GACxD,MAAM,CAAC,cAAc,CAAC,SAAS,eAAe,CAAC,QAAQ,GACrD,qBAAqB,CAAC,MAAM,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC,GAClD,qBAAqB,CAAC,MAAM,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../../../../src/server/unauthenticated/admin/factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,oBAAoB,EAAC,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../../../../src/server/unauthenticated/admin/factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,oBAAoB,EAAC,MAAM,sBAAsB,CAAC;AAI1D,OAAO,EAAC,WAAW,EAAC,MAAM,aAAa,CAAC;AAGxC,OAAO,EAAC,2BAA2B,EAAC,MAAM,SAAS,CAAC;AAEpD,wBAAgB,kCAAkC,CAChD,SAAS,SAAS,oBAAoB,EACtC,MAAM,EAAE,WAAW,UAEX,MAAM,KACX,OAAO,CAAC,2BAA2B,CAAC,SAAS,CAAC,CAAC,CAcnD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../../../../src/server/unauthenticated/storefront/factory.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../../../../src/server/unauthenticated/storefront/factory.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,WAAW,EAAC,MAAM,aAAa,CAAC;AAGxC,OAAO,EAEL,mCAAmC,EACpC,MAAM,SAAS,CAAC;AAEjB,wBAAgB,uCAAuC,CACrD,MAAM,EAAE,WAAW,GAClB,mCAAmC,CAerC"}
|