@decocms/apps-nuvemshop 7.74.1 → 7.75.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@decocms/apps-nuvemshop",
3
- "version": "7.74.1",
3
+ "version": "7.75.0",
4
4
  "type": "module",
5
5
  "description": "Deco commerce app: Nuvemshop (Tiendanube) Storefront API integration",
6
6
  "repository": {
@@ -30,8 +30,9 @@
30
30
  "lint:unused": "knip"
31
31
  },
32
32
  "dependencies": {
33
- "@decocms/blocks": "7.74.1",
34
- "@decocms/apps-commerce": "7.74.1"
33
+ "@decocms/blocks": "7.75.0",
34
+ "@decocms/apps-commerce": "7.75.0",
35
+ "@decocms/apps-website": "7.75.0"
35
36
  },
36
37
  "peerDependencies": {
37
38
  "react": "^19.0.0"
@@ -1,6 +1,6 @@
1
1
  import { describe, expect, it } from "vitest";
2
2
  import { getNuvemshopConfig } from "../client";
3
- import { configure } from "../mod";
3
+ import NuvemshopApp, { configure, type Props } from "../mod";
4
4
  import { nuvemshopOperationRouter } from "../utils/operationRouter";
5
5
 
6
6
  const noSecret = async () => null;
@@ -34,6 +34,25 @@ describe("configure", () => {
34
34
  });
35
35
  });
36
36
 
37
+ describe("CMS Props (admin form for the deco-nuvemshop block)", () => {
38
+ it("is the shape configure() reads, and is the default export's input", async () => {
39
+ const props: Props = {
40
+ storeId: "8336778",
41
+ currency: "ARS",
42
+ defaultSort: "price-ascending",
43
+ apiVersion: "v2026-11",
44
+ };
45
+ expect(NuvemshopApp(props)).toEqual({ state: props });
46
+ await configure({ ...props }, noSecret);
47
+ expect(getNuvemshopConfig()).toMatchObject({
48
+ storeId: "8336778",
49
+ currency: "ARS",
50
+ defaultSort: "price-ascending",
51
+ apiVersion: "v2026-11",
52
+ });
53
+ });
54
+ });
55
+
37
56
  describe("nuvemshopOperationRouter", () => {
38
57
  const base = "https://storefront-api.tiendanube.com/v2026-11/stores/1";
39
58
  it.each([
package/src/mod.ts CHANGED
@@ -9,8 +9,45 @@
9
9
  * production — see `client.ts` for the rate-limit trade-off.
10
10
  */
11
11
  import type { AppDefinition, ResolveSecretFn } from "@decocms/apps-commerce/app-types";
12
+ import type { Secret } from "@decocms/apps-website/mod";
12
13
  import { configureNuvemshop, type NuvemshopConfig } from "./client";
13
14
  import manifest from "./manifest.gen";
15
+ import type { SortValue } from "./utils/listing";
16
+
17
+ // -------------------------------------------------------------------------
18
+ // CMS Props — the admin form for the `deco-nuvemshop` block. Sites expose it
19
+ // through a bridge (`src/apps/nuvemshop.ts` re-exporting this module's default
20
+ // and `Props`); generate-schema builds the form from this interface.
21
+ // -------------------------------------------------------------------------
22
+
23
+ /** @title Nuvemshop */
24
+ export interface Props {
25
+ /**
26
+ * @title Store ID
27
+ * @description Numeric Nuvemshop/Tiendanube store id (e.g. 8336778).
28
+ */
29
+ storeId: string;
30
+ /**
31
+ * @title Storefront token
32
+ * @description Optional. Without it all buyers share 120 req/min per IP; with it the store gets 1,200 req/min.
33
+ */
34
+ token?: Secret;
35
+ /**
36
+ * @title Currency
37
+ * @description The API returns no currency. @default BRL
38
+ */
39
+ currency?: string;
40
+ /**
41
+ * @title Default category sort
42
+ * @description The API doesn't expose the category's configured sort. @default created-descending
43
+ */
44
+ defaultSort?: SortValue;
45
+ /**
46
+ * @title API version
47
+ * @default v2026-11
48
+ */
49
+ apiVersion?: string;
50
+ }
14
51
 
15
52
  export interface NuvemshopState {
16
53
  config: NuvemshopConfig;
@@ -40,3 +77,8 @@ export async function configure(
40
77
  }
41
78
 
42
79
  export const preview = undefined;
80
+
81
+ /** Default export for schema generation and app bridges. */
82
+ export default function Nuvemshop(props: Props) {
83
+ return { state: props };
84
+ }
@@ -22,7 +22,17 @@ export const LISTING_WINDOW = 200;
22
22
  * The theme's "user" (merchant's manual order) isn't in the API, so it's not
23
23
  * offered; `?sort_by=user` falls back to the default sort.
24
24
  */
25
- export const SORT_OPTIONS: SortOption[] = [
25
+ export type SortValue =
26
+ | "best-selling"
27
+ | "price-ascending"
28
+ | "price-descending"
29
+ | "alpha-ascending"
30
+ | "alpha-descending"
31
+ | "created-descending"
32
+ | "created-ascending"
33
+ | "discount-descending";
34
+
35
+ export const SORT_OPTIONS: (SortOption & { value: SortValue })[] = [
26
36
  { value: "best-selling", label: "Mais vendidos" },
27
37
  { value: "price-ascending", label: "Menor preço" },
28
38
  { value: "price-descending", label: "Maior preço" },