cli icon indicating copy to clipboard operation
cli copied to clipboard

[prototype] Import declarative webhooks

Open shauns opened this issue 1 year ago β€’ 3 comments

WHY are these changes introduced?

Make it easier to start using declarative webhooks by helping you write the TOML your app might need.

WHAT is this pull request doing?

image
  • New capability to connect to admin on behalf of the current app (incl. GraphQL codegen πŸͺ„ )
  • Use this to list current webhooks and output some TOML

How to test your changes?

  • Create an app, install it, create some webhook subscriptions via the API
  • Run app import-extensions and choose webhooks. You should get the TOML equivalent of what you set up.

Post-release steps

Measuring impact

How do we know this change was effective? Please choose one:

  • [ ] n/a - this doesn't need measurement, e.g. a linting rule or a bug-fix
  • [x] Existing analytics will cater for this addition
  • [ ] PR includes analytics changes to measure impact

Checklist

  • [x] I've considered possible cross-platform impacts (Mac, Linux, Windows)
  • [ ] I've considered possible documentation changes

shauns avatar Sep 18 '24 15:09 shauns

Thanks for your contribution!

Depending on what you are working on, you may want to request a review from a Shopify team:

  • Themes: @shopify/advanced-edits
  • UI extensions: @shopify/ui-extensions-cli
    • Checkout UI extensions: @shopify/checkout-ui-extensions-api-stewardship
  • Hydrogen: @shopify/hydrogen
  • Other: @shopify/app-inner-loop

github-actions[bot] avatar Sep 18 '24 15:09 github-actions[bot]

Differences in type declarations

We detected differences in the type declarations generated by Typescript for this branch compared to the baseline ('main' branch). Please, review them to ensure they are backward-compatible. Here are some important things to keep in mind:

  • Some seemingly private modules might be re-exported through public modules.
  • If the branch is behind main you might see odd diffs, rebase main into this branch.

New type declarations

packages/cli-kit/dist/public/node/api/admin-as-app.d.ts
import { AdminSession } from '../session.js';
import { TypedDocumentNode } from '@graphql-typed-document-node/core';
import { Variables } from 'graphql-request';
/**
 * Executes a GraphQL query against the Admin API on behalf of the app. Uses typed documents.
 *
 * @param query - GraphQL query to execute.
 * @param session - Admin session.
 * @param apiVersion - API version, e.g. '2024-07'.
 * @param variables - GraphQL variables to pass to the query.
 * @returns The response of the query of generic type <TResult>.
 */
export declare function adminAsAppRequest<TResult, TVariables extends Variables>(query: TypedDocumentNode<TResult, TVariables>, session: AdminSession, apiVersion: string, variables?: TVariables): Promise<TResult>;

Existing type declarations

packages/cli-kit/dist/public/node/session.d.ts
@@ -54,6 +54,17 @@ export declare function ensureAuthenticatedStorefront(scopes?: string[], passwor
  * @returns The access token for the Admin API.
  */
 export declare function ensureAuthenticatedAdmin(store: string, scopes?: string[], forceRefresh?: boolean, options?: EnsureAuthenticatedAdditionalOptions): Promise<AdminSession>;
+/**
+ * Ensure that we have a valid Admin session for the given store, acting on behalf of the app.
+ *
+ * This will fail if the app has not already been installed.
+ *
+ * @param storeFqdn - Store fqdn to request auth for.
+ * @param apiKey - API key for the app.
+ * @param apiSecret - API secret for the app.
+ * @returns The access token for the Admin API.
+ */
+export declare function ensureAuthenticatedAdminAsApp(storeFqdn: string, apiKey: string, apiSecret: string): Promise<AdminSession>;
 /**
  * Ensure that we have a valid session to access the Theme API.
  * If a password is provided, that token will be used against Theme Access API.

github-actions[bot] avatar Sep 18 '24 15:09 github-actions[bot]

Coverage report

St.:grey_question:
Category Percentage Covered / Total
🟑 Statements
72.93% (-0.08% πŸ”»)
8442/11576
🟑 Branches
69.44% (-0.12% πŸ”»)
4106/5913
🟑 Functions
71.8% (+0.05% πŸ”Ό)
2192/3053
🟑 Lines
73.26% (-0.1% πŸ”»)
7987/10903
Show new covered files 🐣
St.:grey_question:
File Statements Branches Functions Lines
🟒
... / list-webhook-subscriptions.ts
100% 100% 100% 100%
πŸ”΄
... / import-declarative-webhooks.ts
61.11% 46.67% 92.31% 58.82%
πŸ”΄
... / admin-as-app.ts
0% 100% 0% 0%
Show files with reduced coverage πŸ”»
St.:grey_question:
File Statements Branches Functions Lines
🟒
... / import-extensions.ts
93.75% (-6.25% πŸ”»)
75% (-8.33% πŸ”»)
100%
93.55% (-6.45% πŸ”»)
🟒
... / ConcurrentOutput.tsx
98.39% (-1.61% πŸ”»)
90.91% (-4.55% πŸ”»)
100%
98.33% (-1.67% πŸ”»)

Test suite run success

1891 tests passing in 860 suites.

Report generated by πŸ§ͺjest coverage report action from d51b164809b7c0e27db83d5ea8d53e98981cf097

github-actions[bot] avatar Sep 18 '24 15:09 github-actions[bot]

This PR seems inactive. If it's still relevant, please add a comment saying so. Otherwise, take no action. β†’ If there's no activity within a week, then a bot will automatically close this. Thanks for helping to improve Shopify's dev tooling and experience.

github-actions[bot] avatar Oct 19 '24 03:10 github-actions[bot]