@shopify/cli-kit 3.78.2 → 3.79.1

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 (73) hide show
  1. package/dist/private/node/analytics.d.ts +1 -0
  2. package/dist/private/node/analytics.js +2 -0
  3. package/dist/private/node/analytics.js.map +1 -1
  4. package/dist/private/node/session/exchange.d.ts +20 -2
  5. package/dist/private/node/session/exchange.js +36 -9
  6. package/dist/private/node/session/exchange.js.map +1 -1
  7. package/dist/private/node/session/scopes.d.ts +6 -0
  8. package/dist/private/node/session/scopes.js +17 -0
  9. package/dist/private/node/session/scopes.js.map +1 -1
  10. package/dist/private/node/ui/components/TextAnimation.js +8 -3
  11. package/dist/private/node/ui/components/TextAnimation.js.map +1 -1
  12. package/dist/public/common/array.d.ts +19 -0
  13. package/dist/public/common/array.js +33 -0
  14. package/dist/public/common/array.js.map +1 -1
  15. package/dist/public/common/object.d.ts +11 -3
  16. package/dist/public/common/object.js +11 -0
  17. package/dist/public/common/object.js.map +1 -1
  18. package/dist/public/common/version.d.ts +1 -1
  19. package/dist/public/common/version.js +1 -1
  20. package/dist/public/common/version.js.map +1 -1
  21. package/dist/public/node/api/app-management.d.ts +6 -1
  22. package/dist/public/node/api/app-management.js +3 -1
  23. package/dist/public/node/api/app-management.js.map +1 -1
  24. package/dist/public/node/api/business-platform.d.ts +2 -2
  25. package/dist/public/node/api/business-platform.js.map +1 -1
  26. package/dist/public/node/api/graphql.d.ts +2 -0
  27. package/dist/public/node/api/graphql.js +1 -1
  28. package/dist/public/node/api/graphql.js.map +1 -1
  29. package/dist/public/node/api/partners.d.ts +5 -2
  30. package/dist/public/node/api/partners.js +6 -2
  31. package/dist/public/node/api/partners.js.map +1 -1
  32. package/dist/public/node/context/local.d.ts +0 -7
  33. package/dist/public/node/context/local.js +0 -10
  34. package/dist/public/node/context/local.js.map +1 -1
  35. package/dist/public/node/environment.js +2 -2
  36. package/dist/public/node/environment.js.map +1 -1
  37. package/dist/public/node/error-handler.js +4 -0
  38. package/dist/public/node/error-handler.js.map +1 -1
  39. package/dist/public/node/github.js +1 -1
  40. package/dist/public/node/github.js.map +1 -1
  41. package/dist/public/node/hidden-folder.d.ts +8 -0
  42. package/dist/public/node/hidden-folder.js +27 -0
  43. package/dist/public/node/hidden-folder.js.map +1 -0
  44. package/dist/public/node/http.d.ts +1 -1
  45. package/dist/public/node/http.js.map +1 -1
  46. package/dist/public/node/is-global.d.ts +0 -6
  47. package/dist/public/node/is-global.js +4 -20
  48. package/dist/public/node/is-global.js.map +1 -1
  49. package/dist/public/node/monorail.d.ts +1 -1
  50. package/dist/public/node/monorail.js +1 -1
  51. package/dist/public/node/monorail.js.map +1 -1
  52. package/dist/public/node/multiple-installation-warning.d.ts +10 -0
  53. package/dist/public/node/multiple-installation-warning.js +45 -0
  54. package/dist/public/node/multiple-installation-warning.js.map +1 -0
  55. package/dist/public/node/notifications-system.js +13 -11
  56. package/dist/public/node/notifications-system.js.map +1 -1
  57. package/dist/public/node/session.d.ts +1 -0
  58. package/dist/public/node/session.js +11 -1
  59. package/dist/public/node/session.js.map +1 -1
  60. package/dist/public/node/system.d.ts +6 -0
  61. package/dist/public/node/system.js +9 -0
  62. package/dist/public/node/system.js.map +1 -1
  63. package/dist/public/node/tcp.js +10 -1
  64. package/dist/public/node/tcp.js.map +1 -1
  65. package/dist/public/node/themes/api.js +1 -1
  66. package/dist/public/node/themes/api.js.map +1 -1
  67. package/dist/public/node/ui/components.d.ts +1 -0
  68. package/dist/public/node/ui/components.js +1 -0
  69. package/dist/public/node/ui/components.js.map +1 -1
  70. package/dist/public/node/version.js +13 -4
  71. package/dist/public/node/version.js.map +1 -1
  72. package/dist/tsconfig.tsbuildinfo +1 -1
  73. package/package.json +2 -1
@@ -21,6 +21,7 @@ interface EnvironmentData {
21
21
  env_package_manager: string;
22
22
  env_is_global: boolean;
23
23
  env_auth_method: string;
24
+ env_is_wsl: boolean;
24
25
  }
25
26
  export declare function getEnvironmentData(config: Interfaces.Config): Promise<EnvironmentData>;
