@forgecart/cli 2.202610071755.0 → 2.202610082355.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 (26) hide show
  1. package/dist/src/authorization/cli-authorization-flow.d.ts +55 -0
  2. package/dist/src/authorization/cli-authorization-flow.js +175 -0
  3. package/dist/src/authorization/cli-authorization-flow.js.map +1 -0
  4. package/dist/src/authorization/cli-authorization.client.d.ts +36 -0
  5. package/dist/src/authorization/cli-authorization.client.js +169 -0
  6. package/dist/src/authorization/cli-authorization.client.js.map +1 -0
  7. package/dist/src/authorization/cli-credential-check.d.ts +42 -0
  8. package/dist/src/authorization/cli-credential-check.js +157 -0
  9. package/dist/src/authorization/cli-credential-check.js.map +1 -0
  10. package/dist/src/authorization/cli-unauthorized-refusal.d.ts +21 -0
  11. package/dist/src/authorization/cli-unauthorized-refusal.js +33 -0
  12. package/dist/src/authorization/cli-unauthorized-refusal.js.map +1 -0
  13. package/dist/src/authorization/type/cli-authorization.types.d.ts +55 -0
  14. package/dist/src/authorization/type/cli-authorization.types.js +24 -0
  15. package/dist/src/authorization/type/cli-authorization.types.js.map +1 -0
  16. package/dist/src/commands/init.d.ts +41 -14
  17. package/dist/src/commands/init.js +131 -23
  18. package/dist/src/commands/init.js.map +1 -1
  19. package/dist/src/exit-ladder.d.ts +8 -1
  20. package/dist/src/exit-ladder.js +7 -0
  21. package/dist/src/exit-ladder.js.map +1 -1
  22. package/package.json +1 -1
  23. package/templates/storefront/README.md +6 -2
  24. package/templates/storefront/src/server/forgecart/forgecart-client.factory.ts +11 -7
  25. package/templates/storefront-shadcn/README.md +6 -2
  26. package/templates/storefront-shadcn/src/server/forgecart/forgecart-client.factory.ts +11 -7
