@shopify/shopify-app-remix 1.3.0 → 2.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.
Files changed (53) hide show
  1. package/README.md +32 -281
  2. package/build/cjs/server/authenticate/public/factory.js +1 -1
  3. package/build/cjs/server/authenticate/webhooks/authenticate.js +38 -20
  4. package/build/cjs/server/shopify-app.js +4 -4
  5. package/build/cjs/server/version.js +1 -1
  6. package/build/ts/server/__test-helpers/test-config.d.ts +9 -4
  7. package/build/ts/server/__test-helpers/test-config.d.ts.map +1 -1
  8. package/build/ts/server/__test-helpers/test-config.js +2 -2
  9. package/build/ts/server/__test-helpers/test-config.js.map +1 -1
  10. package/build/ts/server/authenticate/admin/billing/types.d.ts +8 -8
  11. package/build/ts/server/authenticate/admin/types.d.ts +12 -12
  12. package/build/ts/server/authenticate/public/appProxy/types.d.ts +2 -2
  13. package/build/ts/server/authenticate/public/checkout/types.d.ts +4 -4
  14. package/build/ts/server/authenticate/public/factory.js +1 -1
  15. package/build/ts/server/authenticate/public/types.d.ts +4 -4
  16. package/build/ts/server/authenticate/webhooks/authenticate.d.ts +3 -2
  17. package/build/ts/server/authenticate/webhooks/authenticate.d.ts.map +1 -1
  18. package/build/ts/server/authenticate/webhooks/authenticate.js +31 -19
  19. package/build/ts/server/authenticate/webhooks/authenticate.js.map +1 -1
  20. package/build/ts/server/authenticate/webhooks/authenticate.webhooks.doc.d.ts.map +1 -1
  21. package/build/ts/server/authenticate/webhooks/authenticate.webhooks.doc.js +9 -2
  22. package/build/ts/server/authenticate/webhooks/authenticate.webhooks.doc.js.map +1 -1
  23. package/build/ts/server/authenticate/webhooks/types.d.ts +70 -9
  24. package/build/ts/server/authenticate/webhooks/types.d.ts.map +1 -1
  25. package/build/ts/server/clients/admin/types.d.ts +7 -7
  26. package/build/ts/server/clients/storefront/types.d.ts +2 -2
  27. package/build/ts/server/config-types.d.ts +13 -4
  28. package/build/ts/server/config-types.d.ts.map +1 -1
  29. package/build/ts/server/future/flags.d.ts +11 -0
  30. package/build/ts/server/future/flags.d.ts.map +1 -0
  31. package/build/ts/server/future/flags.js +3 -0
  32. package/build/ts/server/future/flags.js.map +1 -0
  33. package/build/ts/server/shopify-app.d.ts.map +1 -1
  34. package/build/ts/server/shopify-app.doc.d.ts.map +1 -1
  35. package/build/ts/server/shopify-app.doc.js +6 -0
  36. package/build/ts/server/shopify-app.doc.js.map +1 -1
  37. package/build/ts/server/shopify-app.js +3 -4
  38. package/build/ts/server/shopify-app.js.map +1 -1
  39. package/build/ts/server/types.d.ts +13 -13
  40. package/build/ts/server/types.d.ts.map +1 -1
  41. package/build/ts/server/unauthenticated/admin/types.d.ts +2 -2
  42. package/build/ts/server/unauthenticated/helpers/get-offline-session.d.ts +1 -1
  43. package/build/ts/server/unauthenticated/helpers/get-offline-session.d.ts.map +1 -1
  44. package/build/ts/server/unauthenticated/helpers/get-offline-session.js.map +1 -1
  45. package/build/ts/server/unauthenticated/storefront/factory.d.ts +1 -1
  46. package/build/ts/server/unauthenticated/storefront/factory.d.ts.map +1 -1
  47. package/build/ts/server/unauthenticated/storefront/factory.js.map +1 -1
  48. package/build/ts/server/unauthenticated/storefront/types.d.ts +2 -2
  49. package/build/ts/server/unauthenticated/types.d.ts +4 -4
  50. package/build/ts/server/version.d.ts +1 -1
  51. package/build/ts/server/version.js +1 -1
  52. package/package.json +6 -6
  53. package/build/tsconfig.tsbuildinfo +0 -1
@@ -27,11 +27,11 @@ interface AdminContextInternal<Config extends AppConfigArg, Resources extends Sh
27
27
  * ```
28
28
  * ```ts
29
29
  * // /app/routes/**\/*.ts
30
- * import { LoaderArgs, json } from "@remix-run/node";
30
+ * import { LoaderFunctionArgs, json } from "@remix-run/node";
31
31
  * import { authenticate } from "../shopify.server";
32
32
  * import { getMyAppData } from "~/db/model.server";
33
33
  *
