diff --git a/packages/app/src/cli/api/graphql/all_app_extension_registrations.ts b/packages/app/src/cli/api/graphql/all_app_extension_registrations.ts index 1946ceee391..0a11fb6348a 100644 --- a/packages/app/src/cli/api/graphql/all_app_extension_registrations.ts +++ b/packages/app/src/cli/api/graphql/all_app_extension_registrations.ts @@ -1,58 +1,3 @@ -import {gql} from 'graphql-request' - -export const AllAppExtensionRegistrationsQuery = gql` - query allAppExtensionRegistrations($apiKey: String!) { - app(apiKey: $apiKey) { - extensionRegistrations { - id - uuid - title - type - draftVersion { - config - context - } - activeVersion { - config - context - } - } - configurationRegistrations { - id - uuid - title - type - draftVersion { - config - context - } - activeVersion { - config - context - } - } - dashboardManagedExtensionRegistrations { - id - uuid - title - type - activeVersion { - config - context - } - draftVersion { - config - context - } - } - } - } -` - -export interface AllAppExtensionRegistrationsQueryVariables { - apiKey: string -} - export interface ExtensionRegistration { id: string uid?: string diff --git a/packages/app/src/cli/api/graphql/app_active_version.ts b/packages/app/src/cli/api/graphql/app_active_version.ts deleted file mode 100644 index 801f36cfa9d..00000000000 --- a/packages/app/src/cli/api/graphql/app_active_version.ts +++ /dev/null @@ -1,55 +0,0 @@ -import {gql} from 'graphql-request' - -export const ActiveAppVersionQuery = gql` - query activeAppVersion($apiKey: String!) { - app(apiKey: $apiKey) { - activeAppVersion { - appModuleVersions { - registrationId - registrationUuid - registrationTitle - type - config - specification { - identifier - name - experience - options { - managementExperience - } - } - } - } - } - } -` - -export interface ActiveAppVersionQueryVariables { - apiKey: string -} - -interface AppModuleVersionSpecification { - identifier: string - name: string - experience: 'extension' | 'configuration' | 'deprecated' - options: { - managementExperience: 'cli' | 'custom' | 'dashboard' - } -} - -export interface AppModuleVersion { - registrationId: string - registrationUuid: string - registrationTitle: string - config?: string - type: string - specification?: AppModuleVersionSpecification -} - -export interface ActiveAppVersionQuerySchema { - app: { - activeAppVersion?: { - appModuleVersions: AppModuleVersion[] - } - } -} diff --git a/packages/app/src/cli/api/graphql/app_deploy.ts b/packages/app/src/cli/api/graphql/app_deploy.ts index 454f4cc9891..cc6557b986b 100644 --- a/packages/app/src/cli/api/graphql/app_deploy.ts +++ b/packages/app/src/cli/api/graphql/app_deploy.ts @@ -1,52 +1,4 @@ import {UserError} from '../../utilities/developer-platform-client.js' -import {gql} from 'graphql-request' - -// eslint-disable-next-line @shopify/cli/no-inline-graphql -export const AppDeploy = gql` - mutation AppDeploy( - $apiKey: String! - $bundleUrl: String - $appModules: [AppModuleSettings!] - $skipPublish: Boolean - $message: String - $versionTag: String - $commitReference: String - ) { - appDeploy( - input: { - apiKey: $apiKey - bundleUrl: $bundleUrl - appModules: $appModules - skipPublish: $skipPublish - message: $message - versionTag: $versionTag - commitReference: $commitReference - } - ) { - appVersion { - uuid - id - message - versionTag - location - appModuleVersions { - uuid - registrationUuid - validationErrors { - message - field - } - } - } - userErrors { - message - field - category - details - } - } - } -` export interface AppModuleSettings { uid?: string diff --git a/packages/app/src/cli/api/graphql/app_release.ts b/packages/app/src/cli/api/graphql/app_release.ts index a38f288f5d9..77054875753 100644 --- a/packages/app/src/cli/api/graphql/app_release.ts +++ b/packages/app/src/cli/api/graphql/app_release.ts @@ -1,29 +1,4 @@ import {UserError} from '../../utilities/developer-platform-client.js' -import {gql} from 'graphql-request' -// eslint-disable-next-line @shopify/cli/no-inline-graphql -export const AppRelease = gql` - mutation AppRelease($apiKey: String!, $appVersionId: ID, $versionTag: String) { - appRelease(input: {apiKey: $apiKey, appVersionId: $appVersionId, versionTag: $versionTag}) { - appVersion { - versionTag - message - location - } - userErrors { - message - field - category - details - } - } - } -` - -export interface AppReleaseVariables { - apiKey: string - versionTag?: string - appVersionId?: number -} export interface AppReleaseSchema { appRelease: { diff --git a/packages/app/src/cli/api/graphql/app_version_by_tag.ts b/packages/app/src/cli/api/graphql/app_version_by_tag.ts deleted file mode 100644 index 5acc6660115..00000000000 --- a/packages/app/src/cli/api/graphql/app_version_by_tag.ts +++ /dev/null @@ -1,45 +0,0 @@ -import {AppModuleVersion} from './app_active_version.js' -import {gql} from 'graphql-request' - -export const AppVersionByTagQuery = gql` - query AppVersionByTag($apiKey: String!, $versionTag: String!) { - app(apiKey: $apiKey) { - appVersion(versionTag: $versionTag) { - id - uuid - versionTag - location - message - appModuleVersions { - config - specification { - identifier - name - experience - options { - managementExperience - } - } - } - } - } - } -` - -export interface AppVersionByTagVariables { - apiKey: string - versionTag?: string -} - -export interface AppVersionByTagSchema { - app: { - appVersion: { - id: number - uuid: string - versionTag?: string | null - location: string - message: string - appModuleVersions: AppModuleVersion[] - } - } -} diff --git a/packages/app/src/cli/api/graphql/app_versions_diff.ts b/packages/app/src/cli/api/graphql/app_versions_diff.ts index ed8d07437a8..fc284b41f9b 100644 --- a/packages/app/src/cli/api/graphql/app_versions_diff.ts +++ b/packages/app/src/cli/api/graphql/app_versions_diff.ts @@ -1,47 +1,3 @@ -import {gql} from 'graphql-request' - -export const AppVersionsDiffQuery = gql` - query AppVersionsDiff($apiKey: String!, $versionId: ID!) { - app(apiKey: $apiKey) { - versionsDiff(appVersionId: $versionId) { - added { - uuid - registrationTitle - specification { - identifier - experience - options { - managementExperience - } - } - } - updated { - uuid - registrationTitle - specification { - identifier - experience - options { - managementExperience - } - } - } - removed { - uuid - registrationTitle - specification { - identifier - experience - options { - managementExperience - } - } - } - } - } - } -` - export interface AppVersionsDiffExtensionSchema { uuid: string registrationTitle: string diff --git a/packages/app/src/cli/api/graphql/create_app.ts b/packages/app/src/cli/api/graphql/create_app.ts deleted file mode 100644 index 577368b7b88..00000000000 --- a/packages/app/src/cli/api/graphql/create_app.ts +++ /dev/null @@ -1,104 +0,0 @@ -import {gql} from 'graphql-request' - -export const CreateAppQuery = gql` - mutation AppCreate( - $org: Int! - $title: String! - $appUrl: Url! - $redir: [Url]! - $type: AppType - $requestedAccessScopes: [String!] - ) { - appCreate( - input: { - organizationID: $org - title: $title - applicationUrl: $appUrl - redirectUrlWhitelist: $redir - appType: $type - requestedAccessScopes: $requestedAccessScopes - } - ) { - app { - id - title - apiKey - organizationId - apiSecretKeys { - secret - } - appType - grantedScopes - applicationUrl - redirectUrlWhitelist - requestedAccessScopes - webhookApiVersion - embedded - posEmbedded - preferencesUrl - gdprWebhooks { - customerDeletionUrl - customerDataRequestUrl - shopDeletionUrl - } - appProxy { - subPath - subPathPrefix - url - } - disabledFlags - } - userErrors { - field - message - } - } - } -` - -export interface CreateAppQueryVariables { - org: number - title: string - appUrl: string - redir: string[] - type: string - requestedAccessScopes?: string[] -} - -export interface CreateAppQuerySchema { - appCreate: { - app: { - id: string - title: string - apiKey: string - organizationId: string - apiSecretKeys: { - secret: string - }[] - appType: string - grantedScopes: string[] - applicationUrl: string - redirectUrlWhitelist: string[] - requestedAccessScopes?: string[] - webhookApiVersion: string - embedded: boolean - posEmbedded?: boolean - preferencesUrl?: string - gdprWebhooks?: { - customerDeletionUrl?: string - customerDataRequestUrl?: string - shopDeletionUrl?: string - } - appProxy?: { - subPath: string - subPathPrefix: string - url: string - } - disabledFlags: string[] - } - userErrors: { - field: string[] - message: string - }[] - } -} diff --git a/packages/app/src/cli/api/graphql/extension_specifications.ts b/packages/app/src/cli/api/graphql/extension_specifications.ts index a2108617ab6..679786eb552 100644 --- a/packages/app/src/cli/api/graphql/extension_specifications.ts +++ b/packages/app/src/cli/api/graphql/extension_specifications.ts @@ -1,35 +1,3 @@ -import {gql} from 'graphql-request' - -// eslint-disable-next-line @shopify/cli/no-inline-graphql -export const ExtensionSpecificationsQuery = gql` - query fetchSpecifications($apiKey: String!) { - extensionSpecifications(apiKey: $apiKey) { - name - externalName - externalIdentifier - identifier - gated - experience - options { - managementExperience - registrationLimit - } - features { - argo { - surface - } - } - validationSchema { - jsonSchema - } - } - } -` - -export interface ExtensionSpecificationsQueryVariables { - apiKey: string -} - export interface RemoteSpecification { name: string externalName: string @@ -45,28 +13,3 @@ export interface RemoteSpecification { jsonSchema: string } | null } - -interface PartnersRemoteSpecification { - name: string - externalName: string - identifier: string - gated: boolean - externalIdentifier: string - experience: 'extension' | 'configuration' | 'deprecated' - options: { - managementExperience: 'cli' | 'custom' | 'dashboard' - registrationLimit: number - } - features?: { - argo?: { - surface: string - } - } - validationSchema?: { - jsonSchema: string - } | null -} - -export interface ExtensionSpecificationsQuerySchema { - extensionSpecifications: PartnersRemoteSpecification[] -} diff --git a/packages/app/src/cli/api/graphql/find_app.ts b/packages/app/src/cli/api/graphql/find_app.ts deleted file mode 100644 index aaa848a1caf..00000000000 --- a/packages/app/src/cli/api/graphql/find_app.ts +++ /dev/null @@ -1,73 +0,0 @@ -import {gql} from 'graphql-request' - -export const FindAppQuery = gql` - query FindApp($apiKey: String!) { - app(apiKey: $apiKey) { - id - title - apiKey - organizationId - apiSecretKeys { - secret - } - appType - grantedScopes - applicationUrl - redirectUrlWhitelist - requestedAccessScopes - webhookApiVersion - embedded - posEmbedded - preferencesUrl - gdprWebhooks { - customerDeletionUrl - customerDataRequestUrl - shopDeletionUrl - } - appProxy { - subPath - subPathPrefix - url - } - developmentStorePreviewEnabled - disabledFlags - } - } -` - -export interface FindAppQueryVariables { - apiKey: string -} - -export interface FindAppQuerySchema { - app: { - id: string - title: string - apiKey: string - organizationId: string - apiSecretKeys: { - secret: string - }[] - appType: string - grantedScopes: string[] - applicationUrl: string - redirectUrlWhitelist: string[] - requestedAccessScopes?: string[] - webhookApiVersion: string - embedded: boolean - posEmbedded?: boolean - preferencesUrl?: string - gdprWebhooks?: { - customerDeletionUrl?: string - customerDataRequestUrl?: string - shopDeletionUrl?: string - } - appProxy?: { - subPath: string - subPathPrefix: string - url: string - } - developmentStorePreviewEnabled: boolean - disabledFlags: string[] - } -} diff --git a/packages/app/src/cli/api/graphql/find_org.ts b/packages/app/src/cli/api/graphql/find_org.ts deleted file mode 100644 index 6be9ecc5ba8..00000000000 --- a/packages/app/src/cli/api/graphql/find_org.ts +++ /dev/null @@ -1,46 +0,0 @@ -import {gql} from 'graphql-request' - -export const FindOrganizationQuery = gql` - query FindOrganization($id: ID!, $title: String) { - organizations(id: $id, first: 1) { - nodes { - id - businessName - apps(first: 25, title: $title) { - pageInfo { - hasNextPage - } - nodes { - id - title - apiKey - } - } - } - } - } -` - -export interface FindOrganizationQueryVariables { - id: string - title?: string -} - -export interface FindOrganizationQuerySchema { - organizations: { - nodes: { - id: string - businessName: string - apps: { - pageInfo: { - hasNextPage: boolean - } - nodes: { - id: string - title: string - apiKey: string - }[] - } - }[] - } -} diff --git a/packages/app/src/cli/api/graphql/find_org_basic.ts b/packages/app/src/cli/api/graphql/find_org_basic.ts deleted file mode 100644 index b5cc272e344..00000000000 --- a/packages/app/src/cli/api/graphql/find_org_basic.ts +++ /dev/null @@ -1,25 +0,0 @@ -import {gql} from 'graphql-request' - -export const FindOrganizationBasicQuery = gql` - query FindOrganization($id: ID!) { - organizations(id: $id, first: 1) { - nodes { - id - businessName - } - } - } -` - -export interface FindOrganizationBasicQuerySchema { - organizations: { - nodes: { - id: string - businessName: string - }[] - } -} - -export interface FindOrganizationBasicVariables { - id: string -} diff --git a/packages/app/src/cli/api/graphql/find_store_by_domain.ts b/packages/app/src/cli/api/graphql/find_store_by_domain.ts deleted file mode 100644 index 1b2c96c88fb..00000000000 --- a/packages/app/src/cli/api/graphql/find_store_by_domain.ts +++ /dev/null @@ -1,46 +0,0 @@ -import {gql} from 'graphql-request' - -export const FindStoreByDomainQuery = gql` - query FindOrganization($orgId: ID!, $shopDomain: String) { - organizations(id: $orgId, first: 1) { - nodes { - id - businessName - stores(shopDomain: $shopDomain, first: 1, archived: false) { - nodes { - shopId - link - shopDomain - shopName - transferDisabled - convertableToPartnerTest - } - } - } - } - } -` - -export interface FindStoreByDomainQueryVariables { - orgId: string - shopDomain: string -} - -export interface FindStoreByDomainSchema { - organizations: { - nodes: { - id: string - businessName: string - stores: { - nodes: { - shopId: string - link: string - shopDomain: string - shopName: string - transferDisabled: boolean - convertableToPartnerTest: boolean - }[] - } - }[] - } -} diff --git a/packages/app/src/cli/api/graphql/functions/api_schema_definition.ts b/packages/app/src/cli/api/graphql/functions/api_schema_definition.ts deleted file mode 100644 index bf6be02a5dc..00000000000 --- a/packages/app/src/cli/api/graphql/functions/api_schema_definition.ts +++ /dev/null @@ -1,11 +0,0 @@ -import {gql} from 'graphql-request' - -export const ApiSchemaDefinitionQuery = gql` - query ApiSchemaDefinitionQuery($apiKey: String!, $version: String!, $type: String!) { - definition: functionApiSchemaDefinition(apiKey: $apiKey, version: $version, type: $type) - } -` - -export interface ApiSchemaDefinitionQuerySchema { - definition: string | null -} diff --git a/packages/app/src/cli/api/graphql/functions/target_schema_definition.ts b/packages/app/src/cli/api/graphql/functions/target_schema_definition.ts deleted file mode 100644 index a957d03d65f..00000000000 --- a/packages/app/src/cli/api/graphql/functions/target_schema_definition.ts +++ /dev/null @@ -1,11 +0,0 @@ -import {gql} from 'graphql-request' - -export const TargetSchemaDefinitionQuery = gql` - query TargetSchemaDefinitionQuery($apiKey: String!, $version: String!, $target: String!) { - definition: functionTargetSchemaDefinition(apiKey: $apiKey, version: $version, target: $target) - } -` - -export interface TargetSchemaDefinitionQuerySchema { - definition: string | null -} diff --git a/packages/app/src/cli/api/graphql/generate_signed_upload_url.ts b/packages/app/src/cli/api/graphql/generate_signed_upload_url.ts deleted file mode 100644 index 81f24a99189..00000000000 --- a/packages/app/src/cli/api/graphql/generate_signed_upload_url.ts +++ /dev/null @@ -1,28 +0,0 @@ -import {gql} from 'graphql-request' - -export const GenerateSignedUploadUrl = gql` - mutation GenerateSignedUploadUrl($apiKey: String!, $bundleFormat: Int!) { - appVersionGenerateSignedUploadUrl(input: {apiKey: $apiKey, bundleFormat: $bundleFormat}) { - signedUploadUrl - userErrors { - field - message - } - } - } -` - -export interface GenerateSignedUploadUrlVariables { - apiKey: string - bundleFormat: number -} - -export interface GenerateSignedUploadUrlSchema { - appVersionGenerateSignedUploadUrl: { - signedUploadUrl: string - userErrors: { - field: string[] - message: string - }[] - } -} diff --git a/packages/app/src/cli/api/graphql/get_versions_list.ts b/packages/app/src/cli/api/graphql/get_versions_list.ts index 5a8ebcc8cb7..d01150892c0 100644 --- a/packages/app/src/cli/api/graphql/get_versions_list.ts +++ b/packages/app/src/cli/api/graphql/get_versions_list.ts @@ -1,33 +1,3 @@ -import {gql} from 'graphql-request' - -export const AppVersionsQuery = gql` - query AppVersionsQuery($apiKey: String!) { - app(apiKey: $apiKey) { - id - organizationId - title - appVersions { - nodes { - createdAt - createdBy { - displayName - } - message - status - versionTag - } - pageInfo { - totalResults - } - } - } - } -` - -export interface AppVersionsQueryVariables { - apiKey: string -} - export interface AppVersionsQuerySchema { app: { id: string diff --git a/packages/app/src/cli/api/graphql/partners/generated/all-orgs.ts b/packages/app/src/cli/api/graphql/partners/generated/all-orgs.ts deleted file mode 100644 index a0e4c8c245e..00000000000 --- a/packages/app/src/cli/api/graphql/partners/generated/all-orgs.ts +++ /dev/null @@ -1,49 +0,0 @@ -/* eslint-disable @typescript-eslint/consistent-type-definitions */ -import * as Types from './types.js' - -import {TypedDocumentNode as DocumentNode} from '@graphql-typed-document-node/core' - -export type AllOrgsQueryVariables = Types.Exact<{[key: string]: never}> - -export type AllOrgsQuery = {organizations: {nodes?: ({id: string; businessName: string} | null)[] | null}} - -export const AllOrgs = { - kind: 'Document', - definitions: [ - { - kind: 'OperationDefinition', - operation: 'query', - name: {kind: 'Name', value: 'AllOrgs'}, - selectionSet: { - kind: 'SelectionSet', - selections: [ - { - kind: 'Field', - name: {kind: 'Name', value: 'organizations'}, - arguments: [ - {kind: 'Argument', name: {kind: 'Name', value: 'first'}, value: {kind: 'IntValue', value: '200'}}, - ], - selectionSet: { - kind: 'SelectionSet', - selections: [ - { - kind: 'Field', - name: {kind: 'Name', value: 'nodes'}, - selectionSet: { - kind: 'SelectionSet', - selections: [ - {kind: 'Field', name: {kind: 'Name', value: 'id'}}, - {kind: 'Field', name: {kind: 'Name', value: 'businessName'}}, - {kind: 'Field', name: {kind: 'Name', value: '__typename'}}, - ], - }, - }, - {kind: 'Field', name: {kind: 'Name', value: '__typename'}}, - ], - }, - }, - ], - }, - }, - ], -} as unknown as DocumentNode diff --git a/packages/app/src/cli/api/graphql/partners/generated/dev-stores-by-org.ts b/packages/app/src/cli/api/graphql/partners/generated/dev-stores-by-org.ts deleted file mode 100644 index 12381011f62..00000000000 --- a/packages/app/src/cli/api/graphql/partners/generated/dev-stores-by-org.ts +++ /dev/null @@ -1,132 +0,0 @@ -/* eslint-disable @typescript-eslint/consistent-type-definitions */ -import * as Types from './types.js' - -import {TypedDocumentNode as DocumentNode} from '@graphql-typed-document-node/core' - -export type DevStoresByOrgQueryVariables = Types.Exact<{ - id: Types.Scalars['ID']['input'] -}> - -export type DevStoresByOrgQuery = { - organizations: { - nodes?: - | ({ - id: string - stores: { - nodes?: - | ({ - shopId?: string | null - link: unknown - shopDomain: string - shopName: string - transferDisabled: boolean - convertableToPartnerTest: boolean - } | null)[] - | null - } - } | null)[] - | null - } -} - -export const DevStoresByOrg = { - kind: 'Document', - definitions: [ - { - kind: 'OperationDefinition', - operation: 'query', - name: {kind: 'Name', value: 'DevStoresByOrg'}, - variableDefinitions: [ - { - kind: 'VariableDefinition', - variable: {kind: 'Variable', name: {kind: 'Name', value: 'id'}}, - type: {kind: 'NonNullType', type: {kind: 'NamedType', name: {kind: 'Name', value: 'ID'}}}, - }, - ], - selectionSet: { - kind: 'SelectionSet', - selections: [ - { - kind: 'Field', - name: {kind: 'Name', value: 'organizations'}, - arguments: [ - { - kind: 'Argument', - name: {kind: 'Name', value: 'id'}, - value: {kind: 'Variable', name: {kind: 'Name', value: 'id'}}, - }, - {kind: 'Argument', name: {kind: 'Name', value: 'first'}, value: {kind: 'IntValue', value: '1'}}, - ], - selectionSet: { - kind: 'SelectionSet', - selections: [ - { - kind: 'Field', - name: {kind: 'Name', value: 'nodes'}, - selectionSet: { - kind: 'SelectionSet', - selections: [ - {kind: 'Field', name: {kind: 'Name', value: 'id'}}, - { - kind: 'Field', - name: {kind: 'Name', value: 'stores'}, - arguments: [ - { - kind: 'Argument', - name: {kind: 'Name', value: 'first'}, - value: {kind: 'IntValue', value: '500'}, - }, - { - kind: 'Argument', - name: {kind: 'Name', value: 'archived'}, - value: {kind: 'BooleanValue', value: false}, - }, - { - kind: 'Argument', - name: {kind: 'Name', value: 'type'}, - value: { - kind: 'ListValue', - values: [ - {kind: 'EnumValue', value: 'DEVELOPMENT'}, - {kind: 'EnumValue', value: 'MANAGED'}, - {kind: 'EnumValue', value: 'PLUS_SANDBOX'}, - ], - }, - }, - ], - selectionSet: { - kind: 'SelectionSet', - selections: [ - { - kind: 'Field', - name: {kind: 'Name', value: 'nodes'}, - selectionSet: { - kind: 'SelectionSet', - selections: [ - {kind: 'Field', name: {kind: 'Name', value: 'shopId'}}, - {kind: 'Field', name: {kind: 'Name', value: 'link'}}, - {kind: 'Field', name: {kind: 'Name', value: 'shopDomain'}}, - {kind: 'Field', name: {kind: 'Name', value: 'shopName'}}, - {kind: 'Field', name: {kind: 'Name', value: 'transferDisabled'}}, - {kind: 'Field', name: {kind: 'Name', value: 'convertableToPartnerTest'}}, - {kind: 'Field', name: {kind: 'Name', value: '__typename'}}, - ], - }, - }, - {kind: 'Field', name: {kind: 'Name', value: '__typename'}}, - ], - }, - }, - {kind: 'Field', name: {kind: 'Name', value: '__typename'}}, - ], - }, - }, - {kind: 'Field', name: {kind: 'Name', value: '__typename'}}, - ], - }, - }, - ], - }, - }, - ], -} as unknown as DocumentNode diff --git a/packages/app/src/cli/api/graphql/partners/queries/all-orgs.graphql b/packages/app/src/cli/api/graphql/partners/queries/all-orgs.graphql deleted file mode 100644 index 30eb916c46d..00000000000 --- a/packages/app/src/cli/api/graphql/partners/queries/all-orgs.graphql +++ /dev/null @@ -1,8 +0,0 @@ -query AllOrgs { - organizations(first: 200) { - nodes { - id - businessName - } - } -} diff --git a/packages/app/src/cli/api/graphql/partners/queries/dev-stores-by-org.graphql b/packages/app/src/cli/api/graphql/partners/queries/dev-stores-by-org.graphql deleted file mode 100644 index a4f0dd56a46..00000000000 --- a/packages/app/src/cli/api/graphql/partners/queries/dev-stores-by-org.graphql +++ /dev/null @@ -1,17 +0,0 @@ -query DevStoresByOrg($id: ID!) { - organizations(id: $id, first: 1) { - nodes { - id - stores(first: 500, archived: false, type: [DEVELOPMENT, MANAGED, PLUS_SANDBOX]) { - nodes { - shopId - link - shopDomain - shopName - transferDisabled - convertableToPartnerTest - } - } - } - } -} diff --git a/packages/app/src/cli/api/graphql/subscribe_to_app_logs.ts b/packages/app/src/cli/api/graphql/subscribe_to_app_logs.ts deleted file mode 100644 index 33e4fc2d4d5..00000000000 --- a/packages/app/src/cli/api/graphql/subscribe_to_app_logs.ts +++ /dev/null @@ -1,20 +0,0 @@ -import {gql} from 'graphql-request' - -export interface AppLogsSubscribeResponse { - appLogsSubscribe: { - success: boolean - errors?: string[] - jwtToken: string - } -} - -// eslint-disable-next-line @shopify/cli/no-inline-graphql -export const AppLogsSubscribeMutation = gql` - mutation AppLogsSubscribe($apiKey: String!, $shopIds: [ID!]!) { - appLogsSubscribe(input: {apiKey: $apiKey, shopIds: $shopIds}) { - jwtToken - success - errors - } - } -` diff --git a/packages/app/src/cli/api/graphql/template_specifications.ts b/packages/app/src/cli/api/graphql/template_specifications.ts deleted file mode 100644 index b473407a150..00000000000 --- a/packages/app/src/cli/api/graphql/template_specifications.ts +++ /dev/null @@ -1,52 +0,0 @@ -import {ExtensionFlavorValue} from '../../services/generate/extension.js' -import {gql} from 'graphql-request' - -export const RemoteTemplateSpecificationsQuery = gql` - query RemoteTemplateSpecifications($version: String, $apiKey: String) { - templateSpecifications(version: $version, apiKey: $apiKey) { - identifier - name - defaultName - group - sortPriority - supportLinks - types { - url - type - extensionPoints - supportedFlavors { - name - value - path - } - } - } - } -` - -interface ExtensionType { - url: string - type: string - extensionPoints: string[] - supportedFlavors: { - name: string - value: ExtensionFlavorValue - path: string - }[] -} - -export interface RemoteTemplateSpecificationsSchema { - templateSpecifications: { - identifier: string - name: string - defaultName: string - group: string - sortPriority: number - supportLinks: string[] - types: [ExtensionType, ...ExtensionType[]] - }[] -} - -export interface RemoteTemplateSpecificationsVariables { - apiKey: string -} diff --git a/packages/app/src/cli/api/graphql/update_urls.ts b/packages/app/src/cli/api/graphql/update_urls.ts index 085400bc552..d3b64906767 100644 --- a/packages/app/src/cli/api/graphql/update_urls.ts +++ b/packages/app/src/cli/api/graphql/update_urls.ts @@ -1,23 +1,3 @@ -import {gql} from 'graphql-request' - -export const UpdateURLsQuery = gql` - mutation appUpdate($apiKey: String!, $applicationUrl: Url!, $redirectUrlWhitelist: [Url]!, $appProxy: AppProxyInput) { - appUpdate( - input: { - apiKey: $apiKey - applicationUrl: $applicationUrl - redirectUrlWhitelist: $redirectUrlWhitelist - appProxy: $appProxy - } - ) { - userErrors { - message - field - } - } - } -` - export interface UpdateURLsVariables { apiKey: string applicationUrl: string diff --git a/packages/app/src/cli/models/app/app.test-data.ts b/packages/app/src/cli/models/app/app.test-data.ts index ce01625a337..230c665b681 100644 --- a/packages/app/src/cli/models/app/app.test-data.ts +++ b/packages/app/src/cli/models/app/app.test-data.ts @@ -60,14 +60,16 @@ import { import {MigrateAppModuleSchema, MigrateAppModuleVariables} from '../../api/graphql/extension_migrate_app_module.js' import appWebhookSubscriptionSpec from '../extensions/specifications/app_config_webhook_subscription.js' import appAccessSpec from '../extensions/specifications/app_config_app_access.js' -import {AppLogsSubscribeResponse} from '../../api/graphql/subscribe_to_app_logs.js' import {SchemaDefinitionByTargetQueryVariables} from '../../api/graphql/functions/generated/schema-definition-by-target.js' import {SchemaDefinitionByApiTypeQueryVariables} from '../../api/graphql/functions/generated/schema-definition-by-api-type.js' import {AppHomeSpecIdentifier} from '../extensions/specifications/app_config_app_home.js' import {AppProxySpecIdentifier} from '../extensions/specifications/app_config_app_proxy.js' import {ExtensionSpecification} from '../extensions/specification.js' import {AppLogsOptions} from '../../services/app-logs/utils.js' -import {AppLogsSubscribeMutationVariables} from '../../api/graphql/app-management/generated/app-logs-subscribe.js' +import { + AppLogsSubscribeMutation, + AppLogsSubscribeMutationVariables, +} from '../../api/graphql/app-management/generated/app-logs-subscribe.js' import {Project} from '../project/project.js' import {Session} from '@shopify/cli-kit/node/session' import {vi} from 'vitest' @@ -1294,7 +1296,7 @@ const migrateToUiExtensionResponse: MigrateToUiExtensionSchema = { }, } -const appLogsSubscribeResponse: AppLogsSubscribeResponse = { +const appLogsSubscribeResponse: AppLogsSubscribeMutation = { appLogsSubscribe: { success: true, jwtToken: 'jwttoken', diff --git a/packages/app/src/cli/services/webhook/request-api-versions.ts b/packages/app/src/cli/services/webhook/request-api-versions.ts index 0a0d1eb9304..79f2c083d3f 100644 --- a/packages/app/src/cli/services/webhook/request-api-versions.ts +++ b/packages/app/src/cli/services/webhook/request-api-versions.ts @@ -4,12 +4,6 @@ export interface PublicApiVersionsSchema { publicApiVersions: string[] } -export const GetApiVersionsQuery = ` - query getApiVersions { - publicApiVersions - } -` - /** * Requests available api-versions in order to validate flags or present a list of options * diff --git a/packages/app/src/cli/services/webhook/request-sample.ts b/packages/app/src/cli/services/webhook/request-sample.ts index b6c6ab813c5..460d3802b01 100644 --- a/packages/app/src/cli/services/webhook/request-sample.ts +++ b/packages/app/src/cli/services/webhook/request-sample.ts @@ -25,20 +25,6 @@ export interface UserErrors { fields: string[] } -// eslint-disable-next-line @shopify/cli/no-inline-graphql -export const sendSampleWebhookMutation = ` - mutation samplePayload($topic: String!, $api_version: String!, $address: String!, $delivery_method: String!, $shared_secret: String!, $api_key: String) { - sendSampleWebhook(input: {topic: $topic, apiVersion: $api_version, address: $address, deliveryMethod: $delivery_method, sharedSecret: $shared_secret, apiKey: $api_key}) { - samplePayload - success - headers - userErrors { - message - } - } - } -` - /** * Request the sample to partners. Partners will call core and the webhook will be emitted * In case the deliveryMethod is localhost and address is local, the response comes with the data the plugin diff --git a/packages/app/src/cli/services/webhook/request-topics.ts b/packages/app/src/cli/services/webhook/request-topics.ts index f93a162e3a7..f66a47b45be 100644 --- a/packages/app/src/cli/services/webhook/request-topics.ts +++ b/packages/app/src/cli/services/webhook/request-topics.ts @@ -8,12 +8,6 @@ export interface WebhookTopicsSchema { webhookTopics: string[] } -export const getTopicsQuery = ` - query getWebhookTopics($api_version: String!) { - webhookTopics(apiVersion: $api_version) - } -` - /** * Requests topics for an api-version in order to validate flags or present a list of options * diff --git a/packages/app/src/cli/utilities/developer-platform-client/partners-client.test.ts b/packages/app/src/cli/utilities/developer-platform-client/partners-client.test.ts index e2cce11bf64..054b4cd6d52 100644 --- a/packages/app/src/cli/utilities/developer-platform-client/partners-client.test.ts +++ b/packages/app/src/cli/utilities/developer-platform-client/partners-client.test.ts @@ -1,208 +1,11 @@ import {PartnersClient} from './partners-client.js' -import {CreateAppQuery} from '../../api/graphql/create_app.js' -import {AppInterface, WebType} from '../../models/app/app.js' -import {Organization, OrganizationSource, OrganizationStore} from '../../models/organization.js' -import { - testPartnersUserSession, - testApp, - testAppWithConfig, - testOrganizationApp, -} from '../../models/app/app.test-data.js' -import {appNamePrompt} from '../../prompts/dev.js' -import {FindOrganizationQuery} from '../../api/graphql/find_org.js' -import {partnersRequest} from '@shopify/cli-kit/node/api/partners' -import {describe, expect, vi, test, beforeEach} from 'vitest' - -vi.mock('../../prompts/dev.js') -vi.mock('@shopify/cli-kit/node/api/partners') +import {describe, expect, test, beforeEach} from 'vitest' beforeEach(() => { // Reset the singleton instance before each test PartnersClient.resetInstance() }) -const LOCAL_APP: AppInterface = testApp({ - directory: '', - configuration: { - client_id: 'test-client-id', - name: 'my-app', - application_url: 'https://example.com', - embedded: true, - access_scopes: {scopes: 'read_products'}, - extension_directories: ['extensions/*'], - }, - webs: [ - { - directory: '', - configuration: { - roles: [WebType.Backend], - commands: {dev: ''}, - }, - }, - ], - name: 'my-app', -}) - -type OrganizationInPartnersResponse = Omit - -const ORG1: OrganizationInPartnersResponse = { - id: '1', - businessName: 'org1', -} -const ORG2: OrganizationInPartnersResponse = { - id: '2', - businessName: 'org2', -} - -const APP1 = testOrganizationApp({apiKey: 'key1'}) -const APP2 = testOrganizationApp({ - id: '2', - title: 'app2', - apiKey: 'key2', - apiSecretKeys: [{secret: 'secret2'}], -}) - -const STORE1: OrganizationStore = { - shopId: '1', - link: 'link1', - shopDomain: 'domain1', - shopName: 'store1', - transferDisabled: false, - convertableToPartnerTest: false, - provisionable: true, -} - -const FETCH_ORG_RESPONSE_VALUE = { - organizations: { - nodes: [ - { - id: ORG1.id, - businessName: ORG1.businessName, - apps: {nodes: [APP1, APP2], pageInfo: {hasNextPage: false}}, - stores: {nodes: [STORE1]}, - }, - ], - }, -} - -describe('createApp', () => { - test('sends request to create app with launchable defaults and returns it', async () => { - // Given - const partnersClient = PartnersClient.getInstance(testPartnersUserSession) - const localApp = testAppWithConfig({config: {access_scopes: {scopes: 'write_products'}}}) - vi.mocked(appNamePrompt).mockResolvedValue('app-name') - vi.mocked(partnersRequest).mockResolvedValueOnce({appCreate: {app: APP1, userErrors: []}}) - const variables = { - org: 1, - title: localApp.name, - appUrl: 'https://example.com', - redir: ['https://example.com/api/auth'], - requestedAccessScopes: ['write_products'], - type: 'undecided', - } - - // When - const got = await partnersClient.createApp( - {...ORG1, source: OrganizationSource.Partners}, - { - name: localApp.name, - scopesArray: ['write_products'], - isLaunchable: true, - directory: '', - }, - ) - - // Then - expect(got).toEqual({...APP1, newApp: true, developerPlatformClient: partnersClient}) - expect(partnersRequest).toHaveBeenCalledWith(CreateAppQuery, 'token', variables, undefined, undefined, { - type: 'token_refresh', - handler: expect.any(Function), - }) - }) - - test('creates an app with non-launchable defaults', async () => { - // Given - const partnersClient = PartnersClient.getInstance(testPartnersUserSession) - vi.mocked(appNamePrompt).mockResolvedValue('app-name') - vi.mocked(partnersRequest).mockResolvedValueOnce({appCreate: {app: APP1, userErrors: []}}) - const variables = { - org: 1, - title: LOCAL_APP.name, - appUrl: 'https://shopify.dev/apps/default-app-home', - redir: ['https://shopify.dev/apps/default-app-home/api/auth'], - requestedAccessScopes: ['write_products'], - type: 'undecided', - } - - // When - const got = await partnersClient.createApp( - {...ORG1, source: OrganizationSource.Partners}, - { - name: LOCAL_APP.name, - isLaunchable: false, - scopesArray: ['write_products'], - }, - ) - - // Then - expect(got).toEqual({...APP1, newApp: true, developerPlatformClient: partnersClient}) - expect(partnersRequest).toHaveBeenCalledWith(CreateAppQuery, 'token', variables, undefined, undefined, { - type: 'token_refresh', - handler: expect.any(Function), - }) - }) - - test('throws error if requests has a user error', async () => { - // Given - const partnersClient = PartnersClient.getInstance(testPartnersUserSession) - vi.mocked(appNamePrompt).mockResolvedValue('app-name') - vi.mocked(partnersRequest).mockResolvedValueOnce({ - appCreate: {app: {}, userErrors: [{message: 'some-error'}]}, - }) - - // When - const got = partnersClient.createApp({...ORG2, source: OrganizationSource.Partners}, {name: LOCAL_APP.name}) - - // Then - await expect(got).rejects.toThrow(`some-error`) - }) -}) - -describe('fetchApp', async () => { - test('returns fetched apps', async () => { - // Given - const partnersClient = PartnersClient.getInstance(testPartnersUserSession) - vi.mocked(partnersRequest).mockResolvedValue(FETCH_ORG_RESPONSE_VALUE) - const partnerMarkedOrg = {...ORG1, source: 'Partners'} - - // When - const got = await partnersClient.orgAndApps(ORG1.id) - - // Then - expect(got).toEqual({organization: partnerMarkedOrg, apps: [APP1, APP2], hasMorePages: false}) - expect(partnersRequest).toHaveBeenCalledWith(FindOrganizationQuery, 'token', {id: ORG1.id}, undefined, undefined, { - type: 'token_refresh', - handler: expect.any(Function), - }) - }) - - test('throws if there are no organizations', async () => { - // Given - const partnersClient = PartnersClient.getInstance(testPartnersUserSession) - vi.mocked(partnersRequest).mockResolvedValue({organizations: {nodes: []}}) - - // When - const got = () => partnersClient.orgAndApps(ORG1.id) - - // Then - await expect(got).rejects.toThrow('No Organization found') - expect(partnersRequest).toHaveBeenCalledWith(FindOrganizationQuery, 'token', {id: ORG1.id}, undefined, undefined, { - type: 'token_refresh', - handler: expect.any(Function), - }) - }) -}) - describe('PartnersClient', () => { describe('bundleFormat', () => { test('uses zip format', () => { diff --git a/packages/app/src/cli/utilities/developer-platform-client/partners-client.ts b/packages/app/src/cli/utilities/developer-platform-client/partners-client.ts index 8e31833517b..ae56863ed44 100644 --- a/packages/app/src/cli/utilities/developer-platform-client/partners-client.ts +++ b/packages/app/src/cli/utilities/developer-platform-client/partners-client.ts @@ -1,180 +1,33 @@ -import {CreateAppQuery, CreateAppQuerySchema, CreateAppQueryVariables} from '../../api/graphql/create_app.js' -import { - AppVersion, - AppDeployOptions, - AssetUrlSchema, - AppVersionIdentifiers, - DeveloperPlatformClient, - TemplateSpecificationsOptions, - Paginateable, - filterDisabledFlags, - ClientName, - AppVersionWithContext, - CreateAppOptions, - AppLogsResponse, - createUnauthorizedHandler, -} from '../developer-platform-client.js' -import {fetchCurrentAccountInformation} from '../../services/context/partner-account-info.js' -import { - MinimalAppIdentifiers, - MinimalOrganizationApp, - Organization, - OrganizationApp, - OrganizationSource, - OrganizationStore, -} from '../../models/organization.js' -import { - AllAppExtensionRegistrationsQuery, - AllAppExtensionRegistrationsQueryVariables, - AllAppExtensionRegistrationsQuerySchema, -} from '../../api/graphql/all_app_extension_registrations.js' -import { - ActiveAppVersionQuery, - ActiveAppVersionQuerySchema, - ActiveAppVersionQueryVariables, -} from '../../api/graphql/app_active_version.js' -import {AppDeploy, AppDeploySchema, AppDeployVariables} from '../../api/graphql/app_deploy.js' -import { - GenerateSignedUploadUrl, - GenerateSignedUploadUrlSchema, - GenerateSignedUploadUrlVariables, -} from '../../api/graphql/generate_signed_upload_url.js' -import { - FindStoreByDomainQuery, - FindStoreByDomainQueryVariables, - FindStoreByDomainSchema, -} from '../../api/graphql/find_store_by_domain.js' -import {Store} from '../../api/graphql/business-platform-organizations/generated/types.js' -import { - AppVersionsQuery, - AppVersionsQueryVariables, - AppVersionsQuerySchema, -} from '../../api/graphql/get_versions_list.js' -import { - AppVersionsDiffQuery, - AppVersionsDiffSchema, - AppVersionsDiffVariables, -} from '../../api/graphql/app_versions_diff.js' -import {AppRelease, AppReleaseSchema, AppReleaseVariables} from '../../api/graphql/app_release.js' -import { - AppVersionByTagQuery, - AppVersionByTagSchema, - AppVersionByTagVariables, -} from '../../api/graphql/app_version_by_tag.js' -import { - SendSampleWebhookSchema, - SendSampleWebhookVariables, - sendSampleWebhookMutation, -} from '../../services/webhook/request-sample.js' -import {PublicApiVersionsSchema, GetApiVersionsQuery} from '../../services/webhook/request-api-versions.js' -import {WebhookTopicsSchema, WebhookTopicsVariables, getTopicsQuery} from '../../services/webhook/request-topics.js' +import {ClientName, MigrationDeveloperPlatformClient, createUnauthorizedHandler} from '../developer-platform-client.js' +import {OrganizationSource} from '../../models/organization.js' import { MigrateFlowExtensionVariables, MigrateFlowExtensionSchema, MigrateFlowExtensionMutation, } from '../../api/graphql/extension_migrate_flow_extension.js' -import {UpdateURLsVariables, UpdateURLsSchema, UpdateURLsQuery} from '../../api/graphql/update_urls.js' -import {CurrentAccountInfo, CurrentAccountInfoQuery} from '../../api/graphql/partners/generated/current-account-info.js' -import { - RemoteTemplateSpecificationsQuery, - RemoteTemplateSpecificationsSchema, - RemoteTemplateSpecificationsVariables, -} from '../../api/graphql/template_specifications.js' -import {ExtensionTemplatesResult} from '../../models/app/template.js' -import { - TargetSchemaDefinitionQuerySchema, - TargetSchemaDefinitionQuery, -} from '../../api/graphql/functions/target_schema_definition.js' -import { - ApiSchemaDefinitionQuerySchema, - ApiSchemaDefinitionQuery, -} from '../../api/graphql/functions/api_schema_definition.js' import { MigrateToUiExtensionVariables, MigrateToUiExtensionSchema, MigrateToUiExtensionQuery, } from '../../api/graphql/extension_migrate_to_ui_extension.js' -import { - ExtensionSpecificationsQuery, - ExtensionSpecificationsQuerySchema, - ExtensionSpecificationsQueryVariables, - RemoteSpecification, -} from '../../api/graphql/extension_specifications.js' -import { - FindOrganizationBasicQuery, - FindOrganizationBasicQuerySchema, - FindOrganizationBasicVariables, -} from '../../api/graphql/find_org_basic.js' import { MigrateAppModuleMutation, MigrateAppModuleSchema, MigrateAppModuleVariables, } from '../../api/graphql/extension_migrate_app_module.js' -import {AppLogsSubscribeMutation, AppLogsSubscribeResponse} from '../../api/graphql/subscribe_to_app_logs.js' - -import {AllOrgs} from '../../api/graphql/partners/generated/all-orgs.js' -import {FindAppQuery, FindAppQuerySchema, FindAppQueryVariables} from '../../api/graphql/find_app.js' -import { - FindOrganizationQuery, - FindOrganizationQuerySchema, - FindOrganizationQueryVariables, -} from '../../api/graphql/find_org.js' -import {NoOrgError} from '../../services/dev/fetch.js' -import { - DevStoresByOrg, - DevStoresByOrgQuery, - DevStoresByOrgQueryVariables, -} from '../../api/graphql/partners/generated/dev-stores-by-org.js' -import {SchemaDefinitionByTargetQueryVariables} from '../../api/graphql/functions/generated/schema-definition-by-target.js' -import {SchemaDefinitionByApiTypeQueryVariables} from '../../api/graphql/functions/generated/schema-definition-by-api-type.js' -import {AppLogData} from '../../services/app-logs/types.js' -import {AppLogsOptions} from '../../services/app-logs/utils.js' -import {AppLogsSubscribeMutationVariables} from '../../api/graphql/app-management/generated/app-logs-subscribe.js' -import {TypedDocumentNode} from '@graphql-typed-document-node/core' import {isUnitTest} from '@shopify/cli-kit/node/context/local' -import {AbortError} from '@shopify/cli-kit/node/error' -import {generateFetchAppLogUrl, partnersRequest, partnersRequestDoc} from '@shopify/cli-kit/node/api/partners' +import {partnersRequest} from '@shopify/cli-kit/node/api/partners' import {CacheOptions, GraphQLVariables, UnauthorizedHandler} from '@shopify/cli-kit/node/api/graphql' import {ensureAuthenticatedPartners, Session} from '@shopify/cli-kit/node/session' -import {partnersFqdn} from '@shopify/cli-kit/node/context/fqdn' -import {TokenItem} from '@shopify/cli-kit/node/ui' -import {RequestModeInput, Response, shopifyFetch} from '@shopify/cli-kit/node/http' -import {CLI_KIT_VERSION} from '@shopify/cli-kit/common/version' - -// this is a temporary solution for editions to support https://vault.shopify.io/gsd/projects/31406 -// read more here: https://vault.shopify.io/gsd/projects/31406 -const MAGIC_URL = 'https://shopify.dev/apps/default-app-home' -const MAGIC_REDIRECT_URL = 'https://shopify.dev/apps/default-app-home/api/auth' - -function getAppVars(org: Organization, options: CreateAppOptions): CreateAppQueryVariables { - const {name, isLaunchable = true, scopesArray} = options - const defaultAppUrl = isLaunchable ? 'https://example.com' : MAGIC_URL - const defaultRedirectUrl = isLaunchable ? 'https://example.com/api/auth' : MAGIC_REDIRECT_URL - - return { - org: parseInt(org.id, 10), - title: name, - appUrl: defaultAppUrl, - redir: [defaultRedirectUrl], - requestedAccessScopes: scopesArray ?? [], - type: 'undecided', - } -} - -interface OrganizationAppsResponse { - pageInfo: { - hasNextPage: boolean - } - nodes: MinimalOrganizationApp[] -} - -interface OrgAndAppsResponse { - organization: Organization - apps: OrganizationAppsResponse - stores: OrganizationStore[] -} - -export class PartnersClient implements DeveloperPlatformClient { +import {RequestModeInput} from '@shopify/cli-kit/node/http' + +/** + * The Partners-backed client now exists solely to run the legacy extension migrations + * (see {@link MigrationDeveloperPlatformClient}). Every other developer platform operation is + * served by the App Management client, so only the migration mutations and the session/request + * infrastructure they depend on remain here. + */ +export class PartnersClient implements MigrationDeveloperPlatformClient { private static instance: PartnersClient | undefined static getInstance(session?: Session): PartnersClient { @@ -208,8 +61,6 @@ export class PartnersClient implements DeveloperPlatformClient { accountInfo: {type: 'UnknownAccount'}, userId, } - const accountInfo = await fetchCurrentAccountInformation(this, userId) - this._session = {token, businessPlatformToken: '', accountInfo, userId} } return this._session } @@ -230,13 +81,6 @@ export class PartnersClient implements DeveloperPlatformClient { ) } - async requestDoc( - document: TypedDocumentNode, - variables?: TVariables, - ): Promise { - return partnersRequestDoc(document, await this.token(), variables, undefined, this.createUnauthorizedHandler()) - } - async token(): Promise { return (await this.session()).token } @@ -250,255 +94,6 @@ export class PartnersClient implements DeveloperPlatformClient { return session.token } - async accountInfo(): Promise { - return (await this.session()).accountInfo - } - - async appFromIdentifiers(apiKey: string): Promise { - const variables: FindAppQueryVariables = {apiKey} - const res: FindAppQuerySchema = await this.request(FindAppQuery, variables) - const app = res.app - if (app) { - const flags = filterDisabledFlags(app.disabledFlags) - return { - ...app, - flags, - developerPlatformClient: this, - } - } - } - - async organizations(): Promise { - try { - const result = await this.requestDoc(AllOrgs) - return result.organizations.nodes!.map((org) => ({ - id: org!.id, - businessName: `${org!.businessName} (Partner Dashboard)`, - source: this.organizationSource, - })) - } catch (error: unknown) { - if ((error as {statusCode?: number}).statusCode === 404) { - return [] - } else { - throw error - } - } - } - - async orgFromId(orgId: string): Promise { - const variables: FindOrganizationBasicVariables = {id: orgId} - const result: FindOrganizationBasicQuerySchema = await this.request(FindOrganizationBasicQuery, variables, { - cacheTTL: {hours: 6}, - }) - const org: Omit | undefined = result.organizations.nodes[0] - return org ? {...org, source: this.organizationSource} : undefined - } - - async orgAndApps(orgId: string): Promise> { - const result = await this.fetchOrgAndApps(orgId) - return { - organization: result.organization, - apps: result.apps.nodes, - hasMorePages: result.apps.pageInfo.hasNextPage, - } - } - - async appsForOrg(organizationId: string, term?: string): Promise> { - const result = await this.fetchOrgAndApps(organizationId, term) - return { - apps: result.apps.nodes, - hasMorePages: result.apps.pageInfo.hasNextPage, - } - } - - async specifications({apiKey}: MinimalAppIdentifiers): Promise { - const variables: ExtensionSpecificationsQueryVariables = {apiKey} - const result: ExtensionSpecificationsQuerySchema = await this.request(ExtensionSpecificationsQuery, variables) - // Partners API doesn't provide uidStrategy; derive it from experience. - return result.extensionSpecifications.map(({options, features, ...spec}) => ({ - ...spec, - uidStrategy: spec.experience === 'extension' ? 'uuid' : 'single', - registrationLimit: options.registrationLimit, - managementExperience: options.managementExperience, - surface: features?.argo?.surface, - })) - } - - async templateSpecifications( - {apiKey}: MinimalAppIdentifiers, - _options: TemplateSpecificationsOptions = {}, - ): Promise { - const variables: RemoteTemplateSpecificationsVariables = {apiKey} - const result: RemoteTemplateSpecificationsSchema = await this.request(RemoteTemplateSpecificationsQuery, variables) - const templates = result.templateSpecifications.map((template) => { - const {types, ...rest} = template - return { - ...rest, - ...types[0], - } - }) - - let counter = 0 - const templatesWithPriority = templates.map((template) => ({ - ...template, - sortPriority: template.sortPriority ?? counter++, - })) - - const groupOrder: string[] = [] - for (const template of templatesWithPriority) { - if (template.group && !groupOrder.includes(template.group)) { - groupOrder.push(template.group) - } - } - - return { - templates: templatesWithPriority, - groupOrder, - } - } - - async createApp(org: Organization, options: CreateAppOptions): Promise { - const variables: CreateAppQueryVariables = getAppVars(org, options) - const result: CreateAppQuerySchema = await this.request(CreateAppQuery, variables) - if (result.appCreate.userErrors.length > 0) { - const errors = result.appCreate.userErrors.map((error) => error.message).join(', ') - throw new AbortError(errors) - } - - const flags = filterDisabledFlags(result.appCreate.app.disabledFlags) - return {...result.appCreate.app, organizationId: org.id, newApp: true, flags, developerPlatformClient: this} - } - - async devStoresForOrg(orgId: string): Promise> { - const variables: DevStoresByOrgQueryVariables = {id: orgId} - const result: DevStoresByOrgQuery = await this.requestDoc(DevStoresByOrg, variables) - return { - stores: result.organizations.nodes![0]!.stores.nodes as OrganizationStore[], - hasMorePages: false, - } - } - - async appExtensionRegistrations( - {apiKey}: MinimalAppIdentifiers, - _activeAppVersion?: AppVersion, - ): Promise { - const variables: AllAppExtensionRegistrationsQueryVariables = {apiKey} - return this.request(AllAppExtensionRegistrationsQuery, variables) - } - - async appVersions({apiKey}: OrganizationApp): Promise { - const variables: AppVersionsQueryVariables = {apiKey} - return this.request(AppVersionsQuery, variables) - } - - async appInstallCount(_app: MinimalAppIdentifiers): Promise { - // Install count is not supported in partners client. - throw new Error('Unsupported operation') - } - - async appVersionByTag({apiKey}: MinimalOrganizationApp, versionTag: string): Promise { - const input: AppVersionByTagVariables = {apiKey, versionTag} - const result: AppVersionByTagSchema = await this.request(AppVersionByTagQuery, input) - const appVersion = result.app.appVersion - return { - ...appVersion, - appModuleVersions: appVersion.appModuleVersions.map((appModuleVersion) => ({ - ...appModuleVersion, - config: appModuleVersion.config ? JSON.parse(appModuleVersion.config) : undefined, - })), - } - } - - async appVersionsDiff( - {apiKey}: MinimalOrganizationApp, - {appVersionId}: AppVersionIdentifiers, - ): Promise { - const variables: AppVersionsDiffVariables = {apiKey, versionId: appVersionId} - return this.request(AppVersionsDiffQuery, variables) - } - - async activeAppVersion({apiKey}: MinimalAppIdentifiers): Promise { - const variables: ActiveAppVersionQueryVariables = {apiKey} - const result = await this.request(ActiveAppVersionQuery, variables) - const version = result.app.activeAppVersion - if (!version) return - return { - ...version, - appModuleVersions: version.appModuleVersions.map((mod) => { - return { - ...mod, - config: mod.config ? (JSON.parse(mod.config) as object) : {}, - } - }), - } - } - - async deploy(deployInput: AppDeployOptions): Promise { - const {organizationId, ...deployOptions} = deployInput - // Enforce the type - const variables: AppDeployVariables = deployOptions - // Exclude uid - variables.appModules = variables.appModules?.map((element) => { - const {uid, ...otherFields} = element - return otherFields - }) - return this.request(AppDeploy, variables, undefined, 'slow-request') - } - - async release({ - app: {apiKey}, - version: {appVersionId}, - }: { - app: MinimalOrganizationApp - version: AppVersionIdentifiers - }): Promise { - const input: AppReleaseVariables = {apiKey, appVersionId} - return this.request(AppRelease, input) - } - - async generateSignedUploadUrl(app: MinimalAppIdentifiers): Promise { - const variables: GenerateSignedUploadUrlVariables = {apiKey: app.apiKey, bundleFormat: 1} - const result = await this.request(GenerateSignedUploadUrl, variables) - return { - assetUrl: result.appVersionGenerateSignedUploadUrl.signedUploadUrl, - userErrors: result.appVersionGenerateSignedUploadUrl.userErrors, - } - } - - async storeByDomain(orgId: string, shopDomain: string, _storeTypes: Store[]): Promise { - // Note: storeTypes filtering not implemented for PartnersClient - const variables: FindStoreByDomainQueryVariables = {orgId, shopDomain} - const result: FindStoreByDomainSchema = await this.request(FindStoreByDomainQuery, variables) - - const node = result.organizations.nodes[0]?.stores.nodes[0] - if (!node) { - return undefined - } - return { - ...node, - provisionable: false, - } - } - - async ensureUserAccessToStore(_orgId: string, _store: OrganizationStore): Promise { - // This is a no-op for partners - } - - async sendSampleWebhook( - input: SendSampleWebhookVariables, - _organizationId: string, - ): Promise { - return this.request(sendSampleWebhookMutation, input) - } - - async apiVersions(_organizationId: string): Promise { - return this.request(GetApiVersionsQuery) - } - - async topics(input: WebhookTopicsVariables, _organizationId: string): Promise { - return this.request(getTopicsQuery, input) - } - async migrateFlowExtension(input: MigrateFlowExtensionVariables): Promise { return this.request(MigrateFlowExtensionMutation, input) } @@ -507,153 +102,11 @@ export class PartnersClient implements DeveloperPlatformClient { return this.request(MigrateAppModuleMutation, input) } - async updateURLs(input: UpdateURLsVariables): Promise { - return this.request(UpdateURLsQuery, input) - } - - async currentAccountInfo(): Promise { - return this.requestDoc(CurrentAccountInfo) - } - - async targetSchemaDefinition( - input: SchemaDefinitionByTargetQueryVariables, - apiKey: string, - _organizationId: string, - ): Promise { - // Ensures compatibility with existing partners requests - // Can remove once migrated to AMF - const transformedInput = { - target: input.handle, - version: input.version, - apiKey, - } - - const response: TargetSchemaDefinitionQuerySchema = await this.request( - TargetSchemaDefinitionQuery, - transformedInput, - ) - return response.definition - } - - async apiSchemaDefinition( - input: SchemaDefinitionByApiTypeQueryVariables & {apiKey?: string}, - apiKey: string, - _organizationId: string, - _appId?: string, - ): Promise { - const response: ApiSchemaDefinitionQuerySchema = await this.request(ApiSchemaDefinitionQuery, { - ...input, - apiKey, - }) - return response.definition - } - async migrateToUiExtension(input: MigrateToUiExtensionVariables): Promise { return this.request(MigrateToUiExtensionQuery, input) } - toExtensionGraphQLType(input: string) { - return input.toUpperCase() - } - - async subscribeToAppLogs( - input: AppLogsSubscribeMutationVariables, - _organizationId: string, - ): Promise { - return this.request(AppLogsSubscribeMutation, input) - } - - async appDeepLink({id, organizationId}: MinimalAppIdentifiers): Promise { - return `https://${await partnersFqdn()}/${organizationId}/apps/${id}` - } - - async appLogs(options: AppLogsOptions, _organizationId: string): Promise { - const response = await fetchAppLogs(options) - - try { - const data = (await response.json()) as { - app_logs?: AppLogData[] - cursor?: string - errors?: string[] - } - - if (!response.ok) { - return { - errors: data.errors ?? [`Request failed with status ${response.status}`], - status: response.status, - } - } - - return { - app_logs: data.app_logs ?? [], - cursor: data.cursor, - status: response.status, - } - // eslint-disable-next-line no-catch-all/no-catch-all - } catch (error) { - return { - errors: [`Failed to parse response: ${error}`], - status: response.status, - } - } - } - - async devSessionCreate(_input: unknown): Promise { - // Dev Sessions are not supported in partners client. - throw new Error('Unsupported operation') - } - - async devSessionUpdate(_input: unknown): Promise { - // Dev Sessions are not supported in partners client. - throw new Error('Unsupported operation') - } - - // eslint-disable-next-line @typescript-eslint/no-explicit-any - async devSessionDelete(_input: unknown): Promise { - // Dev Sessions are not supported in partners client. - return Promise.resolve() - } - - async getCreateDevStoreLink(org: Organization): Promise { - const url = `https://${await partnersFqdn()}/${org.id}/stores` - return [ - `Looks like you don't have any dev stores associated with ${org.businessName}'s Partner Dashboard.`, - {link: {url, label: 'Create a store in Partner Dashboard'}}, - ] - } - - private async fetchOrgAndApps(orgId: string, title?: string): Promise { - const params: FindOrganizationQueryVariables = {id: orgId} - if (title) params.title = title - const result: FindOrganizationQuerySchema = await this.request(FindOrganizationQuery, params) - const org = result.organizations.nodes[0] - if (!org) { - const partnersSession = await this.session() - throw new NoOrgError(partnersSession.accountInfo, orgId) - } - const parsedOrg = {id: org.id, businessName: org.businessName, source: this.organizationSource} - const appsWithOrg = org.apps.nodes.map((app) => ({...app, organizationId: org.id})) - return {organization: parsedOrg, apps: {...org.apps, nodes: appsWithOrg}, stores: []} - } - private createUnauthorizedHandler(): UnauthorizedHandler { return createUnauthorizedHandler(this) } } - -const fetchAppLogs = async ({jwtToken, cursor, filters}: AppLogsOptions): Promise => { - const url = await generateFetchAppLogUrl(cursor, filters) - const userAgent = `Shopify CLI; v=${CLI_KIT_VERSION}` - const headers = { - Authorization: `Bearer ${jwtToken}`, - 'User-Agent': userAgent, - } - return shopifyFetch( - url, - { - method: 'GET', - headers, - }, - 'non-blocking', - ) -} diff --git a/packages/cli-kit/src/public/node/api/partners.ts b/packages/cli-kit/src/public/node/api/partners.ts index bb1f00766a1..1d952ccf23a 100644 --- a/packages/cli-kit/src/public/node/api/partners.ts +++ b/packages/cli-kit/src/public/node/api/partners.ts @@ -1,4 +1,3 @@ -import {addCursorAndFiltersToAppLogsUrl} from './utilities.js' import { graphqlRequest, GraphQLVariables, @@ -78,18 +77,6 @@ export async function partnersRequest( return result } -export const generateFetchAppLogUrl = async ( - cursor?: string, - filters?: { - status?: string - source?: string - }, -): Promise => { - const fqdn = await partnersFqdn() - const url = `https://${fqdn}/app_logs/poll` - return addCursorAndFiltersToAppLogsUrl(url, cursor, filters) -} - /** * Executes a GraphQL query against the Partners API. Uses typed documents. * diff --git a/packages/eslint-plugin-cli/rules/no-inline-graphql.js b/packages/eslint-plugin-cli/rules/no-inline-graphql.js index 8959ccda80b..6184e3edbf6 100644 --- a/packages/eslint-plugin-cli/rules/no-inline-graphql.js +++ b/packages/eslint-plugin-cli/rules/no-inline-graphql.js @@ -116,20 +116,10 @@ module.exports = { } const knownFailures = { - 'packages/app/src/cli/api/graphql/all_app_extension_registrations.ts': - 'bbde8b08d13bdeeab3d586ffd76c75cfea31c5891ac9a0f957a7a273d520e9e2', 'packages/app/src/cli/api/graphql/all_dev_stores_by_org.ts': 'f48a44e2dae39f1b33ac685971740e3705f2754de5fdf1d6f1fbb3492bc62be2', - 'packages/app/src/cli/api/graphql/app_active_version.ts': - '685d858cf3ad636fe8d771707715dd9a793e4aa4529f843eac3df625efd4d5be', - 'packages/app/src/cli/api/graphql/app_release.ts': '3acace031157856c88dc57506d81364c084fb5ca66ab5c6ff59393ab5255846d', - 'packages/app/src/cli/api/graphql/app_version_by_tag.ts': - 'a3231389ceb20eec4cab51186678b032e52d8f3e4df3078ce1a33c8ae83ac7fa', - 'packages/app/src/cli/api/graphql/app_versions_diff.ts': - '233e2abb837d4cad52e985b373784314129163bf530a6caa501af2b711717b09', 'packages/app/src/cli/api/graphql/convert_dev_to_transfer_disabled_store.ts': '0261459f988f5ba947ba52dc90dd049032196595cad5be8b7042ad1d0a22277c', - 'packages/app/src/cli/api/graphql/create_app.ts': '13fdc528f39a5e6d589c7834e03f916528f00b431e69b8148c6237229be1dc2c', 'packages/app/src/cli/api/graphql/current_account_info.ts': 'e25977539cec28a33c0c32c75973ac5a78e3b4b5e504aa3d14d01291c5b42c14', 'packages/app/src/cli/api/graphql/development_preview.ts': @@ -142,33 +132,10 @@ const knownFailures = { '812944a456b2ae439ebb01a97c19e3e0c445157dd3578bc48b0a8c4cebb6e12e', 'packages/app/src/cli/api/graphql/extension_migrate_to_ui_extension.ts': 'dd3fb42d0b9327de627bd02295de9e08087266885777602a34b44bdc460c0285', - 'packages/app/src/cli/api/graphql/extension_specifications.ts': - '9a3dff21a92b5910a29f4893faef35a549a08f5675f67407cc415b10ba7091a3', - 'packages/app/src/cli/api/graphql/find_app.ts': '699def43534d0fdb4988b91e74a890778026960fd31662fecd86384ecfc05370', 'packages/app/src/cli/api/graphql/find_app_preview_mode.ts': '8311925b338d4aba1957974bb815cfa8c5d8272226f68b8e74a69d91acc9c8cb', - 'packages/app/src/cli/api/graphql/find_org.ts': 'f434cae80f3799cadc482ae22b0544c6f1d1171127943163d6e85e3a6b94c992', - 'packages/app/src/cli/api/graphql/find_org_basic.ts': - '867f01113c20386d6a438dd56a6d241199e407eab928ab1ad9a7f233cd35c1be', - 'packages/app/src/cli/api/graphql/find_store_by_domain.ts': - '0824f5baaab1ad419a7fa1d64824e306bd369430da47c7457ed72e74a1e94a9a', - 'packages/app/src/cli/api/graphql/functions/api_schema_definition.ts': - 'e71100cf61919831681da1be8f12cd9067c4e3f2faf04c1b88b764fd8a275b82', - 'packages/app/src/cli/api/graphql/functions/target_schema_definition.ts': - 'd338c5d187ca8a1e1e68892987d780e540426faeba89df2dd9d8c96e193f5c13', - 'packages/app/src/cli/api/graphql/generate_signed_upload_url.ts': - '848e40bf6b44331de0fe1dc1b0753593c1d47f9705ebe988a1b8ad5638d267ef', 'packages/app/src/cli/api/graphql/get_variant_id.ts': '805a7d8fb4b66ae23dc45cc37d401350c3d8eab4e262bd90e70afceb48be10de', - 'packages/app/src/cli/api/graphql/get_versions_list.ts': - '36b6f90c6687ba50b84b31de9fa28b4e9d0cadb732cab6c0d83664b627f2969d', - 'packages/app/src/cli/api/graphql/subscribe_to_app_logs.ts': - '47ba882dc6bb2487cf6d047aa1f4b45c2eed96017faf80af45f8f954017983bf', - 'packages/app/src/cli/api/graphql/template_specifications.ts': - '7c9ce345b6cfce9292b7221e1b24205c3a3276495e0516da504de45c386567ae', - 'packages/app/src/cli/api/graphql/update_urls.ts': '37d20c418982a4bc4eed047ec48f52d93be1a0e59f1d905911b8519ab3adb5a4', - 'packages/app/src/cli/services/webhook/request-sample.ts': - '05dd159152c528d7e785ef3476f6dbfca0be25046ce06584d5fd2ea89a23ed16', 'packages/app/src/cli/utilities/developer-platform-client/app-management-client/graphql/active-app-release.ts': 'e1998153a015f9a7bb392aab6788a10a9afe76220eeb4515e958e679ec667ed1', 'packages/app/src/cli/utilities/developer-platform-client/app-management-client/graphql/app-version-by-id.ts':