26
27
  export declare function getSensitiveEnvironmentData(config: Interfaces.Config): Promise<{
@@ -6,6 +6,7 @@ import { platformAndArch } from '../../public/node/os.js';
6
6
  import { ciPlatform, cloudEnvironment, macAddress } from '@shopify/cli-kit/node/context/local';
7
7
  import { cwd } from '@shopify/cli-kit/node/path';
8
8
  import { currentProcessIsGlobal } from '@shopify/cli-kit/node/is-global';
9
+ import { isWsl } from '@shopify/cli-kit/node/system';
9
10
  export async function startAnalytics({ commandContent, args, currentTime = new Date().getTime(), commandClass, }) {
10
11
  let startCommand = commandContent.command;
11
12
  if (commandClass && Object.prototype.hasOwnProperty.call(commandClass, 'analyticsNameOverride')) {
@@ -48,6 +49,7 @@ export async function getEnvironmentData(config) {
48
49
  env_package_manager: await getPackageManager(cwd()),
49
50
  env_is_global: currentProcessIsGlobal(),
50
51
  env_auth_method: await getLastSeenAuthMethod(),
52
+ env_is_wsl: await isWsl(),
51
53
  };
52
54
  }
53
55
  export async function getSensitiveEnvironmentData(config) {
@@ -1 +1 @@
1
- {"version":3,"file":"analytics.js","sourceRoot":"","sources":["../../../src/private/node/analytics.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,qBAAqB,EAAC,MAAM,cAAc,CAAA;AAClD,OAAO,EAAC,UAAU,EAAC,MAAM,6BAA6B,CAAA;AACtD,OAAO,EAAC,iBAAiB,EAAE,2BAA2B,EAAC,MAAM,2CAA2C,CAAA;AAGxG,OAAO,KAAK,QAAQ,MAAM,+BAA+B,CAAA;AACzD,OAAO,EAAC,eAAe,EAAC,MAAM,yBAAyB,CAAA;AAEvD,OAAO,EAAC,UAAU,EAAE,gBAAgB,EAAE,UAAU,EAAC,MAAM,qCAAqC,CAAA;AAC5F,OAAO,EAAC,GAAG,EAAC,MAAM,4BAA4B,CAAA;AAC9C,OAAO,EAAC,sBAAsB,EAAC,MAAM,iCAAiC,CAAA;AAStE,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,EACnC,cAA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;AAC7E,CAAC;AAED,SAAS,YAAY,CAAC,IAAY,EAAE,YAAiD;IACnF,IAAI,CAAC,YAAY;QAAE,OAAO,KAAK,CAAA;IAE/B,MAAM,YAAY,GAAG,YAAY,CAAC,KAAK,IAAI,EAAE,CAAA;IAC7C,OAAO,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAA;AACjD,CAAC","sourcesContent":["import {getLastSeenAuthMethod} from './session.js'\nimport {hashString} from '../../public/node/crypto.js'\nimport {getPackageManager, packageManagerFromUserAgent} from '../../public/node/node-package-manager.js'\nimport BaseCommand from '../../public/node/base-command.js'\nimport {CommandContent} from '../../public/node/hooks/prerun.js'\nimport * as metadata from '../../public/node/metadata.js'\nimport {platformAndArch} from '../../public/node/os.js'\nimport {Command, Interfaces} from '@oclif/core'\nimport {ciPlatform, cloudEnvironment, macAddress} from '@shopify/cli-kit/node/context/local'\nimport {cwd} from '@shopify/cli-kit/node/path'\nimport {currentProcessIsGlobal} from '@shopify/cli-kit/node/is-global'\n\ninterface StartOptions {\n commandContent: CommandContent\n args: string[]\n currentTime?: number\n commandClass?: Command.Class | typeof BaseCommand\n}\n\nexport async function startAnalytics({\n commandContent,\n args,\n currentTime = new Date().getTime(),\n commandClass,\n}: StartOptions): Promise<void> {\n let startCommand: string = commandContent.command\n if (commandClass && Object.prototype.hasOwnProperty.call(commandClass, 'analyticsNameOverride')) {\n startCommand = (commandClass as typeof BaseCommand).analyticsNameOverride() ?? commandContent.command\n }\n\n let pluginName = commandClass?.plugin?.name\n if (commandClass && 'customPluginName' in commandClass) {\n pluginName = commandClass.customPluginName as string\n }\n\n await metadata.addSensitiveMetadata(() => ({\n commandStartOptions: {\n startTime: currentTime,\n startCommand,\n startArgs: args,\n },\n }))\n\n await metadata.addPublicMetadata(() => ({\n cmd_all_launcher: packageManagerFromUserAgent(),\n cmd_all_alias_used: commandContent.alias,\n cmd_all_topic: commandContent.topic,\n cmd_all_plugin: pluginName,\n cmd_all_force: flagIncluded('force', commandClass) ? args.includes('--force') : undefined,\n }))\n}\n\ninterface EnvironmentData {\n uname: string\n env_ci: boolean\n env_ci_platform?: string\n env_plugin_installed_any_custom: boolean\n env_plugin_installed_shopify: string\n env_shell: string\n env_web_ide: string | undefined\n env_device_id: string\n env_cloud: string\n env_package_manager: string\n env_is_global: boolean\n env_auth_method: string\n}\n\nexport async function getEnvironmentData(config: Interfaces.Config): Promise<EnvironmentData> {\n const ciplatform = ciPlatform()\n\n const pluginNames = getPluginNames(config)\n const shopifyPlugins = pluginNames.filter((plugin) => plugin.startsWith('@shopify/'))\n\n const {platform, arch} = platformAndArch()\n\n return {\n uname: `${platform} ${arch}`,\n env_ci: ciplatform.isCI,\n env_ci_platform: ciplatform.name,\n env_plugin_installed_any_custom: pluginNames.length !== shopifyPlugins.length,\n env_plugin_installed_shopify: JSON.stringify(shopifyPlugins),\n env_shell: config.shell,\n env_web_ide: cloudEnvironment().editor ? cloudEnvironment().platform : undefined,\n env_device_id: hashString(await macAddress()),\n env_cloud: cloudEnvironment().platform,\n env_package_manager: await getPackageManager(cwd()),\n env_is_global: currentProcessIsGlobal(),\n env_auth_method: await getLastSeenAuthMethod(),\n }\n}\n\nexport async function getSensitiveEnvironmentData(config: Interfaces.Config) {\n return {\n env_plugin_installed_all: JSON.stringify(getPluginNames(config)),\n }\n}\n\nfunction getPluginNames(config: Interfaces.Config) {\n const pluginNames = [...config.plugins.keys()]\n return pluginNames.sort().filter((plugin) => !plugin.startsWith('@oclif/'))\n}\n\nfunction flagIncluded(flag: string, commandClass?: Command.Class | typeof BaseCommand) {\n if (!commandClass) return false\n\n const commandFlags = commandClass.flags ?? {}\n return Object.keys(commandFlags).includes(flag)\n}\n"]}
1
+ {"version":3,"file":"analytics.js","sourceRoot":"","sources":["../../../src/private/node/analytics.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,qBAAqB,EAAC,MAAM,cAAc,CAAA;AAClD,OAAO,EAAC,UAAU,EAAC,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C,eAAe,EAAE,MAAM,qBAAqB,EAAE;QAC9C,UAAU,EAAE,MAAM,KAAK,EAAE;KAC1B,CAAA;AACH,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,2BAA2B,CAAC,MAAyB;IACzE,OAAO;QACL,wBAAwB,EAAE,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;KACjE,CAAA;AACH,CAAC;AAED,SAAS,cAAc,CAAC,MAAyB;IAC/C,MAAM,WAAW,GAAG,CAAC,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAA;IAC9C,OAAO,WAAW,CAAC,IAAI,EAAE,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,CAAA;AAC7E,CAAC;AAED,SAAS,YAAY,CAAC,IAAY,EAAE,YAAiD;IACnF,IAAI,CAAC,YAAY;QAAE,OAAO,KAAK,CAAA;IAE/B,MAAM,YAAY,GAAG,YAAY,CAAC,KAAK,IAAI,EAAE,CAAA;IAC7C,OAAO,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAA;AACjD,CAAC","sourcesContent":["import {getLastSeenAuthMethod} from './session.js'\nimport {hashString} from '../../public/node/crypto.js'\nimport {getPackageManager, packageManagerFromUserAgent} from '../../public/node/node-package-manager.js'\nimport BaseCommand from '../../public/node/base-command.js'\nimport {CommandContent} from '../../public/node/hooks/prerun.js'\nimport * as metadata from '../../public/node/metadata.js'\nimport {platformAndArch} from '../../public/node/os.js'\nimport {Command, Interfaces} from '@oclif/core'\nimport {ciPlatform, cloudEnvironment, macAddress} from '@shopify/cli-kit/node/context/local'\nimport {cwd} from '@shopify/cli-kit/node/path'\nimport {currentProcessIsGlobal} from '@shopify/cli-kit/node/is-global'\nimport {isWsl} from '@shopify/cli-kit/node/system'\n\ninterface StartOptions {\n commandContent: CommandContent\n args: string[]\n currentTime?: number\n commandClass?: Command.Class | typeof BaseCommand\n}\n\nexport async function startAnalytics({\n commandContent,\n args,\n currentTime = new Date().getTime(),\n commandClass,\n}: StartOptions): Promise<void> {\n let startCommand: string = commandContent.command\n if (commandClass && Object.prototype.hasOwnProperty.call(commandClass, 'analyticsNameOverride')) {\n startCommand = (commandClass as typeof BaseCommand).analyticsNameOverride() ?? commandContent.command\n }\n\n let pluginName = commandClass?.plugin?.name\n if (commandClass && 'customPluginName' in commandClass) {\n pluginName = commandClass.customPluginName as string\n }\n\n await metadata.addSensitiveMetadata(() => ({\n commandStartOptions: {\n startTime: currentTime,\n startCommand,\n startArgs: args,\n },\n }))\n\n await metadata.addPublicMetadata(() => ({\n cmd_all_launcher: packageManagerFromUserAgent(),\n cmd_all_alias_used: commandContent.alias,\n cmd_all_topic: commandContent.topic,\n cmd_all_plugin: pluginName,\n cmd_all_force: flagIncluded('force', commandClass) ? args.includes('--force') : undefined,\n }))\n}\n\ninterface EnvironmentData {\n uname: string\n env_ci: boolean\n env_ci_platform?: string\n env_plugin_installed_any_custom: boolean\n env_plugin_installed_shopify: string\n env_shell: string\n env_web_ide: string | undefined\n env_device_id: string\n env_cloud: string\n env_package_manager: string\n env_is_global: boolean\n env_auth_method: string\n env_is_wsl: boolean\n}\n\nexport async function getEnvironmentData(config: Interfaces.Config): Promise<EnvironmentData> {\n const ciplatform = ciPlatform()\n\n const pluginNames = getPluginNames(config)\n const shopifyPlugins = pluginNames.filter((plugin) => plugin.startsWith('@shopify/'))\n\n const {platform, arch} = platformAndArch()\n\n return {\n uname: `${platform} ${arch}`,\n env_ci: ciplatform.isCI,\n env_ci_platform: ciplatform.name,\n env_plugin_installed_any_custom: pluginNames.length !== shopifyPlugins.length,\n env_plugin_installed_shopify: JSON.stringify(shopifyPlugins),\n env_shell: config.shell,\n env_web_ide: cloudEnvironment().editor ? cloudEnvironment().platform : undefined,\n env_device_id: hashString(await macAddress()),\n env_cloud: cloudEnvironment().platform,\n env_package_manager: await getPackageManager(cwd()),\n env_is_global: currentProcessIsGlobal(),\n env_auth_method: await getLastSeenAuthMethod(),\n env_is_wsl: await isWsl(),\n }\n}\n\nexport async function getSensitiveEnvironmentData(config: Interfaces.Config) {\n return {\n env_plugin_installed_all: JSON.stringify(getPluginNames(config)),\n }\n}\n\nfunction getPluginNames(config: Interfaces.Config) {\n const pluginNames = [...config.plugins.keys()]\n return pluginNames.sort().filter((plugin) => !plugin.startsWith('@oclif/'))\n}\n\nfunction flagIncluded(flag: string, commandClass?: Command.Class | typeof BaseCommand) {\n if (!commandClass) return false\n\n const commandFlags = commandClass.flags ?? {}\n return Object.keys(commandFlags).includes(flag)\n}\n"]}
@@ -26,15 +26,33 @@ export declare function exchangeAccessForApplicationTokens(identityToken: Identi
26
26
  */
27
27
  export declare function refreshAccessToken(currentToken: IdentityToken): Promise<IdentityToken>;
28
28
  /**
29
- * Given a custom CLI token passed as ENV variable, request a valid partners API token
29
+ * Given a custom CLI token passed as ENV variable, request a valid Partners API token
30
30
  * This token does not accept extra scopes, just the cli one.
31
- * @param token - The CLI token passed as ENV variable
31
+ * @param token - The CLI token passed as ENV variable `SHOPIFY_CLI_PARTNERS_TOKEN`
32
32
  * @returns An instance with the application access tokens.
33
33
  */
34
34
  export declare function exchangeCustomPartnerToken(token: string): Promise<{
35
35
  accessToken: string;
36
36
  userId: string;
37
37
  }>;
38
+ /**
39
+ * Given a custom CLI token passed as ENV variable, request a valid App Management API token
40
+ * @param token - The CLI token passed as ENV variable `SHOPIFY_CLI_PARTNERS_TOKEN`
41
+ * @returns An instance with the application access tokens.
42
+ */
43
+ export declare function exchangeCliTokenForAppManagementAccessToken(token: string): Promise<{
44
+ accessToken: string;
45
+ userId: string;
46
+ }>;
47
+ /**
48
+ * Given a custom CLI token passed as ENV variable, request a valid Business Platform API token
49
+ * @param token - The CLI token passed as ENV variable `SHOPIFY_CLI_PARTNERS_TOKEN`
50
+ * @returns An instance with the application access tokens.
51
+ */
52
+ export declare function exchangeCliTokenForBusinessPlatformAccessToken(token: string): Promise<{
53
+ accessToken: string;
54
+ userId: string;
55
+ }>;
38
56
  type IdentityDeviceError = 'authorization_pending' | 'access_denied' | 'expired_token' | 'slow_down' | 'unknown_failure';
39
57
  /**
40
58
  * Given a deviceCode obtained after starting a device identity flow, request an identity token.
@@ -1,9 +1,9 @@
1
1
  import { applicationId, clientId as getIdentityClientId } from './identity.js';
2
+ import { tokenExchangeScopes } from './scopes.js';
2
3
  import { identityFqdn } from '../../../public/node/context/fqdn.js';
3
4
  import { shopifyFetch } from '../../../public/node/http.js';
4
5
  import { err, ok } from '../../../public/node/result.js';
5
6
  import { AbortError, BugError, ExtendableError } from '../../../public/node/error.js';
6
- import { isAppManagementDisabled } from '../../../public/node/context/local.js';
7
7
  import { setLastSeenAuthMethod, setLastSeenUserIdAfterAuth } from '../session.js';
8
8
  import * as jose from 'jose';
9
9
  import { nonRandomUUID } from '@shopify/cli-kit/node/crypto';
@@ -26,7 +26,7 @@ export async function exchangeAccessForApplicationTokens(identityToken, scopes,
26
26
  requestAppToken('storefront-renderer', token, scopes.storefront),
27
27
  requestAppToken('business-platform', token, scopes.businessPlatform),
28
28
  store ? requestAppToken('admin', token, scopes.admin, store) : {},
29
- isAppManagementDisabled() ? {} : requestAppToken('app-management', token, scopes.appManagement),
29
+ requestAppToken('app-management', token, scopes.appManagement),
30
30
  ]);
31
31
  return {
32
32
  ...partners,
@@ -52,15 +52,16 @@ export async function refreshAccessToken(currentToken) {
52
52
  return buildIdentityToken(value, currentToken.userId);
53
53
  }
54
54
  /**
55
- * Given a custom CLI token passed as ENV variable, request a valid partners API token
56
- * This token does not accept extra scopes, just the cli one.
57
- * @param token - The CLI token passed as ENV variable
55
+ * Given a custom CLI token passed as ENV variable request a valid API access token
56
+ * @param token - The CLI token passed as ENV variable `SHOPIFY_CLI_PARTNERS_TOKEN`
57
+ * @param apiName - The API to exchange for the access token
58
+ * @param scopes - The scopes to request with the access token
58
59
  * @returns An instance with the application access tokens.
59
60
  */
60
- export async function exchangeCustomPartnerToken(token) {
61
- const appId = applicationId('partners');
61
+ async function exchangeCliTokenForAccessToken(apiName, token, scopes) {
62
+ const appId = applicationId(apiName);
62
63
  try {
63
- const newToken = await requestAppToken('partners', token, ['https://api.shopify.com/auth/partners.app.cli.access']);
64
+ const newToken = await requestAppToken(apiName, token, scopes);
64
65
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
65
66
  const accessToken = newToken[appId].accessToken;
66
67
  const userId = nonRandomUUID(token);
@@ -69,9 +70,35 @@ export async function exchangeCustomPartnerToken(token) {
69
70
  return { accessToken, userId };
70
71
  }
71
72
  catch (error) {
72
- throw new AbortError('The custom token provided is invalid.', 'Ensure the token is correct and not expired.');
73
+ const prettyName = apiName.replace(/-/g, ' ').replace(/\b\w/g, (char) => char.toUpperCase());
74
+ throw new AbortError(`The custom token provided can't be used for the ${prettyName} API.`, 'Ensure the token is correct and not expired.');
73
75
  }
74
76
  }
77
+ /**
78
+ * Given a custom CLI token passed as ENV variable, request a valid Partners API token
79
+ * This token does not accept extra scopes, just the cli one.
80
+ * @param token - The CLI token passed as ENV variable `SHOPIFY_CLI_PARTNERS_TOKEN`
81
+ * @returns An instance with the application access tokens.
82
+ */
83
+ export async function exchangeCustomPartnerToken(token) {
84
+ return exchangeCliTokenForAccessToken('partners', token, tokenExchangeScopes('partners'));
85
+ }
86
+ /**
87
+ * Given a custom CLI token passed as ENV variable, request a valid App Management API token
88
+ * @param token - The CLI token passed as ENV variable `SHOPIFY_CLI_PARTNERS_TOKEN`
89
+ * @returns An instance with the application access tokens.
90
+ */
91
+ export async function exchangeCliTokenForAppManagementAccessToken(token) {
92
+ return exchangeCliTokenForAccessToken('app-management', token, tokenExchangeScopes('app-management'));
93
+ }
94
+ /**
95
+ * Given a custom CLI token passed as ENV variable, request a valid Business Platform API token
96
+ * @param token - The CLI token passed as ENV variable `SHOPIFY_CLI_PARTNERS_TOKEN`
97
+ * @returns An instance with the application access tokens.
98
+ */
99
+ export async function exchangeCliTokenForBusinessPlatformAccessToken(token) {
100
+ return exchangeCliTokenForAccessToken('business-platform', token, tokenExchangeScopes('business-platform'));
101
+ }
75
102
  /**
76
103
  * Given a deviceCode obtained after starting a device identity flow, request an identity token.
77
104
  * @param deviceCode - The device code obtained after starting a device identity flow
@@ -1 +1 @@
1
- {"version":3,"file":"exchange.js","sourceRoot":"","sources":["../../../../src/private/node/session/exchange.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,aAAa,EAAE,QAAQ,IAAI,mBAAmB,EAAC,MAAM,eAAe,CAAA;AAE5E,OAAO,EAAC,YAAY,EAAC,MAAM,sCAAsC,CAAA;AACjE,OAAO,EAAC,YAAY,EAAC,MAAM,8BAA8B,CAAA;AACzD,OAAO,EAAC,GAAG,EAAE,EAAE,EAAS,MAAM,gCAAgC,CAAA;AAC9D,OAAO,EAAC,UAAU,EAAE,QAAQ,EAAE,eAAe,EAAC,MAAM,+BAA+B,CAAA;AACnF,OAAO,EAAC,uBAAuB,EAAC,MAAM,uCAAuC,CAAA;AAC7E,OAAO,EAAC,qBAAqB,EAAE,0BAA0B,EAAC,MAAM,eAAe,CAAA;AAC/E,OAAO,KAAK,IAAI,MAAM,MAAM,CAAA;AAC5B,OAAO,EAAC,aAAa,EAAC,MAAM,8BAA8B,CAAA;AAE1D,MAAM,OAAO,iBAAkB,SAAQ,eAAe;CAAG;AACzD,MAAM,OAAO,mBAAoB,SAAQ,eAAe;CAAG;AAC3D,MAAM,kBAAmB,SAAQ,UAAU;CAAG;AAU9C;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,kCAAkC,CACtD,aAA4B,EAC5B,MAAsB,EACtB,KAAc;IAEd,MAAM,KAAK,GAAG,aAAa,CAAC,WAAW,CAAA;IAEvC,MAAM,CAAC,QAAQ,EAAE,UAAU,EAAE,gBAAgB,EAAE,KAAK,EAAE,aAAa,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;QACvF,eAAe,CAAC,UAAU,EAAE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AAG,IAAI,CAAC;QAC1D,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC;QAC/B,MAAM;KACP,CAAA;AACH,CAAC;AAED,SAAS,qBAAqB,CAAC,MAA0B;IACvD,OAAO;QACL,WAAW,EAAE,MAAM,CAAC,YAAY;QAChC,SAAS,EAAE,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,MAAM,CAAC,UAAU,GAAG,IAAI,CAAC;QAC1D,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC;KAChC,CAAA;AACH,CAAC","sourcesContent":["import {ApplicationToken, IdentityToken} from './schema.js'\nimport {applicationId, clientId as getIdentityClientId} from './identity.js'\nimport {API} from '../api.js'\nimport {identityFqdn} from '../../../public/node/context/fqdn.js'\nimport {shopifyFetch} from '../../../public/node/http.js'\nimport {err, ok, Result} from '../../../public/node/result.js'\nimport {AbortError, BugError, ExtendableError} from '../../../public/node/error.js'\nimport {isAppManagementDisabled} from '../../../public/node/context/local.js'\nimport {setLastSeenAuthMethod, setLastSeenUserIdAfterAuth} from '../session.js'\nimport * as jose from 'jose'\nimport {nonRandomUUID} from '@shopify/cli-kit/node/crypto'\n\nexport class InvalidGrantError extends ExtendableError {}\nexport class InvalidRequestError extends ExtendableError {}\nclass InvalidTargetError extends AbortError {}\n\nexport interface ExchangeScopes {\n admin: string[]\n partners: string[]\n storefront: string[]\n businessPlatform: string[]\n appManagement: string[]\n}\n\n/**\n * Given an identity token, request an application token.\n * @param identityToken - access token obtained in a previous step\n * @param store - the store to use, only needed for admin API\n * @returns An array with the application access tokens.\n */\nexport async function exchangeAccessForApplicationTokens(\n identityToken: IdentityToken,\n scopes: ExchangeScopes,\n store?: string,\n): Promise<{[x: string]: ApplicationToken}> {\n const token = identityToken.accessToken\n\n const [partners, storefront, businessPlatform, admin, appManagement] = await Promise.all([\n requestAppToken('partners', token, scopes.partners),\n requestAppToken('storefront-renderer', token, scopes.storefront),\n requestAppToken('business-platform', token, scopes.businessPlatform),\n store ? requestAppToken('admin', token, scopes.admin, store) : {},\n isAppManagementDisabled() ? {} : requestAppToken('app-management', token, scopes.appManagement),\n ])\n\n return {\n ...partners,\n ...storefront,\n ...businessPlatform,\n ...admin,\n ...appManagement,\n }\n}\n\n/**\n * Given an expired access token, refresh it to get a new one.\n */\nexport async function refreshAccessToken(currentToken: IdentityToken): Promise<IdentityToken> {\n const clientId = getIdentityClientId()\n const params = {\n grant_type: 'refresh_token',\n access_token: currentToken.accessToken,\n refresh_token: currentToken.refreshToken,\n client_id: clientId,\n }\n const tokenResult = await tokenRequest(params)\n const value = tokenResult.mapError(tokenRequestErrorHandler).valueOrBug()\n return buildIdentityToken(value, currentToken.userId)\n}\n\n/**\n * Given a custom CLI token passed as ENV variable, request a valid partners API token\n * This token does not accept extra scopes, just the cli one.\n * @param token - The CLI token passed as ENV variable\n * @returns An instance with the application access tokens.\n */\nexport async function exchangeCustomPartnerToken(token: string): Promise<{accessToken: string; userId: string}> {\n const appId = applicationId('partners')\n try {\n const newToken = await requestAppToken('partners', token, ['https://api.shopify.com/auth/partners.app.cli.access'])\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const accessToken = newToken[appId]!.accessToken\n const userId = nonRandomUUID(token)\n setLastSeenUserIdAfterAuth(userId)\n setLastSeenAuthMethod('partners_token')\n return {accessToken, userId}\n } catch (error) {\n throw new AbortError('The custom token provided is invalid.', 'Ensure the token is correct and not expired.')\n }\n}\n\ntype IdentityDeviceError = 'authorization_pending' | 'access_denied' | 'expired_token' | 'slow_down' | 'unknown_failure'\n\n/**\n * Given a deviceCode obtained after starting a device identity flow, request an identity token.\n * @param deviceCode - The device code obtained after starting a device identity flow\n * @param scopes - The scopes to request\n * @returns An instance with the identity access tokens.\n */\nexport async function exchangeDeviceCodeForAccessToken(\n deviceCode: string,\n): Promise<Result<IdentityToken, IdentityDeviceError>> {\n const clientId = await getIdentityClientId()\n\n const params = {\n grant_type: 'urn:ietf:params:oauth:grant-type:device_code',\n device_code: deviceCode,\n client_id: clientId,\n }\n\n const tokenResult = await tokenRequest(params)\n if (tokenResult.isErr()) {\n return err(tokenResult.error as IdentityDeviceError)\n }\n const identityToken = buildIdentityToken(tokenResult.value)\n return ok(identityToken)\n}\n\nasync function requestAppToken(\n api: API,\n token: string,\n scopes: string[] = [],\n store?: string,\n): Promise<{[x: string]: ApplicationToken}> {\n const appId = applicationId(api)\n const clientId = await getIdentityClientId()\n\n const params = {\n grant_type: 'urn:ietf:params:oauth:grant-type:token-exchange',\n requested_token_type: 'urn:ietf:params:oauth:token-type:access_token',\n subject_token_type: 'urn:ietf:params:oauth:token-type:access_token',\n client_id: clientId,\n audience: appId,\n scope: scopes.join(' '),\n subject_token: token,\n ...(api === 'admin' && {destination: `https://${store}/admin`}),\n }\n\n let identifier = appId\n if (api === 'admin' && store) {\n identifier = `${store}-${appId}`\n }\n const tokenResult = await tokenRequest(params)\n const value = tokenResult.mapError(tokenRequestErrorHandler).valueOrBug()\n const appToken = buildApplicationToken(value)\n return {[identifier]: appToken}\n}\n\ninterface TokenRequestResult {\n access_token: string\n expires_in: number\n refresh_token: string\n scope: string\n id_token?: string\n}\n\nfunction tokenRequestErrorHandler(error: string) {\n const invalidTargetErrorMessage =\n 'You are not authorized to use the CLI to develop in the provided store.' +\n '\\n\\n' +\n \"You can't use Shopify CLI with development stores if you only have Partner \" +\n 'staff member access. If you want to use Shopify CLI to work on a development store, then ' +\n 'you should be the store owner or create a staff account on the store.' +\n '\\n\\n' +\n \"If you're the store owner, then you need to log in to the store directly using the \" +\n 'store URL at least once before you log in using Shopify CLI.' +\n 'Logging in to the Shopify admin directly connects the development ' +\n 'store with your Shopify login.'\n if (error === 'invalid_grant') {\n // There's an scenario when Identity returns \"invalid_grant\" when trying to refresh the token\n // using a valid refresh token. When that happens, we take the user through the authentication flow.\n return new InvalidGrantError()\n }\n if (error === 'invalid_request') {\n // There's an scenario when Identity returns \"invalid_request\" when exchanging an identity token.\n // This means the token is invalid. We clear the session and throw an error to let the caller know.\n return new InvalidRequestError()\n }\n if (error === 'invalid_target') {\n return new InvalidTargetError(invalidTargetErrorMessage)\n }\n // eslint-disable-next-line @shopify/cli/no-error-factory-functions\n return new AbortError(error)\n}\n\nasync function tokenRequest(params: {[key: string]: string}): Promise<Result<TokenRequestResult, string>> {\n const fqdn = await identityFqdn()\n const url = new URL(`https://${fqdn}/oauth/token`)\n url.search = new URLSearchParams(Object.entries(params)).toString()\n const res = await shopifyFetch(url.href, {method: 'POST'})\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const payload: any = await res.json()\n\n if (res.ok) return ok(payload)\n return err(payload.error)\n}\n\nfunction buildIdentityToken(result: TokenRequestResult, existingUserId?: string): IdentityToken {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const userId = existingUserId ?? (result.id_token ? jose.decodeJwt(result.id_token).sub! : undefined)\n\n if (!userId) {\n throw new BugError('Error setting userId for session. No id_token or pre-existing user ID provided.')\n }\n\n return {\n accessToken: result.access_token,\n refreshToken: result.refresh_token,\n expiresAt: new Date(Date.now() + result.expires_in * 1000),\n scopes: result.scope.split(' '),\n userId,\n }\n}\n\nfunction buildApplicationToken(result: TokenRequestResult): ApplicationToken {\n return {\n accessToken: result.access_token,\n expiresAt: new Date(Date.now() + result.expires_in * 1000),\n scopes: result.scope.split(' '),\n }\n}\n"]}
1
+ {"version":3,"file":"exchange.js","sourceRoot":"","sources":["../../../../src/private/node/session/exchange.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,aAAa,EAAE,QAAQ,IAAI,mBAAmB,EAAC,MAAM,eAAe,CAAA;AAC5E,OAAO,EAAC,mBAAmB,EAAC,MAAM,aAAa,CAAA;AAE/C,OAAO,EAAC,YAAY,EAAC,MAAM,sCAAsC,CAAA;AACjE,OAAO,EAAC,YAAY,EAAC,MAAM,8BAA8B,CAAA;AACzD,OAAO,EAAC,GAAG,EAAE,EAAE,EAAS,MAAM,gCAAgC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,EAAE,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,MAAM,CAAC,UAAU,GAAG,IAAI,CAAC;QAC1D,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC;QAC/B,MAAM;KACP,CAAA;AACH,CAAC;AAED,SAAS,qBAAqB,CAAC,MAA0B;IACvD,OAAO;QACL,WAAW,EAAE,MAAM,CAAC,YAAY;QAChC,SAAS,EAAE,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,MAAM,CAAC,UAAU,GAAG,IAAI,CAAC;QAC1D,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC;KAChC,CAAA;AACH,CAAC","sourcesContent":["import {ApplicationToken, IdentityToken} from './schema.js'\nimport {applicationId, clientId as getIdentityClientId} from './identity.js'\nimport {tokenExchangeScopes} from './scopes.js'\nimport {API} from '../api.js'\nimport {identityFqdn} from '../../../public/node/context/fqdn.js'\nimport {shopifyFetch} from '../../../public/node/http.js'\nimport {err, ok, Result} from '../../../public/node/result.js'\nimport {AbortError, BugError, ExtendableError} from '../../../public/node/error.js'\nimport {setLastSeenAuthMethod, setLastSeenUserIdAfterAuth} from '../session.js'\nimport * as jose from 'jose'\nimport {nonRandomUUID} from '@shopify/cli-kit/node/crypto'\n\nexport class InvalidGrantError extends ExtendableError {}\nexport class InvalidRequestError extends ExtendableError {}\nclass InvalidTargetError extends AbortError {}\n\nexport interface ExchangeScopes {\n admin: string[]\n partners: string[]\n storefront: string[]\n businessPlatform: string[]\n appManagement: string[]\n}\n\n/**\n * Given an identity token, request an application token.\n * @param identityToken - access token obtained in a previous step\n * @param store - the store to use, only needed for admin API\n * @returns An array with the application access tokens.\n */\nexport async function exchangeAccessForApplicationTokens(\n identityToken: IdentityToken,\n scopes: ExchangeScopes,\n store?: string,\n): Promise<{[x: string]: ApplicationToken}> {\n const token = identityToken.accessToken\n\n const [partners, storefront, businessPlatform, admin, appManagement] = await Promise.all([\n requestAppToken('partners', token, scopes.partners),\n requestAppToken('storefront-renderer', token, scopes.storefront),\n requestAppToken('business-platform', token, scopes.businessPlatform),\n store ? requestAppToken('admin', token, scopes.admin, store) : {},\n requestAppToken('app-management', token, scopes.appManagement),\n ])\n\n return {\n ...partners,\n ...storefront,\n ...businessPlatform,\n ...admin,\n ...appManagement,\n }\n}\n\n/**\n * Given an expired access token, refresh it to get a new one.\n */\nexport async function refreshAccessToken(currentToken: IdentityToken): Promise<IdentityToken> {\n const clientId = getIdentityClientId()\n const params = {\n grant_type: 'refresh_token',\n access_token: currentToken.accessToken,\n refresh_token: currentToken.refreshToken,\n client_id: clientId,\n }\n const tokenResult = await tokenRequest(params)\n const value = tokenResult.mapError(tokenRequestErrorHandler).valueOrBug()\n return buildIdentityToken(value, currentToken.userId)\n}\n\n/**\n * Given a custom CLI token passed as ENV variable request a valid API access token\n * @param token - The CLI token passed as ENV variable `SHOPIFY_CLI_PARTNERS_TOKEN`\n * @param apiName - The API to exchange for the access token\n * @param scopes - The scopes to request with the access token\n * @returns An instance with the application access tokens.\n */\nasync function exchangeCliTokenForAccessToken(\n apiName: API,\n token: string,\n scopes: string[],\n): Promise<{accessToken: string; userId: string}> {\n const appId = applicationId(apiName)\n try {\n const newToken = await requestAppToken(apiName, token, scopes)\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const accessToken = newToken[appId]!.accessToken\n const userId = nonRandomUUID(token)\n setLastSeenUserIdAfterAuth(userId)\n setLastSeenAuthMethod('partners_token')\n return {accessToken, userId}\n } catch (error) {\n const prettyName = apiName.replace(/-/g, ' ').replace(/\\b\\w/g, (char) => char.toUpperCase())\n throw new AbortError(\n `The custom token provided can't be used for the ${prettyName} API.`,\n 'Ensure the token is correct and not expired.',\n )\n }\n}\n\n/**\n * Given a custom CLI token passed as ENV variable, request a valid Partners API token\n * This token does not accept extra scopes, just the cli one.\n * @param token - The CLI token passed as ENV variable `SHOPIFY_CLI_PARTNERS_TOKEN`\n * @returns An instance with the application access tokens.\n */\nexport async function exchangeCustomPartnerToken(token: string): Promise<{accessToken: string; userId: string}> {\n return exchangeCliTokenForAccessToken('partners', token, tokenExchangeScopes('partners'))\n}\n\n/**\n * Given a custom CLI token passed as ENV variable, request a valid App Management API token\n * @param token - The CLI token passed as ENV variable `SHOPIFY_CLI_PARTNERS_TOKEN`\n * @returns An instance with the application access tokens.\n */\nexport async function exchangeCliTokenForAppManagementAccessToken(\n token: string,\n): Promise<{accessToken: string; userId: string}> {\n return exchangeCliTokenForAccessToken('app-management', token, tokenExchangeScopes('app-management'))\n}\n\n/**\n * Given a custom CLI token passed as ENV variable, request a valid Business Platform API token\n * @param token - The CLI token passed as ENV variable `SHOPIFY_CLI_PARTNERS_TOKEN`\n * @returns An instance with the application access tokens.\n */\nexport async function exchangeCliTokenForBusinessPlatformAccessToken(\n token: string,\n): Promise<{accessToken: string; userId: string}> {\n return exchangeCliTokenForAccessToken('business-platform', token, tokenExchangeScopes('business-platform'))\n}\n\ntype IdentityDeviceError = 'authorization_pending' | 'access_denied' | 'expired_token' | 'slow_down' | 'unknown_failure'\n\n/**\n * Given a deviceCode obtained after starting a device identity flow, request an identity token.\n * @param deviceCode - The device code obtained after starting a device identity flow\n * @param scopes - The scopes to request\n * @returns An instance with the identity access tokens.\n */\nexport async function exchangeDeviceCodeForAccessToken(\n deviceCode: string,\n): Promise<Result<IdentityToken, IdentityDeviceError>> {\n const clientId = await getIdentityClientId()\n\n const params = {\n grant_type: 'urn:ietf:params:oauth:grant-type:device_code',\n device_code: deviceCode,\n client_id: clientId,\n }\n\n const tokenResult = await tokenRequest(params)\n if (tokenResult.isErr()) {\n return err(tokenResult.error as IdentityDeviceError)\n }\n const identityToken = buildIdentityToken(tokenResult.value)\n return ok(identityToken)\n}\n\nasync function requestAppToken(\n api: API,\n token: string,\n scopes: string[] = [],\n store?: string,\n): Promise<{[x: string]: ApplicationToken}> {\n const appId = applicationId(api)\n const clientId = await getIdentityClientId()\n\n const params = {\n grant_type: 'urn:ietf:params:oauth:grant-type:token-exchange',\n requested_token_type: 'urn:ietf:params:oauth:token-type:access_token',\n subject_token_type: 'urn:ietf:params:oauth:token-type:access_token',\n client_id: clientId,\n audience: appId,\n scope: scopes.join(' '),\n subject_token: token,\n ...(api === 'admin' && {destination: `https://${store}/admin`}),\n }\n\n let identifier = appId\n if (api === 'admin' && store) {\n identifier = `${store}-${appId}`\n }\n const tokenResult = await tokenRequest(params)\n const value = tokenResult.mapError(tokenRequestErrorHandler).valueOrBug()\n const appToken = buildApplicationToken(value)\n return {[identifier]: appToken}\n}\n\ninterface TokenRequestResult {\n access_token: string\n expires_in: number\n refresh_token: string\n scope: string\n id_token?: string\n}\n\nfunction tokenRequestErrorHandler(error: string) {\n const invalidTargetErrorMessage =\n 'You are not authorized to use the CLI to develop in the provided store.' +\n '\\n\\n' +\n \"You can't use Shopify CLI with development stores if you only have Partner \" +\n 'staff member access. If you want to use Shopify CLI to work on a development store, then ' +\n 'you should be the store owner or create a staff account on the store.' +\n '\\n\\n' +\n \"If you're the store owner, then you need to log in to the store directly using the \" +\n 'store URL at least once before you log in using Shopify CLI.' +\n 'Logging in to the Shopify admin directly connects the development ' +\n 'store with your Shopify login.'\n if (error === 'invalid_grant') {\n // There's an scenario when Identity returns \"invalid_grant\" when trying to refresh the token\n // using a valid refresh token. When that happens, we take the user through the authentication flow.\n return new InvalidGrantError()\n }\n if (error === 'invalid_request') {\n // There's an scenario when Identity returns \"invalid_request\" when exchanging an identity token.\n // This means the token is invalid. We clear the session and throw an error to let the caller know.\n return new InvalidRequestError()\n }\n if (error === 'invalid_target') {\n return new InvalidTargetError(invalidTargetErrorMessage)\n }\n // eslint-disable-next-line @shopify/cli/no-error-factory-functions\n return new AbortError(error)\n}\n\nasync function tokenRequest(params: {[key: string]: string}): Promise<Result<TokenRequestResult, string>> {\n const fqdn = await identityFqdn()\n const url = new URL(`https://${fqdn}/oauth/token`)\n url.search = new URLSearchParams(Object.entries(params)).toString()\n\n const res = await shopifyFetch(url.href, {method: 'POST'})\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const payload: any = await res.json()\n\n if (res.ok) return ok(payload)\n return err(payload.error)\n}\n\nfunction buildIdentityToken(result: TokenRequestResult, existingUserId?: string): IdentityToken {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const userId = existingUserId ?? (result.id_token ? jose.decodeJwt(result.id_token).sub! : undefined)\n\n if (!userId) {\n throw new BugError('Error setting userId for session. No id_token or pre-existing user ID provided.')\n }\n\n return {\n accessToken: result.access_token,\n refreshToken: result.refresh_token,\n expiresAt: new Date(Date.now() + result.expires_in * 1000),\n scopes: result.scope.split(' '),\n userId,\n }\n}\n\nfunction buildApplicationToken(result: TokenRequestResult): ApplicationToken {\n return {\n accessToken: result.access_token,\n expiresAt: new Date(Date.now() + result.expires_in * 1000),\n scopes: result.scope.split(' '),\n }\n}\n"]}
@@ -14,3 +14,9 @@ export declare function allDefaultScopes(extraScopes?: string[]): string[];
14
14
  * @returns Array of scopes
15
15
  */
16
16
  export declare function apiScopes(api: API, extraScopes?: string[]): string[];
17
+ /**
18
+ * Returns specific scopes required for token exchange with the given API.
19
+ * @param api - API to get the scopes for
20
+ * @returns Array of transformed scopes
21
+ */
22
+ export declare function tokenExchangeScopes(api: API): string[];
@@ -22,6 +22,23 @@ export function apiScopes(api, extraScopes = []) {
22
22
  const scopes = [...defaultApiScopes(api), ...extraScopes.map(scopeTransform)].map(scopeTransform);
23
23
  return Array.from(new Set(scopes));
24
24
  }
25
+ /**
26
+ * Returns specific scopes required for token exchange with the given API.
27
+ * @param api - API to get the scopes for
28
+ * @returns Array of transformed scopes
29
+ */
30
+ export function tokenExchangeScopes(api) {
31
+ switch (api) {
32
+ case 'partners':
33
+ return [scopeTransform('cli')];
34
+ case 'app-management':
35
+ return [scopeTransform('app-management')];
36
+ case 'business-platform':
37
+ return [scopeTransform('destinations')];
38
+ default:
39
+ throw new BugError(`API not supported for token exchange: ${api}`);
40
+ }
41
+ }
25
42
  function defaultApiScopes(api) {
26
43
  switch (api) {
27
44
  case 'admin':
@@ -1 +1 @@
1
- {"version":3,"file":"scopes.js","sourceRoot":"","sources":["../../../../src/private/node/session/scopes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAM,MAAM,WAAW,CAAA;AACtC,OAAO,EAAC,QAAQ,EAAC,MAAM,+BAA+B,CAAA;AAEtD;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAAC,cAAwB,EAAE;IACzD,IAAI,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,CAAA;IAC/D,MAAM,GAAG,CAAC,QAAQ,EAAE,GAAG,MAAM,EAAE,GAAG,WAAW,CAAC,CAAC,GAAG,CAAC,cAAc,CAAC,CAAA;IAClE,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,MAAM,CAAC,CAAC,CAAA;AACpC,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,SAAS,CAAC,GAAQ,EAAE,cAAwB,EAAE;IAC5D,MAAM,MAAM,GAAG,CAAC,GAAG,gBAAgB,CAAC,GAAG,CAAC,EAAE,GAAG,WAAW,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC,CAAC,GAAG,CAAC,cAAc,CAAC,CAAA;IACjG,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,MAAM,CAAC,CAAC,CAAA;AACpC,CAAC;AAED,SAAS,gBAAgB,CAAC,GAAQ;IAChC,QAAQ,GAAG,EAAE,CAAC;QACZ,KAAK,OAAO;YACV,OAAO,CAAC,SAAS,EAAE,QAAQ,EAAE,cAAc,CAAC,CAAA;QAC9C,KAAK,qBAAqB;YACxB,OAAO,CAAC,UAAU,CAAC,CAAA;QACrB,KAAK,UAAU;YACb,OAAO,CAAC,KAAK,CAAC,CAAA;QAChB,KAAK,mBAAmB;YACtB,OAAO,CAAC,cAAc,EAAE,kBAAkB,CAAC,CAAA;QAC7C,KAAK,gBAAgB;YACnB,OAAO,CAAC,gBAAgB,CAAC,CAAA;QAC3B;YACE,MAAM,IAAI,QAAQ,CAAC,gBAAgB,GAAG,EAAE,CAAC,CAAA;IAC7C,CAAC;AACH,CAAC;AAED,SAAS,cAAc,CAAC,KAAa;IACnC,QAAQ,KAAK,EAAE,CAAC;QACd,KAAK,SAAS;YACZ,OAAO,iDAAiD,CAAA;QAC1D,KAAK,QAAQ;YACX,OAAO,gDAAgD,CAAA;QACzD,KAAK,cAAc;YACjB,OAAO,2EAA2E,CAAA;QACpF,KAAK,KAAK;YACR,OAAO,sDAAsD,CAAA;QAC/D,KAAK,UAAU;YACb,OAAO,gEAAgE,CAAA;QACzE,KAAK,cAAc;YACjB,OAAO,oDAAoD,CAAA;QAC7D,KAAK,kBAAkB;YACrB,OAAO,4DAA4D,CAAA;QACrE,KAAK,gBAAgB;YACnB,OAAO,uDAAuD,CAAA;QAChE;YACE,OAAO,KAAK,CAAA;IAChB,CAAC;AACH,CAAC","sourcesContent":["import {allAPIs, API} from '../api.js'\nimport {BugError} from '../../../public/node/error.js'\n\n/**\n * Generate a flat array with all the default scopes for all the APIs plus\n * any custom scope defined by the user.\n * @param extraScopes - custom user-defined scopes\n * @returns Array of scopes\n */\nexport function allDefaultScopes(extraScopes: string[] = []): string[] {\n let scopes = allAPIs.map((api) => defaultApiScopes(api)).flat()\n scopes = ['openid', ...scopes, ...extraScopes].map(scopeTransform)\n return Array.from(new Set(scopes))\n}\n\n/**\n * Generate a flat array with the default scopes for the given API plus\n * any custom scope defined by the user\n * @param api - API to get the scopes for\n * @param extraScopes - custom user-defined scopes\n * @returns Array of scopes\n */\nexport function apiScopes(api: API, extraScopes: string[] = []): string[] {\n const scopes = [...defaultApiScopes(api), ...extraScopes.map(scopeTransform)].map(scopeTransform)\n return Array.from(new Set(scopes))\n}\n\nfunction defaultApiScopes(api: API): string[] {\n switch (api) {\n case 'admin':\n return ['graphql', 'themes', 'collaborator']\n case 'storefront-renderer':\n return ['devtools']\n case 'partners':\n return ['cli']\n case 'business-platform':\n return ['destinations', 'store-management']\n case 'app-management':\n return ['app-management']\n default:\n throw new BugError(`Unknown API: ${api}`)\n }\n}\n\nfunction scopeTransform(scope: string): string {\n switch (scope) {\n case 'graphql':\n return 'https://api.shopify.com/auth/shop.admin.graphql'\n case 'themes':\n return 'https://api.shopify.com/auth/shop.admin.themes'\n case 'collaborator':\n return 'https://api.shopify.com/auth/partners.collaborator-relationships.readonly'\n case 'cli':\n return 'https://api.shopify.com/auth/partners.app.cli.access'\n case 'devtools':\n return 'https://api.shopify.com/auth/shop.storefront-renderer.devtools'\n case 'destinations':\n return 'https://api.shopify.com/auth/destinations.readonly'\n case 'store-management':\n return 'https://api.shopify.com/auth/organization.store-management'\n case 'app-management':\n return 'https://api.shopify.com/auth/organization.apps.manage'\n default:\n return scope\n }\n}\n"]}
1
+ {"version":3,"file":"scopes.js","sourceRoot":"","sources":["../../../../src/private/node/session/scopes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAM,MAAM,WAAW,CAAA;AACtC,OAAO,EAAC,QAAQ,EAAC,MAAM,+BAA+B,CAAA;AAEtD;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAAC,cAAwB,EAAE;IACzD,IAAI,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,CAAA;IAC/D,MAAM,GAAG,CAAC,QAAQ,EAAE,GAAG,MAAM,EAAE,GAAG,WAAW,CAAC,CAAC,GAAG,CAAC,cAAc,CAAC,CAAA;IAClE,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,MAAM,CAAC,CAAC,CAAA;AACpC,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,SAAS,CAAC,GAAQ,E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AAiD,CAAA;QAC1D,KAAK,QAAQ;YACX,OAAO,gDAAgD,CAAA;QACzD,KAAK,cAAc;YACjB,OAAO,2EAA2E,CAAA;QACpF,KAAK,KAAK;YACR,OAAO,sDAAsD,CAAA;QAC/D,KAAK,UAAU;YACb,OAAO,gEAAgE,CAAA;QACzE,KAAK,cAAc;YACjB,OAAO,oDAAoD,CAAA;QAC7D,KAAK,kBAAkB;YACrB,OAAO,4DAA4D,CAAA;QACrE,KAAK,gBAAgB;YACnB,OAAO,uDAAuD,CAAA;QAChE;YACE,OAAO,KAAK,CAAA;IAChB,CAAC;AACH,CAAC","sourcesContent":["import {allAPIs, API} from '../api.js'\nimport {BugError} from '../../../public/node/error.js'\n\n/**\n * Generate a flat array with all the default scopes for all the APIs plus\n * any custom scope defined by the user.\n * @param extraScopes - custom user-defined scopes\n * @returns Array of scopes\n */\nexport function allDefaultScopes(extraScopes: string[] = []): string[] {\n let scopes = allAPIs.map((api) => defaultApiScopes(api)).flat()\n scopes = ['openid', ...scopes, ...extraScopes].map(scopeTransform)\n return Array.from(new Set(scopes))\n}\n\n/**\n * Generate a flat array with the default scopes for the given API plus\n * any custom scope defined by the user\n * @param api - API to get the scopes for\n * @param extraScopes - custom user-defined scopes\n * @returns Array of scopes\n */\nexport function apiScopes(api: API, extraScopes: string[] = []): string[] {\n const scopes = [...defaultApiScopes(api), ...extraScopes.map(scopeTransform)].map(scopeTransform)\n return Array.from(new Set(scopes))\n}\n\n/**\n * Returns specific scopes required for token exchange with the given API.\n * @param api - API to get the scopes for\n * @returns Array of transformed scopes\n */\nexport function tokenExchangeScopes(api: API): string[] {\n switch (api) {\n case 'partners':\n return [scopeTransform('cli')]\n case 'app-management':\n return [scopeTransform('app-management')]\n case 'business-platform':\n return [scopeTransform('destinations')]\n default:\n throw new BugError(`API not supported for token exchange: ${api}`)\n }\n}\n\nfunction defaultApiScopes(api: API): string[] {\n switch (api) {\n case 'admin':\n return ['graphql', 'themes', 'collaborator']\n case 'storefront-renderer':\n return ['devtools']\n case 'partners':\n return ['cli']\n case 'business-platform':\n return ['destinations', 'store-management']\n case 'app-management':\n return ['app-management']\n default:\n throw new BugError(`Unknown API: ${api}`)\n }\n}\n\nfunction scopeTransform(scope: string): string {\n switch (scope) {\n case 'graphql':\n return 'https://api.shopify.com/auth/shop.admin.graphql'\n case 'themes':\n return 'https://api.shopify.com/auth/shop.admin.themes'\n case 'collaborator':\n return 'https://api.shopify.com/auth/partners.collaborator-relationships.readonly'\n case 'cli':\n return 'https://api.shopify.com/auth/partners.app.cli.access'\n case 'devtools':\n return 'https://api.shopify.com/auth/shop.storefront-renderer.devtools'\n case 'destinations':\n return 'https://api.shopify.com/auth/destinations.readonly'\n case 'store-management':\n return 'https://api.shopify.com/auth/organization.store-management'\n case 'app-management':\n return 'https://api.shopify.com/auth/organization.apps.manage'\n default:\n return scope\n }\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  /* eslint-disable id-length */
2
- import { Text } from 'ink';
2
+ import { Text, useStdout } from 'ink';
3
3
  import React, { memo, useCallback, useLayoutEffect, useRef, useState } from 'react';
4
4
  import gradient from 'gradient-string';
5
5
  function rainbow(text, frame) {
@@ -24,14 +24,19 @@ const TextAnimation = memo(({ text, maxWidth }) => {
24
24
  const frame = useRef(0);
25
25
  const [renderedFrame, setRenderedFrame] = useState(text);
26
26
  const timeout = useRef();
27
+ const { stdout } = useStdout();
28
+ const [width, setWidth] = useState(maxWidth ?? Math.floor(stdout.columns * 0.66));
29
+ stdout.on('resize', () => {
30
+ setWidth(Math.floor(stdout.columns * 0.66));
31
+ });
27
32
  const renderAnimation = useCallback(() => {
28
33
  const newFrame = frame.current + 1;
29
34
  frame.current = newFrame;
30
- setRenderedFrame(rainbow(truncated(rotated(text, frame.current), maxWidth), frame.current));
35
+ setRenderedFrame(rainbow(truncated(rotated(text, frame.current), width), frame.current));
31
36
  timeout.current = setTimeout(() => {
32
37
  renderAnimation();
33
38
  }, 35);
34
- }, [text, maxWidth]);
39
+ }, [text, width]);
35
40
  useLayoutEffect(() => {
36
41
  renderAnimation();
37
42
  return () => {
@@ -1 +1 @@
1
- {"version":3,"file":"TextAnimation.js","sourceRoot":"","sources":["../../../../../src/private/node/ui/components/TextAnimation.tsx"],"names":[],"mappings":"AAAA,8BAA8B;AAC9B,OAAO,EAAC,IAAI,EAAC,MAAM,KAAK,CAAA;AACxB,OAAO,KAAK,EAAE,EAAC,IAAI,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,EAAE,QAAQ,EAAC,MAAM,OAAO,CAAA;AACjF,OAAO,QAAQ,MAAM,iBAAiB,CAAA;AAOtC,SAAS,OAAO,CAAC,IAAY,EAAE,KAAa;IAC1C,MAAM,GAAG,GAAG,CAAC,GAAG,KAAK,CAAA;IACrB,MAAM,SAAS,GAAG,EAAC,CAAC,EAAE,GAAG,GAAG,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC,EAAC,CAAA;IAC9C,MAAM,UAAU,GAAG,EAAC,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC,EAAC,CAAA;IACrD,OAAO,QAAQ,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC,IAAI,EAAE,EAAC,aAAa,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAC,CAAC,CAAA;AACvF,CAAC;AAED,SAAS,OAAO,CAAC,IAAY,EAAE,KAAa;IAC1C,MAAM,eAAe,GAAG,KAAK,GAAG,IAAI,CAAC,MAAM,CAAA;IAC3C,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,eAAe,CAAC,CAAA;IAC1C,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,eAAe,CAAC,CAAA;IAC3C,OAAO,KAAK,GAAG,GAAG,CAAA;AACpB,CAAC;AAED,SAAS,SAAS,CAAC,IAAY,EAAE,QAA4B;IAC3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","sourcesContent":["/* eslint-disable id-length */\nimport {Text} from 'ink'\nimport React, {memo, useCallback, useLayoutEffect, useRef, useState} from 'react'\nimport gradient from 'gradient-string'\n\ninterface TextAnimationProps {\n text: string\n maxWidth?: number\n}\n\nfunction rainbow(text: string, frame: number) {\n const hue = 5 * frame\n const leftColor = {h: hue % 360, s: 0.8, v: 1}\n const rightColor = {h: (hue + 1) % 360, s: 0.8, v: 1}\n return gradient(leftColor, rightColor)(text, {interpolation: 'hsv', hsvSpin: 'long'})\n}\n\nfunction rotated(text: string, steps: number) {\n const normalizedSteps = steps % text.length\n const start = text.slice(-normalizedSteps)\n const end = text.slice(0, -normalizedSteps)\n return start + end\n}\n\nfunction truncated(text: string, maxWidth: number | undefined): string {\n return maxWidth ? text.slice(0, maxWidth) : text\n}\n\n/**\n * `TextAnimation` applies a rainbow animation to text.\n */\nconst TextAnimation = memo(({text, maxWidth}: TextAnimationProps): JSX.Element => {\n const frame = useRef(0)\n const [renderedFrame, setRenderedFrame] = useState(text)\n const timeout = useRef<NodeJS.Timeout>()\n\n const renderAnimation = useCallback(() => {\n const newFrame = frame.current + 1\n frame.current = newFrame\n\n setRenderedFrame(rainbow(truncated(rotated(text, frame.current), maxWidth), frame.current))\n\n timeout.current = setTimeout(() => {\n renderAnimation()\n }, 35)\n }, [text, maxWidth])\n\n useLayoutEffect(() => {\n renderAnimation()\n\n return () => {\n clearTimeout(timeout.current)\n }\n }, [renderAnimation])\n\n return <Text>{renderedFrame}</Text>\n})\n\nTextAnimation.displayName = 'TextAnimation'\n\nexport {TextAnimation}\n"]}
1
+ {"version":3,"file":"TextAnimation.js","sourceRoot":"","sources":["../../../../../src/private/node/ui/components/TextAnimation.tsx"],"names":[],"mappings":"AAAA,8BAA8B;AAC9B,OAAO,EAAC,IAAI,EAAE,SAAS,EAAC,MAAM,KAAK,CAAA;AACnC,OAAO,KAAK,EAAE,EAAC,IAAI,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,EAAE,QAAQ,EAA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C,WAAW,GAAG,eAAe,CAAA;AAE3C,OAAO,EAAC,aAAa,EAAC,CAAA","sourcesContent":["/* eslint-disable id-length */\nimport {Text, useStdout} from 'ink'\nimport React, {memo, useCallback, useLayoutEffect, useRef, useState} from 'react'\nimport gradient from 'gradient-string'\n\ninterface TextAnimationProps {\n text: string\n maxWidth?: number\n}\n\nfunction rainbow(text: string, frame: number) {\n const hue = 5 * frame\n const leftColor = {h: hue % 360, s: 0.8, v: 1}\n const rightColor = {h: (hue + 1) % 360, s: 0.8, v: 1}\n return gradient(leftColor, rightColor)(text, {interpolation: 'hsv', hsvSpin: 'long'})\n}\n\nfunction rotated(text: string, steps: number) {\n const normalizedSteps = steps % text.length\n const start = text.slice(-normalizedSteps)\n const end = text.slice(0, -normalizedSteps)\n return start + end\n}\n\nfunction truncated(text: string, maxWidth: number | undefined): string {\n return maxWidth ? text.slice(0, maxWidth) : text\n}\n\n/**\n * `TextAnimation` applies a rainbow animation to text.\n */\nconst TextAnimation = memo(({text, maxWidth}: TextAnimationProps): JSX.Element => {\n const frame = useRef(0)\n const [renderedFrame, setRenderedFrame] = useState(text)\n const timeout = useRef<NodeJS.Timeout>()\n const {stdout} = useStdout()\n const [width, setWidth] = useState(maxWidth ?? Math.floor(stdout.columns * 0.66))\n\n stdout.on('resize', () => {\n setWidth(Math.floor(stdout.columns * 0.66))\n })\n\n const renderAnimation = useCallback(() => {\n const newFrame = frame.current + 1\n frame.current = newFrame\n\n setRenderedFrame(rainbow(truncated(rotated(text, frame.current), width), frame.current))\n\n timeout.current = setTimeout(() => {\n renderAnimation()\n }, 35)\n }, [text, width])\n\n useLayoutEffect(() => {\n renderAnimation()\n\n return () => {\n clearTimeout(timeout.current)\n }\n }, [renderAnimation])\n\n return <Text>{renderedFrame}</Text>\n})\n\nTextAnimation.displayName = 'TextAnimation'\n\nexport {TextAnimation}\n"]}
@@ -46,3 +46,22 @@ export declare function uniqBy<T>(array: List<T> | null | undefined, iteratee: V
46
46
  * @returns Returns the new array of filtered values.
47
47
  */
48
48
  export declare function difference<T>(array: List<T> | null | undefined, ...values: List<T>[]): T[];
49
+ /**
50
+ * Converts an array of anything into a human friendly list.
51
+ *
52
+ * Returns a new array that contains the items separated by commas,
53
+ * except for the last item, which is separated by "and".
54
+ * This is useful for creating human-friendly sentences.
55
+ *
56
+ * @param items - Token[].
57
+ * @returns Token[].
58
+ * @example
59
+ * ```ts
60
+ * const items = ['apple', 'banana', {command: "--flag"}];
61
+ * const result = asHumanFriendlyList(items)
62
+ *
63
+ * // ['apple', ',', 'banana', ',', 'and', {command: "--flag"}]
64
+ * console.log(result);
65
+ * ```
66
+ */
67
+ export declare function asHumanFriendlyArray<T>(items: T[]): (T | string)[];
@@ -60,4 +60,37 @@ export function uniqBy(array, iteratee) {
60
60
  export function difference(array, ...values) {
61
61
  return lodashDifference(array, ...values);
62
62
  }
63
+ /**
64
+ * Converts an array of anything into a human friendly list.
65
+ *
66
+ * Returns a new array that contains the items separated by commas,
67
+ * except for the last item, which is separated by "and".
68
+ * This is useful for creating human-friendly sentences.
69
+ *
70
+ * @param items - Token[].
71
+ * @returns Token[].
72
+ * @example
73
+ * ```ts
74
+ * const items = ['apple', 'banana', {command: "--flag"}];
75
+ * const result = asHumanFriendlyList(items)
76
+ *
77
+ * // ['apple', ',', 'banana', ',', 'and', {command: "--flag"}]
78
+ * console.log(result);
79
+ * ```
80
+ */
81
+ export function asHumanFriendlyArray(items) {
82
+ if (items.length < 2) {
83
+ return items;
84
+ }
85
+ return items.reduce((acc, item, index) => {
86
+ if (index === items.length - 1) {
87
+ acc.push('and');
88
+ }
89
+ else if (index !== 0) {
90
+ acc.push(', ');
91
+ }
92
+ acc.push(item);
93
+ return acc;
94
+ }, []);
95
+ }
63
96
  //# sourceMappingURL=array.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"array.js","sourceRoot":"","sources":["../../../src/public/common/array.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,kBAAkB,CAAA;AAC3C,OAAO,gBAAgB,MAAM,sBAAsB,CAAA;AAGnD;;;;;GAKG;AACH,MAAM,UAAU,mBAAmB,CAAI,KAAU;IAC/C,oEAAoE;IACpE,OAAO,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,KAAK,CAAC,MAAM,CAAC,CAAE,CAAA;AACzD,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,0BAA0B,CAAI,KAAwB;IACpE,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,KAAK,SAAS,CAAmC,CAAA;AACrF,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,0BAA0B,CAAI,KAAU;IACtD,OAAO,KAAK,CAAC,MAAM,KAAK,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC,IAAI,CAAA;AAC7C,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,IAAI,CAAI,KAAU;IAChC,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC,CAAA;AACnC,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,MAAM,CAAI,KAAiC,EAAE,QAA0B;IACrF,OAAO,YAAY,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAA;AACtC,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,UAAU,CAAI,KAAiC,EAAE,GAAG,MAAiB;IACnF,OAAO,gBAAgB,CAAC,KAAK,EAAE,GAAG,MAAM,CAAC,CAAA;AAC3C,CAAC","sourcesContent":["import lodashUniqBy from 'lodash/uniqBy.js'\nimport lodashDifference from 'lodash/difference.js'\nimport type {List, ValueIteratee} from 'lodash'\n\n/**\n * Takes a random value from an array.\n *\n * @param array - Array from which we'll select a random item.\n * @returns A random element from the array.\n */\nexport function takeRandomFromArray<T>(array: T[]): T {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return array[Math.floor(Math.random() * array.length)]!\n}\n\n/**\n * Returns a copy of the array deleting the elemements that are undefined.\n *\n * @param array - The array whose undefined will be deleted.\n * @returns A copy of the array with the undefined elements deleted.\n */\nexport function getArrayRejectingUndefined<T>(array: (T | undefined)[]): T[] {\n return array.filter((item) => item !== undefined) as Exclude<T, null | undefined>[]\n}\n\n/**\n * Returns true if an array contains duplicates.\n *\n * @param array - The array to check against.\n * @returns True if the array contains duplicates.\n */\nexport function getArrayContainsDuplicates<T>(array: T[]): boolean {\n return array.length !== new Set(array).size\n}\n\n/**\n * Removes duplicated items from an array.\n *\n * @param array - The array to inspect.\n * @returns Returns the new duplicate free array.\n */\nexport function uniq<T>(array: T[]): T[] {\n return Array.from(new Set(array))\n}\n\n/**\n * This method is like `_.uniq` except that it accepts `iteratee` which is\n * invoked for each element in `array` to generate the criterion by which\n * uniqueness is computed. The iteratee is invoked with one argument: (value).\n *\n * @param array - The array to inspect.\n * @param iteratee - The iteratee invoked per element.\n * @returns Returns the new duplicate free array.\n */\nexport function uniqBy<T>(array: List<T> | null | undefined, iteratee: ValueIteratee<T>): T[] {\n return lodashUniqBy(array, iteratee)\n}\n\n/**\n * Creates an array of `array` values not included in the other provided arrays using SameValueZero for\n * equality comparisons. The order and references of result values are determined by the first array.\n *\n * @param array - The array to inspect.\n * @param values - The arrays of values to exclude.\n * @returns Returns the new array of filtered values.\n */\nexport function difference<T>(array: List<T> | null | undefined, ...values: List<T>[]): T[] {\n return lodashDifference(array, ...values)\n}\n"]}
1
+ {"version":3,"file":"array.js","sourceRoot":"","sources":["../../../src/public/common/array.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,kBAAkB,CAAA;AAC3C,OAAO,gBAAgB,MAAM,sBAAsB,CAAA;AAGnD;;;;;GAKG;AACH,MAAM,UAAU,mBAAmB,CAAI,KAAU;IAC/C,oEAAoE;IACpE,OAAO,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,KAAK,CAAC,MAAM,CAAC,CAAE,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D,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QACd,OAAO,GAAG,CAAA;IACZ,CAAC,EAAE,EAAE,CAAC,CAAA;AACR,CAAC","sourcesContent":["import lodashUniqBy from 'lodash/uniqBy.js'\nimport lodashDifference from 'lodash/difference.js'\nimport type {List, ValueIteratee} from 'lodash'\n\n/**\n * Takes a random value from an array.\n *\n * @param array - Array from which we'll select a random item.\n * @returns A random element from the array.\n */\nexport function takeRandomFromArray<T>(array: T[]): T {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return array[Math.floor(Math.random() * array.length)]!\n}\n\n/**\n * Returns a copy of the array deleting the elemements that are undefined.\n *\n * @param array - The array whose undefined will be deleted.\n * @returns A copy of the array with the undefined elements deleted.\n */\nexport function getArrayRejectingUndefined<T>(array: (T | undefined)[]): T[] {\n return array.filter((item) => item !== undefined) as Exclude<T, null | undefined>[]\n}\n\n/**\n * Returns true if an array contains duplicates.\n *\n * @param array - The array to check against.\n * @returns True if the array contains duplicates.\n */\nexport function getArrayContainsDuplicates<T>(array: T[]): boolean {\n return array.length !== new Set(array).size\n}\n\n/**\n * Removes duplicated items from an array.\n *\n * @param array - The array to inspect.\n * @returns Returns the new duplicate free array.\n */\nexport function uniq<T>(array: T[]): T[] {\n return Array.from(new Set(array))\n}\n\n/**\n * This method is like `_.uniq` except that it accepts `iteratee` which is\n * invoked for each element in `array` to generate the criterion by which\n * uniqueness is computed. The iteratee is invoked with one argument: (value).\n *\n * @param array - The array to inspect.\n * @param iteratee - The iteratee invoked per element.\n * @returns Returns the new duplicate free array.\n */\nexport function uniqBy<T>(array: List<T> | null | undefined, iteratee: ValueIteratee<T>): T[] {\n return lodashUniqBy(array, iteratee)\n}\n\n/**\n * Creates an array of `array` values not included in the other provided arrays using SameValueZero for\n * equality comparisons. The order and references of result values are determined by the first array.\n *\n * @param array - The array to inspect.\n * @param values - The arrays of values to exclude.\n * @returns Returns the new array of filtered values.\n */\nexport function difference<T>(array: List<T> | null | undefined, ...values: List<T>[]): T[] {\n return lodashDifference(array, ...values)\n}\n\n/**\n * Converts an array of anything into a human friendly list.\n *\n * Returns a new array that contains the items separated by commas,\n * except for the last item, which is separated by \"and\".\n * This is useful for creating human-friendly sentences.\n *\n * @param items - Token[].\n * @returns Token[].\n * @example\n * ```ts\n * const items = ['apple', 'banana', {command: \"--flag\"}];\n * const result = asHumanFriendlyList(items)\n *\n * // ['apple', ',', 'banana', ',', 'and', {command: \"--flag\"}]\n * console.log(result);\n * ```\n */\nexport function asHumanFriendlyArray<T>(items: T[]): (T | string)[] {\n if (items.length < 2) {\n return items\n }\n\n return items.reduce<(T | string)[]>((acc, item, index) => {\n if (index === items.length - 1) {\n acc.push('and')\n } else if (index !== 0) {\n acc.push(', ')\n }\n acc.push(item)\n return acc\n }, [])\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { Dictionary, ObjectIterator, ValueKeyIteratee } from 'lodash';
1
+ import { Dictionary, ObjectIterator, PropertyPath, ValueKeyIteratee } from 'lodash';
2
2
  /**
3
3
  * Deep merges the two objects and returns a new object with the merge result.
4
4
  *
@@ -53,7 +53,7 @@ export declare function deepDifference(one: object, two: object): [object, objec
53
53
  * @param path - The path of the property to get.
54
54
  * @returns - Returns the resolved value.
55
55
  */
56
- export declare function getPathValue<T = object>(object: object, path: string): T | undefined;
56
+ export declare function getPathValue<T = object>(object: object, path: PropertyPath): T | undefined;
57
57
  /**
58
58
  * Sets the value at path of object. If a portion of path doesn't exist, it's create.
59
59
  *
@@ -62,7 +62,15 @@ export declare function getPathValue<T = object>(object: object, path: string):
62
62
  * @param value - The value to set.
63
63
  * @returns - Returns object.
64
64
  */
65
- export declare function setPathValue(object: object, path: string, value?: unknown): object;
65
+ export declare function setPathValue(object: object, path: PropertyPath, value?: unknown): object;
66
+ /**
67
+ * Removes the property at path of object.
68
+ *
69
+ * @param object - The object to modify.
70
+ * @param path - The path of the property to unset.
71
+ * @returns - Returns true if the property is deleted or not found, else false.
72
+ */
73
+ export declare function unsetPathValue(object: object, path: PropertyPath): boolean;
66
74
  /**
67
75
  * Checks if value is an empty object, collection, map, or set.
68
76
  *
@@ -8,6 +8,7 @@ import fromPairs from 'lodash/fromPairs.js';
8
8
  import toPairs from 'lodash/toPairs.js';
9
9
  import get from 'lodash/get.js';
10
10
  import set from 'lodash/set.js';
11
+ import unset from 'lodash/unset.js';
11
12
  import lodashIsEmpty from 'lodash/isEmpty.js';
12
13
  /**
13
14
  * Deep merges the two objects and returns a new object with the merge result.
@@ -87,6 +88,16 @@ export function getPathValue(object, path) {
87
88
  export function setPathValue(object, path, value) {
88
89
  return set(object, path, value);
89
90
  }
91
+ /**
92
+ * Removes the property at path of object.
93
+ *
94
+ * @param object - The object to modify.
95
+ * @param path - The path of the property to unset.
96
+ * @returns - Returns true if the property is deleted or not found, else false.
97
+ */
98
+ export function unsetPathValue(object, path) {
99
+ return unset(object, path);
100
+ }
90
101
  /**
91
102
  * Checks if value is an empty object, collection, map, or set.
92
103
  *
@@ -1 +1 @@
1
- {"version":3,"file":"object.js","sourceRoot":"","sources":["../../../src/public/common/object.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,kBAAkB,EAAC,MAAM,+BAA+B,CAAA;AAChE,OAAO,SAAS,MAAM,WAAW,CAAA;AAEjC,OAAO,YAAY,MAAM,kBAAkB,CAAA;AAC3C,OAAO,eAAe,MAAM,qBAAqB,CAAA;AACjD,OAAO,aAAa,MAAM,mBAAmB,CAAA;AAC7C,OAAO,cAAc,MAAM,0BAA0B,CAAA;AACrD,OAAO,SAAS,MAAM,qBAAqB,CAAA;AAC3C,OAAO,OAAO,MAAM,mBAAmB,CAAA;AACvC,OAAO,GAAG,MAAM,eAAe,CAAA;AAC/B,OAAO,GAAG,MAAM,eAAe,CAAA;AAC/B,OAAO,aAAa,MAAM,mBAAmB,CAAA;AAE7C;;;;;;;;GAQG;AACH,MAAM,UAAU,gBAAgB,CAC9B,GAAgB,EAChB,GAAgB,EAChB,qBAAyF,kBAAkB;IAE3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AAI,EAAE,KAAK,CAAC,CAAA;AACjC,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,OAAO,CAAC,MAAc;IACpC,OAAO,aAAa,CAAC,MAAM,CAAC,CAAA;AAC9B,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,OAAO,CAAC,MAAc;IACpC,OAAO,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,KAAK,IAAI,IAAI,CAAC,CAAC,CAAA;AACzF,CAAC","sourcesContent":["import {unionArrayStrategy} from '../../private/common/array.js'\nimport deepMerge from 'deepmerge'\nimport {Dictionary, ObjectIterator, ValueKeyIteratee} from 'lodash'\nimport lodashPickBy from 'lodash/pickBy.js'\nimport lodashMapValues from 'lodash/mapValues.js'\nimport lodashIsEqual from 'lodash/isEqual.js'\nimport differenceWith from 'lodash/differenceWith.js'\nimport fromPairs from 'lodash/fromPairs.js'\nimport toPairs from 'lodash/toPairs.js'\nimport get from 'lodash/get.js'\nimport set from 'lodash/set.js'\nimport lodashIsEmpty from 'lodash/isEmpty.js'\n\n/**\n * Deep merges the two objects and returns a new object with the merge result.\n *\n * @param lhs - One of the objects to be merged.\n * @param rhs - Another object to be merged.\n * @param arrayMergeStrategy - Strategy used to merge the array typed fields. Union strategy is used by default to avoid\n * duplicated elements.\n * @returns A Javascrip tobject with th emerged objects.\n */\nexport function deepMergeObjects<T1, T2>(\n lhs: Partial<T1>,\n rhs: Partial<T2>,\n arrayMergeStrategy: (destinationArray: unknown[], sourceArray: unknown[]) => unknown[] = unionArrayStrategy,\n): T1 & T2 {\n return deepMerge(lhs, rhs, {arrayMerge: arrayMergeStrategy})\n}\n\n/**\n * Creates an object composed of the `object` properties `predicate` returns\n * truthy for. The predicate is invoked with two arguments: (value, key).\n *\n * @param object - The source object.\n * @param predicate - The function invoked per property.\n * @returns Returns the new object.\n */\nexport function pickBy<T>(object: Dictionary<T> | null | undefined, predicate: ValueKeyIteratee<T>): Dictionary<T> {\n return lodashPickBy(object, predicate)\n}\n\n/**\n * Creates an object with the same keys as object and values generated by running each own\n * enumerable property of object through iteratee. The iteratee function is\n * invoked with three arguments: (value, key, object).\n *\n * @param source - The object to iterate over.\n * @param callback - The function invoked per iteration.\n * @returns Returns the new mapped object.\n */\nexport function mapValues<T extends object, TResult>(\n source: T | null | undefined,\n callback: ObjectIterator<T, TResult>,\n): {[P in keyof T]: TResult} {\n return lodashMapValues(source, callback)\n}\n\n/**\n * Deeply compares two objects and returns true if they are equal.\n *\n * @param one - The first object to be compared.\n * @param two - The second object to be compared.\n * @returns True if the objects are equal, false otherwise.\n */\nexport function deepCompare(one: object, two: object): boolean {\n return lodashIsEqual(one, two)\n}\n\n/**\n * Return the difference between two nested objects.\n *\n * @param one - The first object to be compared.\n * @param two - The second object to be compared.\n * @returns Two objects containing the fields that are different, each one with the values of one object.\n */\nexport function deepDifference(one: object, two: object): [object, object] {\n const changes = differenceWith(toPairs(one), toPairs(two), deepCompare)\n const changes2 = differenceWith(toPairs(two), toPairs(one), deepCompare)\n return [fromPairs(changes), fromPairs(changes2)]\n}\n\n/**\n * Gets the value at path of object. If the resolved value is undefined, the defaultValue is returned in its place.\n *\n * @param object - The object to query.\n * @param path - The path of the property to get.\n * @returns - Returns the resolved value.\n */\nexport function getPathValue<T = object>(object: object, path: string): T | undefined {\n return get(object, path) === undefined ? undefined : (get(object, path) as T)\n}\n\n/**\n * Sets the value at path of object. If a portion of path doesn't exist, it's create.\n *\n * @param object - The object to modify.\n * @param path - The path of the property to set.\n * @param value - The value to set.\n * @returns - Returns object.\n */\nexport function setPathValue(object: object, path: string, value?: unknown): object {\n return set(object, path, value)\n}\n\n/**\n * Checks if value is an empty object, collection, map, or set.\n *\n * @param object - The value to check.\n * @returns - Returns true if value is empty, else false.\n */\nexport function isEmpty(object: object): boolean {\n return lodashIsEmpty(object)\n}\n\n/**\n * Removes the undefined elements.\n *\n * @param object - The object whose undefined will be deleted.\n * @returns A copy of the object with the undefined elements deleted.\n */\nexport function compact(object: object): object {\n return Object.fromEntries(Object.entries(object).filter(([_, value]) => value != null))\n}\n"]}
1
+ {"version":3,"file":"object.js","sourceRoot":"","sources":["../../../src/public/common/object.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,kBAAkB,EAAC,MAAM,+BAA+B,CAAA;AAChE,OAAO,SAAS,MAAM,WAAW,CAAA;AAEjC,OAAO,YAAY,MAAM,kBAAkB,CAAA;AAC3C,OAAO,eAAe,MAAM,qBAAqB,CAAA;AACjD,OAAO,aAAa,MAAM,mBAAmB,CAAA;AAC7C,OAAO,cAAc,MAAM,0BAA0B,CAAA;AACrD,OAAO,SAAS,MAAM,qBAAqB,CAAA;AAC3C,OAAO,OAAO,MAAM,mBAAmB,CAAA;AACvC,OAAO,GAAG,MAAM,eAAe,CAAA;AAC/B,OAAO,GAAG,MAAM,eAAe,CAAA;AAC/B,OAAO,KAAK,MAAM,iBAAiB,CAAA;AACnC,OAAO,aAAa,MAAM,mBAAmB,CAAA;AAE7C;;;;;;;;GAQG;AACH,MAAM,UAAU,gBAAgB,CAC9B,GAAgB,EAChB,GAAgB,EAChB,qBAAyF,kBAAkB;IAE3G,OAAO,SAAS,CAAC,GAAG,EAAE,GAAG,EAAE,EAAC,UAAU,EAAE,kBAAkB,EAAC,CAAC,CAAA;AAC9D,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,MAAM,CAAI,MAAwC,EAAE,SAA8B;IAChG,OAAO,YAAY,CAAC,MAAM,EAAE,SAAS,CAAC,CAAA;AACxC,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,SAAS,CACvB,MAA4B,EAC5B,QAAoC;IAEpC,OAAO,eAAe,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAA;AAC1C,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,WAAW,CAAC,GAAW,EAAE,GAAW;IAClD,O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E,KAAK,CAAC,EAAE,EAAE,CAAC,KAAK,IAAI,IAAI,CAAC,CAAC,CAAA;AACzF,CAAC","sourcesContent":["import {unionArrayStrategy} from '../../private/common/array.js'\nimport deepMerge from 'deepmerge'\nimport {Dictionary, ObjectIterator, PropertyPath, ValueKeyIteratee} from 'lodash'\nimport lodashPickBy from 'lodash/pickBy.js'\nimport lodashMapValues from 'lodash/mapValues.js'\nimport lodashIsEqual from 'lodash/isEqual.js'\nimport differenceWith from 'lodash/differenceWith.js'\nimport fromPairs from 'lodash/fromPairs.js'\nimport toPairs from 'lodash/toPairs.js'\nimport get from 'lodash/get.js'\nimport set from 'lodash/set.js'\nimport unset from 'lodash/unset.js'\nimport lodashIsEmpty from 'lodash/isEmpty.js'\n\n/**\n * Deep merges the two objects and returns a new object with the merge result.\n *\n * @param lhs - One of the objects to be merged.\n * @param rhs - Another object to be merged.\n * @param arrayMergeStrategy - Strategy used to merge the array typed fields. Union strategy is used by default to avoid\n * duplicated elements.\n * @returns A Javascrip tobject with th emerged objects.\n */\nexport function deepMergeObjects<T1, T2>(\n lhs: Partial<T1>,\n rhs: Partial<T2>,\n arrayMergeStrategy: (destinationArray: unknown[], sourceArray: unknown[]) => unknown[] = unionArrayStrategy,\n): T1 & T2 {\n return deepMerge(lhs, rhs, {arrayMerge: arrayMergeStrategy})\n}\n\n/**\n * Creates an object composed of the `object` properties `predicate` returns\n * truthy for. The predicate is invoked with two arguments: (value, key).\n *\n * @param object - The source object.\n * @param predicate - The function invoked per property.\n * @returns Returns the new object.\n */\nexport function pickBy<T>(object: Dictionary<T> | null | undefined, predicate: ValueKeyIteratee<T>): Dictionary<T> {\n return lodashPickBy(object, predicate)\n}\n\n/**\n * Creates an object with the same keys as object and values generated by running each own\n * enumerable property of object through iteratee. The iteratee function is\n * invoked with three arguments: (value, key, object).\n *\n * @param source - The object to iterate over.\n * @param callback - The function invoked per iteration.\n * @returns Returns the new mapped object.\n */\nexport function mapValues<T extends object, TResult>(\n source: T | null | undefined,\n callback: ObjectIterator<T, TResult>,\n): {[P in keyof T]: TResult} {\n return lodashMapValues(source, callback)\n}\n\n/**\n * Deeply compares two objects and returns true if they are equal.\n *\n * @param one - The first object to be compared.\n * @param two - The second object to be compared.\n * @returns True if the objects are equal, false otherwise.\n */\nexport function deepCompare(one: object, two: object): boolean {\n return lodashIsEqual(one, two)\n}\n\n/**\n * Return the difference between two nested objects.\n *\n * @param one - The first object to be compared.\n * @param two - The second object to be compared.\n * @returns Two objects containing the fields that are different, each one with the values of one object.\n */\nexport function deepDifference(one: object, two: object): [object, object] {\n const changes = differenceWith(toPairs(one), toPairs(two), deepCompare)\n const changes2 = differenceWith(toPairs(two), toPairs(one), deepCompare)\n return [fromPairs(changes), fromPairs(changes2)]\n}\n\n/**\n * Gets the value at path of object. If the resolved value is undefined, the defaultValue is returned in its place.\n *\n * @param object - The object to query.\n * @param path - The path of the property to get.\n * @returns - Returns the resolved value.\n */\nexport function getPathValue<T = object>(object: object, path: PropertyPath): T | undefined {\n return get(object, path) === undefined ? undefined : (get(object, path) as T)\n}\n\n/**\n * Sets the value at path of object. If a portion of path doesn't exist, it's create.\n *\n * @param object - The object to modify.\n * @param path - The path of the property to set.\n * @param value - The value to set.\n * @returns - Returns object.\n */\nexport function setPathValue(object: object, path: PropertyPath, value?: unknown): object {\n return set(object, path, value)\n}\n\n/**\n * Removes the property at path of object.\n *\n * @param object - The object to modify.\n * @param path - The path of the property to unset.\n * @returns - Returns true if the property is deleted or not found, else false.\n */\nexport function unsetPathValue(object: object, path: PropertyPath): boolean {\n return unset(object, path)\n}\n\n/**\n * Checks if value is an empty object, collection, map, or set.\n *\n * @param object - The value to check.\n * @returns - Returns true if value is empty, else false.\n */\nexport function isEmpty(object: object): boolean {\n return lodashIsEmpty(object)\n}\n\n/**\n * Removes the undefined elements.\n *\n * @param object - The object whose undefined will be deleted.\n * @returns A copy of the object with the undefined elements deleted.\n */\nexport function compact(object: object): object {\n return Object.fromEntries(Object.entries(object).filter(([_, value]) => value != null))\n}\n"]}
@@ -1 +1 @@
1
- export declare const CLI_KIT_VERSION = "3.78.2";
1
+ export declare const CLI_KIT_VERSION = "3.79.1";
@@ -1,2 +1,2 @@
1
- export const CLI_KIT_VERSION = '3.78.2';
1
+ export const CLI_KIT_VERSION = '3.79.1';
2
2
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","sourceRoot":"","sources":["../../../src/public/common/version.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,eAAe,GAAG,QAAQ,CAAA","sourcesContent":["export const CLI_KIT_VERSION = '3.78.2'\n"]}
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../../../src/public/common/version.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,eAAe,GAAG,QAAQ,CAAA","sourcesContent":["export const CLI_KIT_VERSION = '3.79.1'\n"]}
@@ -1,4 +1,5 @@
1
1
  import { CacheOptions, GraphQLResponse } from './graphql.js';
2
+ import { RequestModeInput } from '../http.js';
2
3
  import { TypedDocumentNode } from '@graphql-typed-document-node/core';
3
4
  import { Variables } from 'graphql-request';
4
5
  export declare const appManagementHeaders: (token: string) => {
@@ -8,6 +9,9 @@ export declare const appManagementAppLogsUrl: (organizationId: string, cursor?:
8
9
  status?: string;
9
10
  source?: string;
10
11
  }) => Promise<string>;
12
+ export interface RequestOptions {
13
+ requestMode: RequestModeInput;
14
+ }
11
15
  /**
12
16
  * Executes an org-scoped GraphQL query against the App Management API. Uses typed documents.
13
17
  *
@@ -16,9 +20,10 @@ export declare const appManagementAppLogsUrl: (organizationId: string, cursor?:
16
20
  * @param token - Partners token.
17
21
  * @param variables - GraphQL variables to pass to the query.
18
22
  * @param cacheOptions - Cache options for the request. If not present, the request will not be cached.
23
+ * @param requestOptions - Preferred behaviour for the request.
19
24
  * @returns The response of the query of generic type <T>.
20
25
  */
21
- export declare function appManagementRequestDoc<TResult, TVariables extends Variables>(orgId: string, query: TypedDocumentNode<TResult, TVariables>, token: string, variables?: TVariables, cacheOptions?: CacheOptions): Promise<TResult>;
26
+ export declare function appManagementRequestDoc<TResult, TVariables extends Variables>(orgId: string, query: TypedDocumentNode<TResult, TVariables>, token: string, variables?: TVariables, cacheOptions?: CacheOptions, requestOptions?: RequestOptions): Promise<TResult>;
22
27
  /**
23
28
  * Sets the next deprecation date from [GraphQL response extensions](https://www.apollographql.com/docs/resources/graphql-glossary/#extensions)
24
29
  * if `response.extensions.deprecations` objects contain a `supportedUntilDate` (ISO 8601-formatted string).
@@ -38,9 +38,10 @@ export const appManagementAppLogsUrl = async (organizationId, cursor, filters) =
38
38
  * @param token - Partners token.
39
39
  * @param variables - GraphQL variables to pass to the query.
40
40
  * @param cacheOptions - Cache options for the request. If not present, the request will not be cached.
41
+ * @param requestOptions - Preferred behaviour for the request.
41
42
  * @returns The response of the query of generic type <T>.
42
43
  */
43
- export async function appManagementRequestDoc(orgId, query, token, variables, cacheOptions) {
44
+ export async function appManagementRequestDoc(orgId, query, token, variables, cacheOptions, requestOptions) {
44
45
  // For app management, we need to cache the response based on the orgId.
45
46
  const cacheExtraKey = (cacheOptions?.cacheExtraKey ?? '') + orgId;
46
47
  const newCacheOptions = cacheOptions ? { ...cacheOptions, cacheExtraKey } : undefined;
@@ -49,6 +50,7 @@ export async function appManagementRequestDoc(orgId, query, token, variables, ca
49
50
  query,
50
51
  variables,
51
52
  cacheOptions: newCacheOptions,
53
+ preferredBehaviour: requestOptions?.requestMode,
52
54
  }));
53
55
  return result;
54
56
  }