@shopify/cli-kit 3.53.1 → 3.54.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/assets/cli-ruby/lib/shopify_cli/theme/dev_server/proxy.rb +14 -0
  2. package/dist/private/node/analytics.js +2 -4
  3. package/dist/private/node/analytics.js.map +1 -1
  4. package/dist/private/node/ui/components/List.d.ts +8 -1
  5. package/dist/private/node/ui/components/List.js +26 -5
  6. package/dist/private/node/ui/components/List.js.map +1 -1
  7. package/dist/private/node/ui/components/List.test.js +17 -0
  8. package/dist/private/node/ui/components/List.test.js.map +1 -1
  9. package/dist/private/node/ui/components/Prompts/InfoTable.d.ts +3 -1
  10. package/dist/private/node/ui/components/Prompts/InfoTable.js +4 -1
  11. package/dist/private/node/ui/components/Prompts/InfoTable.js.map +1 -1
  12. package/dist/private/node/ui/components/Prompts/InfoTable.test.js +26 -0
  13. package/dist/private/node/ui/components/Prompts/InfoTable.test.js.map +1 -1
  14. package/dist/public/common/object.d.ts +7 -0
  15. package/dist/public/common/object.js +10 -0
  16. package/dist/public/common/object.js.map +1 -1
  17. package/dist/public/common/retry.d.ts +14 -0
  18. package/dist/public/common/retry.js +27 -0
  19. package/dist/public/common/retry.js.map +1 -0
  20. package/dist/public/common/version.d.ts +1 -1
  21. package/dist/public/common/version.js +1 -1
  22. package/dist/public/common/version.js.map +1 -1
  23. package/dist/public/node/analytics.js +1 -1
  24. package/dist/public/node/analytics.js.map +1 -1
  25. package/dist/public/node/api/partners.d.ts +15 -7
  26. package/dist/public/node/api/partners.js +16 -20
  27. package/dist/public/node/api/partners.js.map +1 -1
  28. package/dist/public/node/base-command.js +1 -1
  29. package/dist/public/node/base-command.js.map +1 -1
  30. package/dist/public/node/context/local.d.ts +0 -7
  31. package/dist/public/node/context/local.js +0 -9
  32. package/dist/public/node/context/local.js.map +1 -1
  33. package/dist/public/node/error-handler.js +1 -1
  34. package/dist/public/node/error-handler.js.map +1 -1
  35. package/dist/public/node/fs.d.ts +5 -1
  36. package/dist/public/node/fs.js +3 -2
  37. package/dist/public/node/fs.js.map +1 -1
  38. package/dist/public/node/monorail.js +9 -0
  39. package/dist/public/node/monorail.js.map +1 -1
  40. package/dist/public/node/schema.d.ts +8 -0
  41. package/dist/public/node/schema.js +20 -0
  42. package/dist/public/node/schema.js.map +1 -1
  43. package/dist/public/node/themes/{themes-api.d.ts → api.d.ts} +3 -1
  44. package/dist/public/node/themes/{themes-api.js → api.js} +21 -13
  45. package/dist/public/node/themes/api.js.map +1 -0
  46. package/dist/public/node/themes/factories.d.ts +18 -0
  47. package/dist/public/node/themes/factories.js +27 -0
  48. package/dist/public/node/themes/factories.js.map +1 -0
  49. package/dist/public/node/themes/theme-manager.d.ts +1 -1
  50. package/dist/public/node/themes/theme-manager.js +2 -2
  51. package/dist/public/node/themes/theme-manager.js.map +1 -1
  52. package/dist/public/node/themes/types.d.ts +68 -0
  53. package/dist/public/node/themes/types.js +2 -0
  54. package/dist/public/node/themes/types.js.map +1 -0
  55. package/dist/public/node/themes/{theme-urls.d.ts → urls.d.ts} +1 -1
  56. package/dist/public/node/themes/{theme-urls.js → urls.js} +1 -1
  57. package/dist/public/node/themes/urls.js.map +1 -0
  58. package/dist/public/node/themes/utils.d.ts +3 -0
  59. package/dist/public/node/themes/utils.js +5 -0
  60. package/dist/public/node/themes/utils.js.map +1 -0
  61. package/dist/tsconfig.tsbuildinfo +1 -1
  62. package/package.json +2 -2
  63. package/dist/public/node/themes/models/theme.d.ts +0 -12
  64. package/dist/public/node/themes/models/theme.js +0 -30
  65. package/dist/public/node/themes/models/theme.js.map +0 -1
  66. package/dist/public/node/themes/theme-urls.js.map +0 -1
  67. package/dist/public/node/themes/themes-api.js.map +0 -1
