@shopify/shopify-app-remix
Version:
Shopify Remix - to simplify the building of Shopify Apps with Remix
1 lines • 2.86 kB
Source Map (JSON)
{"version":3,"file":"register.mjs","sources":["../../../../../../src/server/authenticate/webhooks/register.ts"],"sourcesContent":["import type {BasicParams} from '../../types';\n\nimport type {RegisterWebhooksOptions} from './types';\n\nexport function registerWebhooksFactory({api, logger}: BasicParams) {\n return async function registerWebhooks({session}: RegisterWebhooksOptions) {\n return api.webhooks\n .register({session})\n .then((response) => {\n Object.entries(response).forEach(([topic, topicResults]) => {\n topicResults.forEach(({success, ...rest}) => {\n if (success) {\n logger.debug('Registered webhook', {\n topic,\n shop: session.shop,\n operation: rest.operation,\n });\n } else {\n logger.error('Failed to register webhook', {\n topic,\n shop: session.shop,\n result: JSON.stringify(rest.result),\n });\n }\n });\n });\n\n return response;\n })\n .catch((error) => {\n const graphQLErrors: {extensions: {code?: string}}[] =\n error.body?.errors?.graphQLErrors || [];\n\n const throttled = graphQLErrors.find(\n ({extensions: {code}}) => code === 'THROTTLED',\n );\n\n if (throttled) {\n logger.error('Failed to register webhooks', {\n shop: session.shop,\n error: JSON.stringify(error),\n });\n } else {\n throw error;\n }\n });\n };\n}\n"],"names":[],"mappings":"SAIgB,uBAAuB,CAAC,EAAC,GAAG,EAAE,MAAM,EAAc,EAAA;AAChE,IAAA,OAAO,eAAe,gBAAgB,CAAC,EAAC,OAAO,EAA0B,EAAA;QACvE,OAAO,GAAG,CAAC;AACR,aAAA,QAAQ,CAAC,EAAC,OAAO,EAAC;AAClB,aAAA,IAAI,CAAC,CAAC,QAAQ,KAAI;AACjB,YAAA,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,EAAE,YAAY,CAAC,KAAI;gBACzD,YAAY,CAAC,OAAO,CAAC,CAAC,EAAC,OAAO,EAAE,GAAG,IAAI,EAAC,KAAI;oBAC1C,IAAI,OAAO,EAAE;AACX,wBAAA,MAAM,CAAC,KAAK,CAAC,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