34
- * export const loader = async ({ request }: LoaderArgs) => {
34
+ * export const loader = async ({ request }: LoaderFunctionArgs) => {
35
35
  * const { session } = await authenticate.admin(request);
36
36
  * return json(await getMyAppData({shop: session.shop));
37
37
  * };
@@ -53,11 +53,11 @@ interface AdminContextInternal<Config extends AppConfigArg, Resources extends Sh
53
53
  * ```
54
54
  * ```ts
55
55
  * // /app/routes/**\/*.ts
56
- * import { LoaderArgs, json } from "@remix-run/node";
56
+ * import { LoaderFunctionArgs, json } from "@remix-run/node";
57
57
  * import { authenticate } from "../shopify.server";
58
58
  * import { getMyAppData } from "~/db/model.server";
59
59
  *
60
- * export const loader = async ({ request }: LoaderArgs) => {
60
+ * export const loader = async ({ request }: LoaderFunctionArgs) => {
61
61
  * const { session } = await authenticate.admin(request);
62
62
  * return json(await getMyAppData({user: session.onlineAccessInfo!.id}));
63
63
  * };
@@ -82,11 +82,11 @@ interface AdminContextInternal<Config extends AppConfigArg, Resources extends Sh
82
82
  * <description>Use the `cors` helper to ensure your app can respond to requests from admin extensions.</description>
83
83
  * ```ts
84
84
  * // /app/routes/admin/my-route.ts
85
- * import { LoaderArgs, json } from "@remix-run/node";
85
+ * import { LoaderFunctionArgs, json } from "@remix-run/node";
86
86
  * import { authenticate } from "../shopify.server";
87
87
  * import { getMyAppData } from "~/db/model.server";
88
88
  *
89
- * export const loader = async ({ request }: LoaderArgs) => {
89
+ * export const loader = async ({ request }: LoaderFunctionArgs) => {
90
90
  * const { session, cors } = await authenticate.admin(request);
91
91
  * return cors(json(await getMyAppData({user: session.onlineAccessInfo!.id})));
92
92
  * };
@@ -118,11 +118,11 @@ export interface EmbeddedAdminContext<Config extends AppConfigArg, Resources ext
118
118
  * ```
119
119
  * ```ts
120
120
  * // /app/routes/**\/*.ts
121
- * import { LoaderArgs, json } from "@remix-run/node";
121
+ * import { LoaderFunctionArgs, json } from "@remix-run/node";
122
122
  * import { authenticate } from "../shopify.server";
123
123
  * import { getMyAppData } from "~/db/model.server";
124
124
  *
125
- * export const loader = async ({ request }: LoaderArgs) => {
125
+ * export const loader = async ({ request }: LoaderFunctionArgs) => {
126
126
  * const { sessionToken } = await authenticate.public.checkout(
127
127
  * request
128
128
  * );
@@ -142,10 +142,10 @@ export interface EmbeddedAdminContext<Config extends AppConfigArg, Resources ext
142
142
  * <description>Use the `redirect` helper to safely redirect between pages.</description>
143
143
  * ```ts
144
144
  * // /app/routes/admin/my-route.ts
145
- * import { LoaderArgs, json } from "@remix-run/node";
145
+ * import { LoaderFunctionArgs, json } from "@remix-run/node";
146
146
  * import { authenticate } from "../shopify.server";
147
147
  *
148
- * export const loader = async ({ request }: LoaderArgs) => {
148
+ * export const loader = async ({ request }: LoaderFunctionArgs) => {
149
149
  * const { session, redirect } = await authenticate.admin(request);
150
150
  * return redirect("/");
151
151
  * };
@@ -156,10 +156,10 @@ export interface EmbeddedAdminContext<Config extends AppConfigArg, Resources ext
156
156
  * <description>Pass in a `target` option of `_top` or `_parent` to go to an external URL.</description>
157
157
  * ```ts
158
158
  * // /app/routes/admin/my-route.ts
159
- * import { LoaderArgs, json } from "@remix-run/node";
159
+ * import { LoaderFunctionArgs, json } from "@remix-run/node";
160
160
  * import { authenticate } from "../shopify.server";
161
161
  *
162
- * export const loader = async ({ request }: LoaderArgs) => {
162
+ * export const loader = async ({ request }: LoaderFunctionArgs) => {
163
163
  * const { session, redirect } = await authenticate.admin(request);
164
164
  * return redirect("/", { target: '_parent' });
165
165
  * };
@@ -79,7 +79,7 @@ export interface AppProxyContextWithSession<Resources extends ShopifyRestResourc
79
79
  * import { json } from "@remix-run/node";
80
80
  * import { authenticate } from "../shopify.server";
81
81
  *
82
- * export async function action({ request }: ActionArgs) {
82
+ * export async function action({ request }: ActionFunctionArgs) {
83
83
  * const { admin } = await authenticate.public.appProxy(request);
84
84
  *
85
85
  * const response = await admin.graphql(
@@ -111,7 +111,7 @@ export interface AppProxyContextWithSession<Resources extends ShopifyRestResourc
111
111
  * import { json } from "@remix-run/node";
112
112
  * import { authenticate } from "../shopify.server";
113
113
  *
114
- * export async function action({ request }: ActionArgs) {
114
+ * export async function action({ request }: ActionFunctionArgs) {
115
115
  * const { admin } = await authenticate.public.appProxy(request);
116
116
  *
117
117
  * const response = await storefront.graphql(`{blogs(first: 10) { edges { node { id } } } }`);
@@ -18,11 +18,11 @@ export interface CheckoutContext {
18
18
  * <description>Get store-specific data using the `sessionToken` object.</description>
19
19
  * ```ts
20
20
  * // app/routes/public/my-route.ts
21
- * import { LoaderArgs, json } from "@remix-run/node";
21
+ * import { LoaderFunctionArgs, json } from "@remix-run/node";
22
22
  * import { authenticate } from "../shopify.server";
23
23
  * import { getMyAppData } from "~/db/model.server";
24
24
  *
25
- * export const loader = async ({ request }: LoaderArgs) => {
25
+ * export const loader = async ({ request }: LoaderFunctionArgs) => {
26
26
  * const { sessionToken } = await authenticate.public.checkout(
27
27
  * request
28
28
  * );
@@ -39,11 +39,11 @@ export interface CheckoutContext {
39
39
  * <description>Use the `cors` helper to ensure your app can respond to checkout extension requests.</description>
40
40
  * ```ts
41
41
  * // app/routes/public/my-route.ts
42
- * import { LoaderArgs, json } from "@remix-run/node";
42
+ * import { LoaderFunctionArgs, json } from "@remix-run/node";
43
43
  * import { authenticate } from "../shopify.server";
44
44
  * import { getMyAppData } from "~/db/model.server";
45
45
  *
46
- * export const loader = async ({ request }: LoaderArgs) => {
46
+ * export const loader = async ({ request }: LoaderFunctionArgs) => {
47
47
  * const { sessionToken, cors } = await authenticate.public.checkout(
48
48
  * request,
49
49
  * { corsHeaders: ["X-My-Custom-Header"] }
@@ -7,7 +7,7 @@ function authenticatePublicFactory(params) {
7
7
  var logger = params.logger;
8
8
  var authenticateCheckout = (0, authenticate_1.authenticateCheckoutFactory)(params);
9
9
  var authenticatePublic = function (request, options) {
10
- logger.deprecated('2.0.0', 'authenticate.public() will be deprecated in v2. Use authenticate.public.checkout() instead.');
10
+ logger.deprecated('3.0.0', 'authenticate.public() will be deprecated in v3. Use authenticate.public.checkout() instead.');
11
11
  return authenticateCheckout(request, options);
12
12
  };
13
13
  authenticatePublic.checkout = authenticateCheckout;
@@ -8,10 +8,10 @@ interface AuthenticatePublicObject {
8
8
  * <caption>Authenticating a checkout extension request</caption>
9
9
  * ```ts
10
10
  * // /app/routes/public/widgets.ts
11
- * import { LoaderArgs, json } from "@remix-run/node";
11
+ * import { LoaderFunctionArgs, json } from "@remix-run/node";
12
12
  * import { authenticate } from "../shopify.server";
13
13
  *
14
- * export const loader = async ({ request }: LoaderArgs) => {
14
+ * export const loader = async ({ request }: LoaderFunctionArgs) => {
15
15
  * const { sessionToken, cors } = await authenticate.public.checkout(
16
16
  * request,
17
17
  * );
@@ -27,10 +27,10 @@ interface AuthenticatePublicObject {
27
27
  * <caption>Authenticating an app proxy request</caption>
28
28
  * ```ts
29
29
  * // /app/routes/public/widgets.ts
30
- * import { LoaderArgs, json } from "@remix-run/node";
30
+ * import { LoaderFunctionArgs, json } from "@remix-run/node";
31
31
  * import { authenticate } from "../shopify.server";
32
32
  *
33
- * export const loader = async ({ request }: LoaderArgs) => {
33
+ * export const loader = async ({ request }: LoaderFunctionArgs) => {
34
34
  * await authenticate.public.appProxy(
35
35
  * request,
36
36
  * );
@@ -1,5 +1,6 @@
1
1
  import { ShopifyRestResources } from '@shopify/shopify-api';
2
2
  import type { BasicParams, MandatoryTopics } from '../../types';
3
- import type { WebhookContext, WebhookContextWithSession } from './types';
4
- export declare function authenticateWebhookFactory<Resources extends ShopifyRestResources, Topics extends string | number | symbol | MandatoryTopics>({ api, config, logger }: BasicParams): (request: Request) => Promise<WebhookContext<Topics> | WebhookContextWithSession<Topics, Resources>>;
3
+ import { FutureFlagOptions } from '../../future/flags';
4
+ import type { AuthenticateWebhook } from './types';
5
+ export declare function authenticateWebhookFactory<Future extends FutureFlagOptions, Resources extends ShopifyRestResources, Topics extends string | number | symbol | MandatoryTopics>(params: BasicParams): AuthenticateWebhook<Future, Resources, Topics>;
5
6
  //# sourceMappingURL=authenticate.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"authenticate.d.ts","sourceRoot":"","sources":["../../../../../src/server/authenticate/webhooks/authenticate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,oBAAoB,EAAC,MAAM,sBAAsB,CAAC;AAEtE,OAAO,KAAK,EAAC,WAAW,EAAE,eAAe,EAAC,MAAM,aAAa,CAAC;AAE9D,OAAO,KAAK,EAAC,cAAc,EAAE,yBAAyB,EAAC,MAAM,SAAS,CAAC;AAEvE,wBAAgB,0BAA0B,CACxC,SAAS,SAAS,oBAAoB,EACtC,MAAM,SAAS,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,eAAe,EACzD,EAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAC,EAAE,WAAW,aAEvB,OAAO,KACf,QACD,eAAe,MAAM,CAAC,GAAG,0BAA0B,MAAM,EAAE,SAAS,CAAC,CACtE,CA+DF"}
1
+ {"version":3,"file":"authenticate.d.ts","sourceRoot":"","sources":["../../../../../src/server/authenticate/webhooks/authenticate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,oBAAoB,EAAC,MAAM,sBAAsB,CAAC;AAEtE,OAAO,KAAK,EAAC,WAAW,EAAE,eAAe,EAAC,MAAM,aAAa,CAAC;AAG9D,OAAO,EAAC,iBAAiB,EAAC,MAAM,oBAAoB,CAAC;AAErD,OAAO,KAAK,EACV,mBAAmB,EAKpB,MAAM,SAAS,CAAC;AAEjB,wBAAgB,0BAA0B,CACxC,MAAM,SAAS,iBAAiB,EAChC,SAAS,SAAS,oBAAoB,EACtC,MAAM,SAAS,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,eAAe,EACzD,MAAM,EAAE,WAAW,GAAG,mBAAmB,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,CAAC,CAgFrE"}
@@ -2,11 +2,13 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.authenticateWebhookFactory = void 0;
4
4
  var tslib_1 = require("tslib");
5
- function authenticateWebhookFactory(_a) {
6
- var api = _a.api, config = _a.config, logger = _a.logger;
5
+ var clients_1 = require("../../clients");
6
+ var helpers_1 = require("../admin/helpers");
7
+ function authenticateWebhookFactory(params) {
8
+ var api = params.api, config = params.config, logger = params.logger;
7
9
  return function authenticate(request) {
8
10
  return tslib_1.__awaiter(this, void 0, void 0, function () {
9
- var rawBody, check, sessionId, session, webhookContext, restClient, graphqlClient;
11
+ var rawBody, check, sessionId, session, webhookContext, admin, restClient_1, graphqlClient;
10
12
  return tslib_1.__generator(this, function (_a) {
11
13
  switch (_a.label) {
12
14
  case 0:
@@ -46,22 +48,32 @@ function authenticateWebhookFactory(_a) {
46
48
  if (!session) {
47
49
  return [2 /*return*/, webhookContext];
48
50
  }
49
- restClient = new api.clients.Rest({
50
- session: session,
51
- apiVersion: check.apiVersion,
52
- });
53
- graphqlClient = new api.clients.Graphql({
54
- session: session,
55
- apiVersion: check.apiVersion,
56
- });
57
- Object.entries(api.rest).forEach(function (_a) {
58
- var _b = tslib_1.__read(_a, 2), name = _b[0], resource = _b[1];
59
- Reflect.set(restClient, name, resource);
60
- });
61
- return [2 /*return*/, tslib_1.__assign(tslib_1.__assign({}, webhookContext), { session: session, admin: {
62
- rest: restClient,
63
- graphql: graphqlClient,
64
- } })];
51
+ if (config.future.v3_webhookAdminContext) {
52
+ admin = (0, clients_1.adminClientFactory)({
53
+ params: params,
54
+ session: session,
55
+ handleClientError: (0, helpers_1.handleClientErrorFactory)({ request: request }),
56
+ });
57
+ }
58
+ else {
59
+ restClient_1 = new api.clients.Rest({
60
+ session: session,
61
+ apiVersion: check.apiVersion,
62
+ });
63
+ graphqlClient = new api.clients.Graphql({
64
+ session: session,
65
+ apiVersion: check.apiVersion,
66
+ });
67
+ Object.entries(api.rest).forEach(function (_a) {
68
+ var _b = tslib_1.__read(_a, 2), name = _b[0], resource = _b[1];
69
+ Reflect.set(restClient_1, name, resource);
70
+ });
71
+ admin = {
72
+ rest: restClient_1,
73
+ graphql: graphqlClient,
74
+ };
75
+ }
76
+ return [2 /*return*/, tslib_1.__assign(tslib_1.__assign({}, webhookContext), { session: session, admin: admin })];
65
77
  }
66
78
  });
67
79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O,CAAC;4BAC5B,OAAO,EAAE,SAAS;4BAClB,KAAK,EAAE,SAAS;yBACjB,CAAC;wBAEF,IAAI,CAAC,OAAO,EAAE;4BACZ,sBAAO,cAAc,EAAC;yBACvB;wBAKD,IAAI,MAAM,CAAC,MAAM,CAAC,sBAAsB,EAAE;4BACxC,KAAK,GAAG,IAAA,4BAAkB,EAAY;gCACpC,MAAM,QAAA;gCACN,OAAO,SAAA;gCACP,iBAAiB,EAAE,IAAA,kCAAwB,EAAC,EAAC,OAAO,SAAA,EAAC,CAAC;6BACvD,CAAC,CAAC;yBACJ;6BAAM;4BACC,eAAa,IAAI,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC;gCACtC,OAAO,SAAA;gCACP,UAAU,EAAE,KAAK,CAAC,UAAwB;6BAC3C,CAAC,CAAC;4BACG,aAAa,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC;gCAC5C,OAAO,SAAA;gCACP,UAAU,EAAE,KAAK,CAAC,UAAwB;6BAC3C,CAAC,CAAC;4BAEH,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,UAAC,EAAgB;oCAAhB,KAAA,qBAAgB,EAAf,IAAI,QAAA,EAAE,QAAQ,QAAA;gCAC/C,OAAO,CAAC,GAAG,CAAC,YAAU,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC;4BAC1C,CAAC,CAAC,CAAC;4BAEH,KAAK,GAAG;gCACN,IAAI,EAAE,YAA2C;gCACjD,OAAO,EAAE,aAAa;6BACvB,CAAC;yBACH;wBAED,4DACK,cAAc,KACjB,OAAO,SAAA,EACP,KAAK,EAAE,KAA+C,KACtD;;;;KACH,CAAC;AACJ,CAAC;AApFD,gEAoFC"}
@@ -1 +1 @@
1
- {"version":3,"file":"authenticate.webhooks.doc.d.ts","sourceRoot":"","sources":["../../../../../src/server/authenticate/webhooks/authenticate.webhooks.doc.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,6BAA6B,EAAC,MAAM,wBAAwB,CAAC;AAErE,QAAA,MAAM,IAAI,EAAE,6BAeX,CAAC;AAEF,eAAe,IAAI,CAAC"}
1
+ {"version":3,"file":"authenticate.webhooks.doc.d.ts","sourceRoot":"","sources":["../../../../../src/server/authenticate/webhooks/authenticate.webhooks.doc.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,6BAA6B,EAAC,MAAM,wBAAwB,CAAC;AAErE,QAAA,MAAM,IAAI,EAAE,6BAuBX,CAAC;AAEF,eAAe,IAAI,CAAC"}
@@ -2,7 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  var data = {
4
4
  name: 'Webhook',
5
- description: 'Contains functions for verifying Shopify webhooks.',
5
+ description: 'Contains functions for verifying Shopify webhooks.' +
6
+ '\n\n> Note: The format of the `admin` object returned by this function changes with the `v3_webhookAdminContext` future flag. Learn more about [gradual feature adoption](/docs/api/shopify-app-remix/guide-future-flags).',
6
7
  category: 'Authenticate',
7
8
  type: 'object',
8
9
  isVisualComponent: false,
@@ -14,7 +15,13 @@ var data = {
14
15
  },
15
16
  ],
16
17
  jsDocTypeExamples: ['WebhookContextWithSession'],
17
- related: [],
18
+ related: [
19
+ {
20
+ name: 'Admin API context',
21
+ subtitle: 'Interact with the Admin API.',
22
+ url: '/docs/api/shopify-app-remix/apis/admin-api',
23
+ },
24
+ ],
18
25
  };
19
26
  exports.default = data;
20
27
  //# sourceMappingURL=authenticate.webhooks.doc.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"authenticate.webhooks.doc.js","sourceRoot":"","sources":["../../../../../src/server/authenticate/webhooks/authenticate.webhooks.doc.ts"],"names":[],"mappings":";;AAEA,IAAM,IAAI,GAAkC;IAC1C,IAAI,EAAE,SAAS;IACf,WAAW,EAAE,oDAAoD;IACjE,QAAQ,EAAE,cAAc;IACxB,IAAI,EAAE,QAAQ;IACd,iBAAiB,EAAE,KAAK;IACxB,WAAW,EAAE;QACX;YACE,KAAK,EAAE,sBAAsB;YAC7B,WAAW,EAAE,iDAAiD;YAC9D,IAAI,EAAE,qBAAqB;SAC5B;KACF;IACD,iBAAiB,EAAE,CAAC,2BAA2B,CAAC;IAChD,OAAO,EAAE,EAAE;CACZ,CAAC;AAEF,kBAAe,IAAI,CAAC"}
1
+ {"version":3,"file":"authenticate.webhooks.doc.js","sourceRoot":"","sources":["../../../../../src/server/authenticate/webhooks/authenticate.webhooks.doc.ts"],"names":[],"mappings":";;AAEA,IAAM,IAAI,GAAkC;IAC1C,IAAI,EAAE,SAAS;IACf,WAAW,EACT,oDAAoD;QACpD,4NAA4N;IAC9N,QAAQ,EAAE,cAAc;IACxB,IAAI,EAAE,QAAQ;IACd,iBAAiB,EAAE,KAAK;IACxB,WAAW,EAAE;QACX;YACE,KAAK,EAAE,sBAAsB;YAC7B,WAAW,EAAE,iDAAiD;YAC9D,IAAI,EAAE,qBAAqB;SAC5B;KACF;IACD,iBAAiB,EAAE,CAAC,2BAA2B,CAAC;IAChD,OAAO,EAAE;QACP;YACE,IAAI,EAAE,mBAAmB;YACzB,QAAQ,EAAE,8BAA8B;YACxC,GAAG,EAAE,4CAA4C;SAClD;KACF;CACF,CAAC;AAEF,kBAAe,IAAI,CAAC"}
@@ -1,5 +1,7 @@
1
1
  import { Session, Shopify, ShopifyRestResources } from '@shopify/shopify-api';
2
2
  import type { JSONValue } from '../../types';
3
+ import type { AdminApiContext } from '../../clients';
4
+ import type { FeatureEnabled, FutureFlagOptions } from '../../future/flags';
3
5
  export interface RegisterWebhooksOptions {
4
6
  /**
5
7
  * The Shopify session used to register webhooks using the Admin API.
@@ -100,11 +102,18 @@ interface Context<Topics = string | number | symbol> {
100
102
  */
101
103
  payload: JSONValue;
102
104
  }
103
- export interface WebhookContext<Topics = string | number | symbol> extends Context<Topics> {
105
+ export interface WebhookContextWithoutSession<Topics = string | number | symbol> extends Context<Topics> {
104
106
  session: undefined;
105
107
  admin: undefined;
106
108
  }
107
- export interface WebhookContextWithSession<Topics = string | number | symbol, Resources extends ShopifyRestResources = any> extends Context<Topics> {
109
+ export interface LegacyWebhookAdminApiContext<Resources extends ShopifyRestResources> {
110
+ /** A REST client. */
111
+ rest: InstanceType<Shopify['clients']['Rest']> & Resources;
112
+ /** A GraphQL client. */
113
+ graphql: InstanceType<Shopify['clients']['Graphql']>;
114
+ }
115
+ export type WebhookAdminContext<Future extends FutureFlagOptions, Resources extends ShopifyRestResources> = FeatureEnabled<Future, 'v3_webhookAdminContext'> extends true ? AdminApiContext<Resources> : LegacyWebhookAdminApiContext<Resources>;
116
+ export interface WebhookContextWithSession<Future extends FutureFlagOptions, Resources extends ShopifyRestResources, Topics = string | number | symbol> extends Context<Topics> {
108
117
  /**
109
118
  * A session with an offline token for the shop.
110
119
  *
@@ -115,14 +124,66 @@ export interface WebhookContextWithSession<Topics = string | number | symbol, Re
115
124
  * An admin context for the webhook.
116
125
  *
117
126
  * Returned only if there is a session for the shop.
127
+ *
128
+ * @example
129
+ * <caption>[V3] Webhook admin context.</caption>
130
+ * <description>With the `v3_webhookAdminContext` future flag enabled, use the `admin` object in the context to interact with the Admin API.</description>
131
+ * ```ts
132
+ * import { ActionFunctionArgs } from "@remix-run/node";
133
+ * import { authenticate } from "../shopify.server";
134
+ *
135
+ * export async function action({ request }: ActionFunctionArgs) {
136
+ * const { admin } = await authenticate.webhook(request);
137
+ *
138
+ * const response = await admin?.graphql(
139
+ * `#graphql
140
+ * mutation populateProduct($input: ProductInput!) {
141
+ * productCreate(input: $input) {
142
+ * product {
143
+ * id
144
+ * }
145
+ * }
146
+ * }`,
147
+ * { variables: { input: { title: "Product Name" } } }
148
+ * );
149
+ *
150
+ * const productData = await response.json();
151
+ * return json({ data: productData.data });
152
+ * }
153
+ * ```
154
+ *
155
+ * @example
156
+ * <caption>Webhook admin context.</caption>
157
+ * <description>Use the `admin` object in the context to interact with the Admin API. This format will be removed in V3 of the package.</description>
158
+ * ```ts
159
+ * import { json, ActionFunctionArgs } from "@remix-run/node";
160
+ * import { authenticate } from "../shopify.server";
161
+ *
162
+ * export async function action({ request }: ActionFunctionArgs) {
163
+ * const { admin } = await authenticate.webhook(request);
164
+ *
165
+ * const response = await admin?.graphql.query<any>({
166
+ * data: {
167
+ * query: `#graphql
168
+ * mutation populateProduct($input: ProductInput!) {
169
+ * productCreate(input: $input) {
170
+ * product {
171
+ * id
172
+ * }
173
+ * }
174
+ * }`,
175
+ * variables: { input: { title: "Product Name" } },
176
+ * },
177
+ * });
178
+ *
179
+ * const productData = response?.body.data;
180
+ * return json({ data: productData.data });
181
+ * }
182
+ * ```
118
183
  */
119
- admin: {
120
- /** A REST client. */
121
- rest: InstanceType<Shopify['clients']['Rest']> & Resources;
122
- /** A GraphQL client. */
123
- graphql: InstanceType<Shopify['clients']['Graphql']>;
124
- };
184
+ admin: WebhookAdminContext<Future, Resources>;
125
185
  }
126
- export type AuthenticateWebhook<Resources extends ShopifyRestResources = ShopifyRestResources, Topics = string | number | symbol> = (request: Request) => Promise<WebhookContext<Topics> | WebhookContextWithSession<Topics, Resources>>;
186
+ export type WebhookContext<Future extends FutureFlagOptions, Resources extends ShopifyRestResources, Topics = string | number | symbol> = WebhookContextWithoutSession<Topics> | WebhookContextWithSession<Future, Resources, Topics>;
187
+ export type AuthenticateWebhook<Future extends FutureFlagOptions, Resources extends ShopifyRestResources, Topics = string | number | symbol> = (request: Request) => Promise<WebhookContext<Future, Resources, Topics>>;
127
188
  export {};
128
189
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/server/authenticate/webhooks/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAE,OAAO,EAAE,oBAAoB,EAAC,MAAM,sBAAsB,CAAC;AAE5E,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;AAE3C,MAAM,WAAW,uBAAuB;IACtC;;OAEG;IACH,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,UAAU,OAAO,CA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AM,MAAM,mBAAmB,CAC7B,MAAM,SAAS,iBAAiB,EAChC,SAAS,SAAS,oBAAoB,IACpC,cAAc,CAAC,MAAM,EAAE,wBAAwB,CAAC,SAAS,IAAI,GAC7D,eAAe,CAAC,SAAS,CAAC,GAC1B,4BAA4B,CAAC,SAAS,CAAC,CAAC;AAE5C,MAAM,WAAW,yBAAyB,CACxC,MAAM,SAAS,iBAAiB,EAChC,SAAS,SAAS,oBAAoB,EACtC,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CACjC,SAAQ,OAAO,CAAC,MAAM,CAAC;IACvB;;;;OAIG;IACH,OAAO,EAAE,OAAO,CAAC;IAEjB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4DG;IACH,KAAK,EAAE,mBAAmB,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;CAC/C;AAED,MAAM,MAAM,cAAc,CACxB,MAAM,SAAS,iBAAiB,EAChC,SAAS,SAAS,oBAAoB,EACtC,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,IAE/B,4BAA4B,CAAC,MAAM,CAAC,GACpC,yBAAyB,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;AAEzD,MAAM,MAAM,mBAAmB,CAC7B,MAAM,SAAS,iBAAiB,EAChC,SAAS,SAAS,oBAAoB,EACtC,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,IAC/B,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,cAAc,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC,CAAC"}
@@ -39,10 +39,10 @@ export interface AdminApiContext<Resources extends ShopifyRestResources = Shopif
39
39
  *
40
40
  * ```ts
41
41
  * // /app/routes/**\/*.ts
42
- * import { LoaderArgs, json } from "@remix-run/node";
42
+ * import { LoaderFunctionArgs, json } from "@remix-run/node";
43
43
  * import { authenticate } from "../shopify.server";
44
44
  *
45
- * export const loader = async ({ request }: LoaderArgs) => {
45
+ * export const loader = async ({ request }: LoaderFunctionArgs) => {
46
46
  * const { admin, session } = await authenticate.admin(request);
47
47
  * return json(admin.rest.resources.Order.count({ session }));
48
48
  * };
@@ -67,10 +67,10 @@ export interface AdminApiContext<Resources extends ShopifyRestResources = Shopif
67
67
  *
68
68
  * ```ts
69
69
  * // /app/routes/**\/*.ts
70
- * import { LoaderArgs, json } from "@remix-run/node";
70
+ * import { LoaderFunctionArgs, json } from "@remix-run/node";
71
71
  * import { authenticate } from "../shopify.server";
72
72
  *
73
- * export const loader = async ({ request }: LoaderArgs) => {
73
+ * export const loader = async ({ request }: LoaderFunctionArgs) => {
74
74
  * const { admin, session } = await authenticate.admin(request);
75
75
  * const response = await admin.rest.get({ path: "/customers/count.json" });
76
76
  * const customers = await response.json();
@@ -83,16 +83,16 @@ export interface AdminApiContext<Resources extends ShopifyRestResources = Shopif
83
83
  * Methods for interacting with the Shopify Admin GraphQL API
84
84
  *
85
85
  * {@link https://shopify.dev/docs/api/admin-graphql}
86
- * {@link https://github.com/Shopify/shopify-api-js/blob/main/docs/reference/clients/Graphql.md}
86
+ * {@link https://github.com/Shopify/shopify-api-js/blob/main/packages/shopify-api/docs/reference/clients/Graphql.md}
87
87
  *
88
88
  * @example
89
89
  * <caption>Querying the GraphQL API.</caption>
90
90
  * <description>Use `admin.graphql` to make query / mutation requests.</description>
91
91
  * ```ts
92
- * import { ActionArgs } from "@remix-run/node";
92
+ * import { ActionFunctionArgs } from "@remix-run/node";
93
93
  * import { authenticate } from "../shopify.server";
94
94
  *
95
- * export async function action({ request }: ActionArgs) {
95
+ * export async function action({ request }: ActionFunctionArgs) {
96
96
  * const { admin } = await authenticate.admin(request);
97
97
  *
98
98
  * const response = await admin.graphql(
@@ -11,10 +11,10 @@ export interface StorefrontContext {
11
11
  * <caption>Querying the GraphQL API.</caption>
12
12
  * <description>Use `storefront.graphql` to make query / mutation requests.</description>
13
13
  * ```ts
14
- * import { ActionArgs } from "@remix-run/node";
14
+ * import { ActionFunctionArgs } from "@remix-run/node";
15
15
  * import { authenticate } from "../shopify.server";
16
16
  *
17
- * export async function action({ request }: ActionArgs) {
17
+ * export async function action({ request }: ActionFunctionArgs) {
18
18
  * const { storefront } = await authenticate.storefront(request);
19
19
  *
20
20
  * const response = await storefront.graphql(`{blogs(first: 10) { edges { node { id } } } }`);
@@ -1,5 +1,6 @@
1
1
  import { ConfigParams as ApiConfigArg, ConfigInterface as ApiConfig, ShopifyRestResources, Session, ApiVersion, WebhookHandler } from '@shopify/shopify-api';
2
2
  import { SessionStorage } from '@shopify/shopify-app-session-storage';
3
+ import type { FutureFlags } from './future/flags';
3
4
  import type { AppDistribution } from './types';
4
5
  import type { AdminApiContext } from './clients';
5
6
  export interface AppConfigArg<Resources extends ShopifyRestResources = ShopifyRestResources, Storage extends SessionStorage = SessionStorage> extends Omit<ApiConfigArg<Resources>, 'hostName' | 'hostScheme' | 'isEmbeddedApp' | 'apiVersion' | 'isCustomStoreApp'> {
@@ -74,12 +75,12 @@ export interface AppConfigArg<Resources extends ShopifyRestResources = ShopifyRe
74
75
  * export const authenticate = shopify.authenticate;
75
76
  *
76
77
  * // /app/routes/webhooks.jsx
77
- * import { ActionArgs } from "@remix-run/node";
78
+ * import { ActionFunctionArgs } from "@remix-run/node";
78
79
  *
79
80
  * import { authenticate } from "../shopify.server";
80
81
  * import db from "../db.server";
81
82
  *
82
- * export const action = async ({ request }: ActionArgs) => {
83
+ * export const action = async ({ request }: ActionFunctionArgs) => {
83
84
  * const { topic, shop } = await authenticate.webhook(request);
84
85
  *
85
86
  * switch (topic) {
@@ -173,10 +174,10 @@ export interface AppConfigArg<Resources extends ShopifyRestResources = ShopifyRe
173
174
  * export const authenticate = shopify.authenticate;
174
175
  *
175
176
  * // /app/routes/auth/$.jsx
176
- * import { LoaderArgs } from "@remix-run/node";
177
+ * import { LoaderFunctionArgs } from "@remix-run/node";
177
178
  * import { authenticate } from "../../shopify.server";
178
179
  *
179
- * export async function loader({ request }: LoaderArgs) {
180
+ * export async function loader({ request }: LoaderFunctionArgs) {
180
181
  * await authenticate.admin(request);
181
182
  *
182
183
  * return null
@@ -184,6 +185,13 @@ export interface AppConfigArg<Resources extends ShopifyRestResources = ShopifyRe
184
185
  * ```
185
186
  */
186
187
  authPathPrefix?: string;
188
+ /**
189
+ * Features that will be introduced in future releases of this package.
190
+ *
191
+ * You can opt in to these features by setting the corresponding flags. By doing so, you can prepare for future
192
+ * releases in advance and provide feedback on the new features.
193
+ */
194
+ future?: FutureFlags;
187
195
  }
188
196
  export interface AppConfig<Storage extends SessionStorage = SessionStorage> extends ApiConfig {
189
197
  canUseLoginForm: boolean;
@@ -192,6 +200,7 @@ export interface AppConfig<Storage extends SessionStorage = SessionStorage> exte
192
200
  sessionStorage: Storage;
193
201
  useOnlineTokens: boolean;
194
202
  hooks: HooksConfig;
203
+ future: FutureFlags;
195
204
  }
196
205
  interface AuthConfig {
197
206
  path: string;
@@ -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,EAAC,eAAe,EAAC,MAAM,SAAS,CAAC;AAC7C,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,WAAW,CAAC;AAE/C,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,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
3
+ * When enabled, returns the same `admin` context (`AdminApiContext`) from `authenticate.webhook` that is returned from `authenticate.admin`.
4
+ *
5
+ * @default false
6
+ */
7
+ v3_webhookAdminContext?: boolean;
8
+ }
9
+ export type FutureFlagOptions = FutureFlags | undefined;
10
+ export type FeatureEnabled<Future extends FutureFlagOptions, Flag extends keyof FutureFlags> = Future extends FutureFlags ? Future[Flag] extends true ? true : false : false;
11
+ //# sourceMappingURL=flags.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flags.d.ts","sourceRoot":"","sources":["../../../../src/server/future/flags.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,WAAW;IAC1B;;;;OAIG;IACH,sBAAsB,CAAC,EAAE,OAAO,CAAC;CAClC;AAED,MAAM,MAAM,iBAAiB,GAAG,WAAW,GAAG,SAAS,CAAC;AAExD,MAAM,MAAM,cAAc,CACxB,MAAM,SAAS,iBAAiB,EAChC,IAAI,SAAS,MAAM,WAAW,IAC5B,MAAM,SAAS,WAAW,GAC1B,MAAM,CAAC,IAAI,CAAC,SAAS,IAAI,GACvB,IAAI,GACJ,KAAK,GACP,KAAK,CAAC"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=flags.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flags.js","sourceRoot":"","sources":["../../../../src/server/future/flags.ts"],"names":[],"mappings":""}
@@ -1 +1 @@
1
- {"version":3,"file":"shopify-app.d.ts","sourceRoot":"","sources":["../../../src/server/shopify-app.ts"],"names":[],"mappings":"AAAA,OAAO,uCAAuC,CAAC;AAC/C,OAAO,EAML,oBAAoB,EAErB,MAAM,sBAAsB,CAAC;AAC9B,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;AAYjB;;;;;;;;;;;;;;;;;;;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,CAyCvC"}
1
+ {"version":3,"file":"shopify-app.d.ts","sourceRoot":"","sources":["../../../src/server/shopify-app.ts"],"names":[],"mappings":"AAAA,OAAO,uCAAuC,CAAC;AAC/C,OAAO,EAIL,oBAAoB,EAErB,MAAM,sBAAsB,CAAC;AAC9B,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;AAYjB;;;;;;;;;;;;;;;;;;;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,CA0CvC"}
@@ -1 +1 @@
1
- {"version":3,"file":"shopify-app.doc.d.ts","sourceRoot":"","sources":["../../../src/server/shopify-app.doc.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,6BAA6B,EAAC,MAAM,wBAAwB,CAAC;AAErE,QAAA,MAAM,IAAI,EAAE,6BAgCX,CAAC;AAEF,eAAe,IAAI,CAAC"}
1
+ {"version":3,"file":"shopify-app.doc.d.ts","sourceRoot":"","sources":["../../../src/server/shopify-app.doc.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,6BAA6B,EAAC,MAAM,wBAAwB,CAAC;AAErE,QAAA,MAAM,IAAI,EAAE,6BAuCX,CAAC;AAEF,eAAe,IAAI,CAAC"}
@@ -13,6 +13,12 @@ var data = {
13
13
  description: 'Function to create a new Shopify API object.',
14
14
  type: 'ShopifyAppGeneratedType',
15
15
  },
16
+ {
17
+ title: 'Future flags',
18
+ description: 'Set future flags using the `future` configuration field to opt in to upcoming breaking changes.' +
19
+ '\n\nWith this feature, you can prepare for major releases ahead of time, as well as try out new features before they are released.',
20
+ type: 'FutureFlags',
21
+ },
16
22
  ],
17
23
  jsDocTypeExamples: [
18
24
  'ShopifyAppGeneratedType',
@@ -1 +1 @@
1
- {"version":3,"file":"shopify-app.doc.js","sourceRoot":"","sources":["../../../src/server/shopify-app.doc.ts"],"names":[],"mappings":";;AAEA,IAAM,IAAI,GAAkC;IAC1C,IAAI,EAAE,YAAY;IAClB,WAAW,EACT,iHAAiH;QACjH,oOAAoO;IACtO,QAAQ,EAAE,aAAa;IACvB,IAAI,EAAE,UAAU;IAChB,iBAAiB,EAAE,KAAK;IACxB,WAAW,EAAE;QACX;YACE,KAAK,EAAE,YAAY;YACnB,WAAW,EAAE,8CAA8C;YAC3D,IAAI,EAAE,yBAAyB;SAChC;KACF;IACD,iBAAiB,EAAE;QACjB,yBAAyB;QACzB,gBAAgB;QAChB,iBAAiB;KAClB;IACD,OAAO,EAAE;QACP;YACE,IAAI,EAAE,wBAAwB;YAC9B,QAAQ,EAAE,4CAA4C;YACtD,GAAG,EAAE,0CAA0C;SAChD;QACD;YACE,IAAI,EAAE,0BAA0B;YAChC,QAAQ,EAAE,gDAAgD;YAC1D,GAAG,EAAE,6CAA6C;SACnD;KACF;CACF,CAAC;AAEF,kBAAe,IAAI,CAAC"}
1
+ {"version":3,"file":"shopify-app.doc.js","sourceRoot":"","sources":["../../../src/server/shopify-app.doc.ts"],"names":[],"mappings":";;AAEA,IAAM,IAAI,GAAkC;IAC1C,IAAI,EAAE,YAAY;IAClB,WAAW,EACT,iHAAiH;QACjH,oOAAoO;IACtO,QAAQ,EAAE,aAAa;IACvB,IAAI,EAAE,UAAU;IAChB,iBAAiB,EAAE,KAAK;IACxB,WAAW,EAAE;QACX;YACE,KAAK,EAAE,YAAY;YACnB,WAAW,EAAE,8CAA8C;YAC3D,IAAI,EAAE,yBAAyB;SAChC;QACD;YACE,KAAK,EAAE,cAAc;YACrB,WAAW,EACT,iGAAiG;gBACjG,oIAAoI;YACtI,IAAI,EAAE,aAAa;SACpB;KACF;IACD,iBAAiB,EAAE;QACjB,yBAAyB;QACzB,gBAAgB;QAChB,iBAAiB;KAClB;IACD,OAAO,EAAE;QACP;YACE,IAAI,EAAE,wBAAwB;YAC9B,QAAQ,EAAE,4CAA4C;YACtD,GAAG,EAAE,0CAA0C;SAChD;QACD;YACE,IAAI,EAAE,0BAA0B;YAChC,QAAQ,EAAE,gDAAgD;YAC1D,GAAG,EAAE,6CAA6C;SACnD;KACF;CACF,CAAC;AAEF,kBAAe,IAAI,CAAC"}