@@ -13,15 +13,19 @@ To migrate a storefront built before the locale and SEO layer, follow [`SEO-MIGR
13
13
 
14
14
  ## Configuration
15
15
 
16
- The storefront reads three environment variables (server-side only):
16
+ The storefront reads four environment variables (server-side only):
17
17
 
18
18
  | Variable | Purpose |
19
19
  | ------------------------- | -------------------------------------------------------------- |
20
20
  | `FORGECART_CHANNEL_TOKEN` | Identifies the channel; sent as the `forgecart-token` header. |
21
21
  | `FORGECART_SHOP_API_URL` | Base URL of the channel's shop GraphQL API (`.../shop-api`). |
22
22
  | `FORGECART_ADMIN_SECRET` | Channel admin secret for server-side admin operations. |
23
+ | `FORGECART_ADMIN_API_URL` | URL of the channel's admin GraphQL API (`.../admin-api`). |
23
24
 
24
- `forgecart init` writes all of them to `.env` — it is the sole author of that
25
+ `forgecart init` looks for all four in the environment, `.env` and
26
+ `.forgecart/config.json`; when any is missing it opens the dashboard's
27
+ `/authorize` page, and the approval delivers them. Either way it writes all of
28
+ them to `.env` — it is the sole author of that
25
29
  file, and `.env` is the only env file this project ever has (no `.env.example`,
26
30
  no `.env.local`). None of the values ever reaches the
27
31
  browser: every module that constructs an SDK client starts with
@@ -6,8 +6,12 @@ import { Injectable } from '@nestjs/common';
6
6
  const SHOP_API_URL = process.env.FORGECART_SHOP_API_URL ?? '';
7
7
  const CHANNEL_TOKEN = process.env.FORGECART_CHANNEL_TOKEN ?? '';
8
8
  const ADMIN_SECRET = process.env.FORGECART_ADMIN_SECRET ?? '';
9
- /** The admin API is the shop API's sibling endpoint on the same host. */
10
- const ADMIN_API_URL = SHOP_API_URL.replace(/\/shop-api$/, '/admin-api');
9
+ /**
10
+ * The admin API endpoint, read like the other three: `forgecart init` writes
11
+ * the URL the platform delivered, so a deployment free to choose its API paths
12
+ * never has it guessed from the shop URL.
13
+ */
14
+ const ADMIN_API_URL = process.env.FORGECART_ADMIN_API_URL ?? '';
11
15
 
12
16
  /**
13
17
  * SDK clients for backend methods. The generated SDK is graphql-ws, so
@@ -21,13 +25,13 @@ export class ForgeCartClientFactory {
21
25
 
22
26
  /**
23
27
  * Whether the backend gate is fully configured: `forgecart init` wrote all
24
- * three env values AND the admin endpoint is derivable from the shop URL.
25
- * False during the image-build pre-warm (which renders with no env) — the
26
- * runner then answers with a typed envelope instead of driving doomed
27
- * clients, keeping the pre-warm contract (serve, never crash) intact.
28
+ * four env values. False during the image-build pre-warm (which renders
29
+ * with no env) — the runner then answers with a typed envelope instead of
30
+ * driving doomed clients, keeping the pre-warm contract (serve, never crash)
31
+ * intact.
28
32
  */
29
33
  isConfigured(): boolean {
30
- return Boolean(SHOP_API_URL && CHANNEL_TOKEN && ADMIN_SECRET && ADMIN_API_URL !== SHOP_API_URL);
34
+ return Boolean(SHOP_API_URL && CHANNEL_TOKEN && ADMIN_SECRET && ADMIN_API_URL);
31
35
  }
32
36
 
33
37
  /**
@@ -14,15 +14,19 @@ To migrate a storefront built before the locale and SEO layer, follow [`SEO-MIGR
14
14
 
15
15
  ## Configuration
16
16
 
17
- The storefront reads three environment variables (server-side only):
17
+ The storefront reads four environment variables (server-side only):
18
18
 
19
19
  | Variable | Purpose |
20
20
  | ------------------------- | -------------------------------------------------------------- |
21
21
  | `FORGECART_CHANNEL_TOKEN` | Identifies the channel; sent as the `forgecart-token` header. |
22
22
  | `FORGECART_SHOP_API_URL` | Base URL of the channel's shop GraphQL API (`.../shop-api`). |
23
23
  | `FORGECART_ADMIN_SECRET` | Channel admin secret for server-side admin operations. |
24
+ | `FORGECART_ADMIN_API_URL` | URL of the channel's admin GraphQL API (`.../admin-api`). |
24
25
 
25
- `forgecart init` writes all of them to `.env` — it is the sole author of that
26
+ `forgecart init` looks for all four in the environment, `.env` and
27
+ `.forgecart/config.json`; when any is missing it opens the dashboard's
28
+ `/authorize` page, and the approval delivers them. Either way it writes all of
29
+ them to `.env` — it is the sole author of that
26
30
  file, and `.env` is the only env file this project ever has (no `.env.example`,
27
31
  no `.env.local`). None of the values ever reaches the
28
32
  browser: every module that constructs an SDK client starts with
@@ -6,8 +6,12 @@ import { Injectable } from '@nestjs/common';
6
6
  const SHOP_API_URL = process.env.FORGECART_SHOP_API_URL ?? '';
7
7
  const CHANNEL_TOKEN = process.env.FORGECART_CHANNEL_TOKEN ?? '';
8
8
  const ADMIN_SECRET = process.env.FORGECART_ADMIN_SECRET ?? '';
9
- /** The admin API is the shop API's sibling endpoint on the same host. */
10
- const ADMIN_API_URL = SHOP_API_URL.replace(/\/shop-api$/, '/admin-api');
9
+ /**
10
+ * The admin API endpoint, read like the other three: `forgecart init` writes
11
+ * the URL the platform delivered, so a deployment free to choose its API paths
12
+ * never has it guessed from the shop URL.
13
+ */
14
+ const ADMIN_API_URL = process.env.FORGECART_ADMIN_API_URL ?? '';
11
15
 
12
16
  /**
13
17
  * SDK clients for backend methods. The generated SDK is graphql-ws, so
@@ -21,13 +25,13 @@ export class ForgeCartClientFactory {
21
25
 
22
26
  /**
23
27
  * Whether the backend gate is fully configured: `forgecart init` wrote all
24
- * three env values AND the admin endpoint is derivable from the shop URL.
25
- * False during the image-build pre-warm (which renders with no env) — the
26
- * runner then answers with a typed envelope instead of driving doomed
27
- * clients, keeping the pre-warm contract (serve, never crash) intact.
28
+ * four env values. False during the image-build pre-warm (which renders
29
+ * with no env) — the runner then answers with a typed envelope instead of
30
+ * driving doomed clients, keeping the pre-warm contract (serve, never crash)
31
+ * intact.
28
32
  */
29
33
  isConfigured(): boolean {
30
- return Boolean(SHOP_API_URL && CHANNEL_TOKEN && ADMIN_SECRET && ADMIN_API_URL !== SHOP_API_URL);
34
+ return Boolean(SHOP_API_URL && CHANNEL_TOKEN && ADMIN_SECRET && ADMIN_API_URL);
31
35
  }
32
36
 
33
37
  /**