@@ -1,9 +1,11 @@
1
- import { Theme } from './models/theme.js';
2
1
  import { AdminSession } from '@shopify/cli-kit/node/session';
2
+ import { Checksum, Key, Theme, ThemeAsset } from '@shopify/cli-kit/node/themes/types';
3
3
  export type ThemeParams = Partial<Pick<Theme, 'name' | 'role' | 'processing'>>;
4
4
  export declare function fetchTheme(id: number, session: AdminSession): Promise<Theme | undefined>;
5
5
  export declare function fetchThemes(session: AdminSession): Promise<Theme[]>;
6
6
  export declare function createTheme(params: ThemeParams, session: AdminSession): Promise<Theme | undefined>;
7
+ export declare function fetchThemeAsset(id: number, key: Key, session: AdminSession): Promise<ThemeAsset | undefined>;
8
+ export declare function fetchChecksums(id: number, session: AdminSession): Promise<Checksum[]>;
7
9
  interface UpgradeThemeOptions {
8
10
  fromTheme: number;
9
11
  toTheme: number;
@@ -1,22 +1,38 @@
1
- import { storeAdminUrl } from './theme-urls.js';
2
- import { Theme } from './models/theme.js';
1
+ import { storeAdminUrl } from './urls.js';
3
2
  import * as throttler from '../../../private/node/themes/themes-api/throttler.js';
4
3
  import { apiCallLimit, retryAfter } from '../../../private/node/themes/themes-api/headers.js';
5
4
  import { retry } from '../../../private/node/themes/themes-api/retry.js';
6
5
  import { restRequest } from '@shopify/cli-kit/node/api/admin';
7
6
  import { AbortError } from '@shopify/cli-kit/node/error';
7
+ import { buildChecksum, buildTheme, buildThemeAsset } from '@shopify/cli-kit/node/themes/factories';
8
8
  export async function fetchTheme(id, session) {
9
- const response = await request('GET', `/themes/${id}`, session, undefined, { fields: 'id,processing' });
9
+ const response = await request('GET', `/themes/${id}`, session, undefined, { fields: 'id,name,role,processing' });
10
10
  return buildTheme(response.json.theme);
11
11
  }
12
12
  export async function fetchThemes(session) {
13
13
  const response = await request('GET', '/themes', session, undefined, { fields: 'id,name,role,processing' });
14
- return buildThemes(response);
14
+ const themes = response.json?.themes;
15
+ if (themes?.length > 0)
16
+ return themes.map(buildTheme);
17
+ return [];
15
18
  }
16
19
  export async function createTheme(params, session) {
17
20
  const response = await request('POST', '/themes', session, { theme: { ...params } });
18
21
  return buildTheme({ ...response.json.theme, createdAtRuntime: true });
19
22
  }
23
+ export async function fetchThemeAsset(id, key, session) {
24
+ const response = await request('GET', `/themes/${id}/assets`, session, undefined, {
25
+ 'asset[key]': key,
26
+ });
27
+ return buildThemeAsset(response.json.asset);
28
+ }
29
+ export async function fetchChecksums(id, session) {
30
+ const response = await request('GET', `/themes/${id}/assets`, session, undefined, { fields: 'key,checksum' });
31
+ const assets = response.json?.assets;
32
+ if (assets?.length > 0)
33
+ return assets.map(buildChecksum);
34
+ return [];
35
+ }
20
36
  export async function upgradeTheme(upgradeOptions) {
21
37
  const { fromTheme, toTheme, session, script } = upgradeOptions;
22
38
  const params = { from_theme: fromTheme, to_theme: toTheme, ...(script && { script }) };
@@ -70,14 +86,6 @@ function buildThemes(response) {
70
86
  }
71
87
  return [];
72
88
  }
73
- // Using `any` to avoid introducing extra DTO layers.
74
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
75
- function buildTheme(themeJson) {
76
- if (!themeJson?.id) {
77
- return undefined;
78
- }
79
- return new Theme(themeJson.id, themeJson.name, themeJson.role, themeJson.createdAtRuntime, themeJson.processing);
80
- }
81
89
  function handleForbiddenError(session) {
82
90
  const store = session.storeFqdn;
83
91
  const adminUrl = storeAdminUrl(session);
@@ -93,4 +101,4 @@ function handleForbiddenError(session) {
93
101
  function errors(response) {
94
102
  return JSON.stringify(response.json?.errors);
95
103
  }
96
- //# sourceMappingURL=themes-api.js.map
104
+ //# sourceMappingURL=api.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api.js","sourceRoot":"","sources":["../../../../src/public/node/themes/api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,WAAW,CAAA;AACvC,OAAO,KAAK,SAAS,MAAM,sDAAsD,CAAA;AACjF,OAAO,EAAC,YAAY,EAAE,UAAU,EAAC,MAAM,oDAAoD,CAAA;AAC3F,OAAO,EAAC,KAAK,EAAC,MAAM,kDAAkD,CAAA;AACtE,OAAO,EAAC,WAAW,EAAe,MAAM,iCAAiC,CAAA;AAEzE,OAAO,EAAC,UAAU,EAAC,MAAM,6BAA6B,CAAA;AACtD,OA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AM,CAAC,QAAsB;IACpC,OAAO,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,CAAA;AAC9C,CAAC","sourcesContent":["import {storeAdminUrl} from './urls.js'\nimport * as throttler from '../../../private/node/themes/themes-api/throttler.js'\nimport {apiCallLimit, retryAfter} from '../../../private/node/themes/themes-api/headers.js'\nimport {retry} from '../../../private/node/themes/themes-api/retry.js'\nimport {restRequest, RestResponse} from '@shopify/cli-kit/node/api/admin'\nimport {AdminSession} from '@shopify/cli-kit/node/session'\nimport {AbortError} from '@shopify/cli-kit/node/error'\nimport {buildChecksum, buildTheme, buildThemeAsset} from '@shopify/cli-kit/node/themes/factories'\nimport {Checksum, Key, Theme, ThemeAsset} from '@shopify/cli-kit/node/themes/types'\n\nexport type ThemeParams = Partial<Pick<Theme, 'name' | 'role' | 'processing'>>\n\nexport async function fetchTheme(id: number, session: AdminSession): Promise<Theme | undefined> {\n const response = await request('GET', `/themes/${id}`, session, undefined, {fields: 'id,name,role,processing'})\n return buildTheme(response.json.theme)\n}\n\nexport async function fetchThemes(session: AdminSession): Promise<Theme[]> {\n const response = await request('GET', '/themes', session, undefined, {fields: 'id,name,role,processing'})\n const themes = response.json?.themes\n if (themes?.length > 0) return themes.map(buildTheme)\n return []\n}\n\nexport async function createTheme(params: ThemeParams, session: AdminSession): Promise<Theme | undefined> {\n const response = await request('POST', '/themes', session, {theme: {...params}})\n return buildTheme({...response.json.theme, createdAtRuntime: true})\n}\n\nexport async function fetchThemeAsset(id: number, key: Key, session: AdminSession): Promise<ThemeAsset | undefined> {\n const response = await request('GET', `/themes/${id}/assets`, session, undefined, {\n 'asset[key]': key,\n })\n return buildThemeAsset(response.json.asset)\n}\n\nexport async function fetchChecksums(id: number, session: AdminSession): Promise<Checksum[]> {\n const response = await request('GET', `/themes/${id}/assets`, session, undefined, {fields: 'key,checksum'})\n const assets = response.json?.assets\n\n if (assets?.length > 0) return assets.map(buildChecksum)\n\n return []\n}\n\ninterface UpgradeThemeOptions {\n fromTheme: number\n toTheme: number\n script?: string\n session: AdminSession\n}\n\nexport async function upgradeTheme(upgradeOptions: UpgradeThemeOptions): Promise<Theme | undefined> {\n const {fromTheme, toTheme, session, script} = upgradeOptions\n const params = {from_theme: fromTheme, to_theme: toTheme, ...(script && {script})}\n const response = await request('POST', `/themes`, session, params)\n return buildTheme(response.json.theme)\n}\n\nexport async function updateTheme(id: number, params: ThemeParams, session: AdminSession): Promise<Theme | undefined> {\n const response = await request('PUT', `/themes/${id}`, session, {theme: {id, ...params}})\n return buildTheme(response.json.theme)\n}\n\nexport async function publishTheme(id: number, session: AdminSession): Promise<Theme | undefined> {\n return updateTheme(id, {role: 'main'}, session)\n}\n\nexport async function deleteTheme(id: number, session: AdminSession): Promise<Theme | undefined> {\n const response = await request('DELETE', `/themes/${id}`, session)\n return buildTheme(response.json.theme)\n}\n\nasync function request<T>(\n method: string,\n path: string,\n session: AdminSession,\n params?: T,\n searchParams: {[name: string]: string} = {},\n): Promise<RestResponse> {\n const response = await throttler.throttle(() => restRequest(method, path, session, params, searchParams))\n\n const status = response.status\n const callLimit = apiCallLimit(response)\n\n throttler.updateApiCallLimit(callLimit)\n\n switch (true) {\n case status >= 200 && status <= 399:\n // Returns the successful reponse\n return response\n case status === 404:\n // Defer the decision when a resource is not found\n return response\n case status === 429:\n // Retry following the \"retry-after\" header\n return retry(() => request(method, path, session, params, searchParams), retryAfter(response))\n case status === 403:\n return handleForbiddenError(session)\n case status === 401:\n throw new AbortError(`[${status}] API request unauthorized error`)\n case status === 422:\n throw new AbortError(`[${status}] API request unprocessable content: ${errors(response)}`)\n case status >= 400 && status <= 499:\n throw new AbortError(`[${status}] API request client error`)\n case status >= 500 && status <= 599:\n throw new AbortError(`[${status}] API request server error`)\n default:\n throw new AbortError(`[${status}] API request unexpected error`)\n }\n}\n\nfunction buildThemes(response: RestResponse): Theme[] {\n const themes = response.json?.themes\n\n if (themes?.length > 0) {\n return themes.map(buildTheme)\n }\n\n return []\n}\n\nfunction handleForbiddenError(session: AdminSession): never {\n const store = session.storeFqdn\n const adminUrl = storeAdminUrl(session)\n\n throw new AbortError(\n `You are not authorized to edit themes on \"${store}\".`,\n \"You can't use Shopify CLI with development stores if you only have Partner staff \" +\n '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 (for example, using \"${adminUrl}\") before you log in using ` +\n 'Shopify CLI. Logging in to the Shopify admin directly connects the development ' +\n 'store with your Shopify login.',\n )\n}\n\nfunction errors(response: RestResponse) {\n return JSON.stringify(response.json?.errors)\n}\n"]}
@@ -0,0 +1,18 @@
1
+ import { Checksum, Theme, ThemeAsset } from '@shopify/cli-kit/node/themes/types';
2
+ interface RemoteThemeJson {
3
+ id: number;
4
+ name: string;
5
+ role: string;
6
+ createdAtRuntime?: boolean;
7
+ processing?: boolean;
8
+ }
9
+ interface RemoteAssetJson {
10
+ key: string;
11
+ checksum: string;
12
+ attachment: string;
13
+ value: string;
14
+ }
15
+ export declare function buildTheme(themeJson?: RemoteThemeJson): Theme | undefined;
16
+ export declare function buildChecksum(assetJson?: RemoteAssetJson): Checksum | undefined;
17
+ export declare function buildThemeAsset(assetJson?: RemoteAssetJson): ThemeAsset | undefined;
18
+ export {};
@@ -0,0 +1,27 @@
1
+ export function buildTheme(themeJson) {
2
+ if (!themeJson)
3
+ return;
4
+ themeJson.processing ?? (themeJson.processing = false);
5
+ themeJson.createdAtRuntime ?? (themeJson.createdAtRuntime = false);
6
+ const { id, name, role, processing, createdAtRuntime } = themeJson;
7
+ return {
8
+ id,
9
+ name,
10
+ processing,
11
+ createdAtRuntime,
12
+ role: role === 'main' ? 'live' : role,
13
+ };
14
+ }
15
+ export function buildChecksum(assetJson) {
16
+ if (!assetJson)
17
+ return;
18
+ const { key, checksum } = assetJson;
19
+ return { key, checksum };
20
+ }
21
+ export function buildThemeAsset(assetJson) {
22
+ if (!assetJson)
23
+ return;
24
+ const { key, checksum, attachment, value } = assetJson;
25
+ return { key, checksum, attachment, value };
26
+ }
27
+ //# sourceMappingURL=factories.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"factories.js","sourceRoot":"","sources":["../../../../src/public/node/themes/factories.ts"],"names":[],"mappings":"AAiBA,MAAM,UAAU,UAAU,CAAC,SAA2B;IACpD,IAAI,CAAC,SAAS;QAAE,OAAM;IAEtB,SAAS,CAAC,UAAU,KAApB,SAAS,CAAC,UAAU,GAAK,KAAK,EAAA;IAC9B,SAAS,CAAC,gBAAgB,KAA1B,SAAS,CAAC,gBAAgB,GAAK,KAAK,EAAA;IAEpC,MAAM,EAAC,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,gBAAgB,EAAC,GAAG,SAAS,CAAA;IAEhE,OAAO;QACL,EAAE;QACF,IAAI;QACJ,UAAU;QACV,gBAAgB;QAChB,IAAI,EAAE,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI;KACtC,CAAA;AACH,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,SAA2B;IACvD,IAAI,CAAC,SAAS;QAAE,OAAM;IAEtB,MAAM,EAAC,GAAG,EAAE,QAAQ,EAAC,GAAG,SAAS,CAAA;IACjC,OAAO,EAAC,GAAG,EAAE,QAAQ,EAAC,CAAA;AACxB,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,SAA2B;IACzD,IAAI,CAAC,SAAS;QAAE,OAAM;IAEtB,MAAM,EAAC,GAAG,EAAE,QAAQ,EAAE,UAAU,EAAE,KAAK,EAAC,GAAG,SAAS,CAAA;IACpD,OAAO,EAAC,GAAG,EAAE,QAAQ,EAAE,UAAU,EAAE,KAAK,EAAC,CAAA;AAC3C,CAAC","sourcesContent":["import {Checksum, Theme, ThemeAsset} from '@shopify/cli-kit/node/themes/types'\n\ninterface RemoteThemeJson {\n id: number\n name: string\n role: string\n createdAtRuntime?: boolean\n processing?: boolean\n}\n\ninterface RemoteAssetJson {\n key: string\n checksum: string\n attachment: string\n value: string\n}\n\nexport function buildTheme(themeJson?: RemoteThemeJson): Theme | undefined {\n if (!themeJson) return\n\n themeJson.processing ??= false\n themeJson.createdAtRuntime ??= false\n\n const {id, name, role, processing, createdAtRuntime} = themeJson\n\n return {\n id,\n name,\n processing,\n createdAtRuntime,\n role: role === 'main' ? 'live' : role,\n }\n}\n\nexport function buildChecksum(assetJson?: RemoteAssetJson): Checksum | undefined {\n if (!assetJson) return\n\n const {key, checksum} = assetJson\n return {key, checksum}\n}\n\nexport function buildThemeAsset(assetJson?: RemoteAssetJson): ThemeAsset | undefined {\n if (!assetJson) return\n\n const {key, checksum, attachment, value} = assetJson\n return {key, checksum, attachment, value}\n}\n"]}
@@ -1,5 +1,5 @@
1
- import { Theme } from './models/theme.js';
2
1
  import { AdminSession } from '@shopify/cli-kit/node/session';
2
+ import { Theme } from '@shopify/cli-kit/node/themes/types';
3
3
  export declare abstract class ThemeManager {
4
4
  protected adminSession: AdminSession;
5
5
  protected themeId: string | undefined;
@@ -1,7 +1,7 @@
1
- import { fetchTheme, createTheme } from './themes-api.js';
2
- import { DEVELOPMENT_THEME_ROLE } from './models/theme.js';
1
+ import { fetchTheme, createTheme } from './api.js';
3
2
  import { generateThemeName } from '../../../private/node/themes/generate-theme-name.js';
4
3
  import { BugError } from '@shopify/cli-kit/node/error';
4
+ import { DEVELOPMENT_THEME_ROLE } from '@shopify/cli-kit/node/themes/utils';
5
5
  export class ThemeManager {
6
6
  constructor(adminSession) {
7
7
  this.adminSession = adminSession;
@@ -1 +1 @@
1
- {"version":3,"file":"theme-manager.js","sourceRoot":"","sources":["../../../../src/public/node/themes/theme-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAE,WAAW,EAAC,MAAM,iBAAiB,CAAA;AACvD,OAAO,EAAC,sBAAsB,EAAQ,MAAM,mBAAmB,CAAA;AAC/D,OAAO,EAAC,iB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E, Theme} from './models/theme.js'\nimport {generateThemeName} from '../../../private/node/themes/generate-theme-name.js'\nimport {AdminSession} from '@shopify/cli-kit/node/session'\nimport {BugError} from '@shopify/cli-kit/node/error'\n\nexport abstract class ThemeManager {\n protected themeId: string | undefined\n protected abstract setTheme(themeId: string): void\n protected abstract removeTheme(): void\n protected abstract context: string\n\n constructor(protected adminSession: AdminSession) {}\n\n async findOrCreate(): Promise<Theme> {\n let theme = await this.fetch()\n if (!theme) {\n theme = await this.create()\n }\n return theme\n }\n\n async fetch() {\n if (!this.themeId) {\n return\n }\n const theme = await fetchTheme(parseInt(this.themeId, 10), this.adminSession)\n if (!theme) {\n this.removeTheme()\n }\n return theme\n }\n\n private async create() {\n const name = generateThemeName(this.context)\n const role = DEVELOPMENT_THEME_ROLE\n const theme = await createTheme(\n {\n name,\n role,\n },\n this.adminSession,\n )\n if (!theme) {\n throw new BugError(`Could not create theme with name \"${name}\" and role \"${role}\"`)\n }\n this.setTheme(theme.id.toString())\n return theme\n }\n}\n"]}
1
+ {"version":3,"file":"theme-manager.js","sourceRoot":"","sources":["../../../../src/public/node/themes/theme-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAE,WAAW,EAAC,MAAM,UAAU,CAAA;AAChD,OAAO,EAAC,iBAAiB,EAAC,MAAM,qDAAqD,CAAA;AAErF,OAAO,EAAC,QAAQ,EAAC,MAAM,6BAA6B,CAAA;AAEpD,OAAO,EAAC,sBAAsB,EAAC,MAAM,oCAAoC,CAAA;AAEzE,MAAM,OAAgB,YAAY;IAMhC,YAAsB,YAA0B;QAA1B,iBAAY,GAAZ,YAAY,CAAc;IAAG,CAAC;IAEpD,KAAK,CAAC,YAAY;QAChB,IAAI,KAAK,GAAG,MAAM,IAAI,CAAC,KAAK,EAAE,CAAA;QAC9B,IAAI,CAAC,KAAK,EAAE;YACV,KAAK,GAAG,MAAM,IAAI,CAAC,MAAM,EAAE,CAAA;SAC5B;QACD,OAAO,KAAK,CAAA;IACd,CAAC;IAED,KAAK,CAAC,KAAK;QACT,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE;YACjB,OAAM;SACP;QACD,MAAM,KAAK,GAAG,MAAM,UAAU,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,CAAC,EAAE,IAAI,CAAC,YAAY,CAAC,CAAA;QAC7E,IAAI,CAAC,KAAK,EAAE;YACV,IAAI,CAAC,WAAW,EAAE,CAAA;SACnB;QACD,OAAO,KAAK,CAAA;IACd,CAAC;IAEO,KAAK,CAAC,MAAM;QAClB,MAAM,IAAI,GAAG,iBAAiB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;QAC5C,MAAM,IAAI,GAAG,sBAAsB,CAAA;QACnC,MAAM,KAAK,GAAG,MAAM,WAAW,CAC7B;YACE,IAAI;YACJ,IAAI;SACL,EACD,IAAI,CAAC,YAAY,CAClB,CAAA;QACD,IAAI,CAAC,KAAK,EAAE;YACV,MAAM,IAAI,QAAQ,CAAC,qCAAqC,IAAI,eAAe,IAAI,GAAG,CAAC,CAAA;SACpF;QACD,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC,QAAQ,EAAE,CAAC,CAAA;QAClC,OAAO,KAAK,CAAA;IACd,CAAC;CACF","sourcesContent":["import {fetchTheme, createTheme} from './api.js'\nimport {generateThemeName} from '../../../private/node/themes/generate-theme-name.js'\nimport {AdminSession} from '@shopify/cli-kit/node/session'\nimport {BugError} from '@shopify/cli-kit/node/error'\nimport {Theme} from '@shopify/cli-kit/node/themes/types'\nimport {DEVELOPMENT_THEME_ROLE} from '@shopify/cli-kit/node/themes/utils'\n\nexport abstract class ThemeManager {\n protected themeId: string | undefined\n protected abstract setTheme(themeId: string): void\n protected abstract removeTheme(): void\n protected abstract context: string\n\n constructor(protected adminSession: AdminSession) {}\n\n async findOrCreate(): Promise<Theme> {\n let theme = await this.fetch()\n if (!theme) {\n theme = await this.create()\n }\n return theme\n }\n\n async fetch() {\n if (!this.themeId) {\n return\n }\n const theme = await fetchTheme(parseInt(this.themeId, 10), this.adminSession)\n if (!theme) {\n this.removeTheme()\n }\n return theme\n }\n\n private async create() {\n const name = generateThemeName(this.context)\n const role = DEVELOPMENT_THEME_ROLE\n const theme = await createTheme(\n {\n name,\n role,\n },\n this.adminSession,\n )\n if (!theme) {\n throw new BugError(`Could not create theme with name \"${name}\" and role \"${role}\"`)\n }\n this.setTheme(theme.id.toString())\n return theme\n }\n}\n"]}
@@ -0,0 +1,68 @@
1
+ /**
2
+ * {@link Key} represents the unique identifier of a file in a theme.
3
+ */
4
+ export type Key = string;
5
+ /**
6
+ * Represents a theme on the file system.
7
+ */
8
+ export interface ThemeFileSystem {
9
+ /**
10
+ * The root path of the theme.
11
+ */
12
+ root: string;
13
+ /**
14
+ * Local theme files.
15
+ */
16
+ files: Map<Key, ThemeAsset>;
17
+ }
18
+ /**
19
+ * Represents a theme.
20
+ */
21
+ export interface Theme {
22
+ /**
23
+ * The remote ID of the theme.
24
+ */
25
+ id: number;
26
+ /**
27
+ * The remote name of the theme.
28
+ */
29
+ name: string;
30
+ /**
31
+ * A boolean determining whether or not the theme was created at runtime.
32
+ */
33
+ createdAtRuntime: boolean;
34
+ /**
35
+ * A boolean determining if the theme is processing at the theme library.
36
+ */
37
+ processing: boolean;
38
+ /**
39
+ * The remote role of the theme.
40
+ */
41
+ role: string;
42
+ }
43
+ /**
44
+ * Represents the remote checksum for a file in a theme.
45
+ */
46
+ export interface Checksum {
47
+ /**
48
+ * Identifier of the theme file.
49
+ */
50
+ key: Key;
51
+ /**
52
+ * Reresents the checksum value of the theme file.
53
+ */
54
+ checksum: string;
55
+ }
56
+ /**
57
+ * Represents a file in a theme.
58
+ */
59
+ export interface ThemeAsset extends Checksum {
60
+ /**
61
+ * A base64-encoded image.
62
+ */
63
+ attachment?: string;
64
+ /**
65
+ * The text content of the asset, such as the HTML and Liquid markup of a template file.
66
+ */
67
+ value?: string;
68
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/public/node/themes/types.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * {@link Key} represents the unique identifier of a file in a theme.\n */\nexport type Key = string\n\n/**\n * Represents a theme on the file system.\n */\nexport interface ThemeFileSystem {\n /**\n * The root path of the theme.\n */\n root: string\n\n /**\n * Local theme files.\n */\n files: Map<Key, ThemeAsset>\n}\n\n/**\n * Represents a theme.\n */\nexport interface Theme {\n /**\n * The remote ID of the theme.\n */\n id: number\n\n /**\n * The remote name of the theme.\n */\n name: string\n\n /**\n * A boolean determining whether or not the theme was created at runtime.\n */\n createdAtRuntime: boolean\n\n /**\n * A boolean determining if the theme is processing at the theme library.\n */\n processing: boolean\n\n /**\n * The remote role of the theme.\n */\n role: string\n}\n\n/**\n * Represents the remote checksum for a file in a theme.\n */\nexport interface Checksum {\n /**\n * Identifier of the theme file.\n */\n key: Key\n\n /**\n * Reresents the checksum value of the theme file.\n */\n checksum: string\n}\n\n/**\n * Represents a file in a theme.\n */\nexport interface ThemeAsset extends Checksum {\n /**\n * A base64-encoded image.\n */\n attachment?: string\n\n /**\n * The text content of the asset, such as the HTML and Liquid markup of a template file.\n */\n value?: string\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { Theme } from '@shopify/cli-kit/node/themes/models/theme';
1
+ import { Theme } from '@shopify/cli-kit/node/themes/types';
2
2
  import { AdminSession } from '@shopify/cli-kit/node/session';
3
3
  export declare function themePreviewUrl(theme: Theme, session: AdminSession): string;
4
4
  export declare function themeEditorUrl(theme: Theme, session: AdminSession): string;
@@ -17,4 +17,4 @@ export function storeAdminUrl(session) {
17
17
  const store = session.storeFqdn;
18
18
  return `https://${store}/admin`;
19
19
  }
20
- //# sourceMappingURL=theme-urls.js.map
20
+ //# sourceMappingURL=urls.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"urls.js","sourceRoot":"","sources":["../../../../src/public/node/themes/urls.ts"],"names":[],"mappings":"AAGA,MAAM,UAAU,eAAe,CAAC,KAAY,EAAE,OAAqB;IACjE,MAAM,KAAK,GAAG,OAAO,CAAC,SAAS,CAAA;IAC/B,IAAI,KAAK,CAAC,IAAI,KAAK,MAAM,EAAE;QACzB,OAAO,WAAW,KAAK,EAAE,CAAA;KAC1B;IAED,OAAO,WAAW,KAAK,qBAAqB,KAAK,CAAC,EAAE,EAAE,CAAA;AACxD,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,KAAY,EAAE,OAAqB;IAChE,MAAM,KAAK,GAAG,OAAO,CAAC,SAAS,CAAA;IAC/B,OAAO,WAAW,KAAK,iBAAiB,KAAK,CAAC,EAAE,SAAS,CAAA;AAC3D,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,KAAY,EAAE,OAAqB;IAC/D,MAAM,KAAK,GAAG,OAAO,CAAC,SAAS,CAAA;IAC/B,OAAO,WAAW,KAAK,iBAAiB,KAAK,CAAC,EAAE,EAAE,CAAA;AACpD,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,OAAqB;IACjD,MAAM,KAAK,GAAG,OAAO,CAAC,SAAS,CAAA;IAC/B,OAAO,WAAW,KAAK,QAAQ,CAAA;AACjC,CAAC","sourcesContent":["import {Theme} from '@shopify/cli-kit/node/themes/types'\nimport {AdminSession} from '@shopify/cli-kit/node/session'\n\nexport function themePreviewUrl(theme: Theme, session: AdminSession) {\n const store = session.storeFqdn\n if (theme.role === 'live') {\n return `https://${store}`\n }\n\n return `https://${store}?preview_theme_id=${theme.id}`\n}\n\nexport function themeEditorUrl(theme: Theme, session: AdminSession) {\n const store = session.storeFqdn\n return `https://${store}/admin/themes/${theme.id}/editor`\n}\n\nexport function codeEditorUrl(theme: Theme, session: AdminSession) {\n const store = session.storeFqdn\n return `https://${store}/admin/themes/${theme.id}`\n}\n\nexport function storeAdminUrl(session: AdminSession) {\n const store = session.storeFqdn\n return `https://${store}/admin`\n}\n"]}
@@ -0,0 +1,3 @@
1
+ import { Theme } from '@shopify/cli-kit/node/themes/types';
2
+ export declare const DEVELOPMENT_THEME_ROLE = "development";
3
+ export declare function isDevelopmentTheme(theme: Theme): boolean;
@@ -0,0 +1,5 @@
1
+ export const DEVELOPMENT_THEME_ROLE = 'development';
2
+ export function isDevelopmentTheme(theme) {
3
+ return theme.role === DEVELOPMENT_THEME_ROLE;
4
+ }
5
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../src/public/node/themes/utils.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,sBAAsB,GAAG,aAAa,CAAA;AAEnD,MAAM,UAAU,kBAAkB,CAAC,KAAY;IAC7C,OAAO,KAAK,CAAC,IAAI,KAAK,sBAAsB,CAAA;AAC9C,CAAC","sourcesContent":["import {Theme} from '@shopify/cli-kit/node/themes/types'\n\nexport const DEVELOPMENT_THEME_ROLE = 'development'\n\nexport function isDevelopmentTheme(theme: Theme) {\n return theme.role === DEVELOPMENT_THEME_ROLE\n}\n"]}