@swishapp/sdk 0.133.0 → 0.134.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/dist/types.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { GetProductQuery, SwishApp } from "./swish";
1
+ import type { GetProductQuery, SwishApp, SwishOptions } from "./swish";
2
2
  export interface SwishUiManifest {
3
3
  scripts: Record<string, string>;
4
4
  prerender: Record<string, string>;
@@ -18,5 +18,23 @@ declare global {
18
18
  swish: SwishApp;
19
19
  }
20
20
  }
21
- export type Product = NonNullable<GetProductQuery["product"]>;
22
- export type ProductVariant = NonNullable<GetProductQuery["variantNode"]>;
21
+ /**
22
+ * Product and variant metafields keyed by `namespace`, then by `key`.
23
+ *
24
+ * @example
25
+ * product.metafields.custom?.combined_listing_parent
26
+ * product.metafields["$app:swish"]?.setup
27
+ */
28
+ export type Metafields = Record<string, Record<string, string>>;
29
+ type RawProduct = NonNullable<GetProductQuery["product"]>;
30
+ type RawProductVariant = NonNullable<GetProductQuery["variantNode"]>;
31
+ export type ProductVariant = Omit<RawProductVariant, "metafields"> & {
32
+ metafields: Metafields;
33
+ };
34
+ export type Product = Omit<RawProduct, "metafields" | "selectedOrFirstAvailableVariant" | "variant"> & {
35
+ metafields: Metafields;
36
+ selectedOrFirstAvailableVariant: ProductVariant | null;
37
+ variant?: ProductVariant | null;
38
+ };
39
+ export type PreviewOptions = Omit<SwishOptions, "auth" | "storefront" | "context">;
40
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@swishapp/sdk",
3
- "version": "0.133.0",
3
+ "version": "0.134.0",
4
4
  "description": "JS SDK for Swish.",
5
5
  "author": "Swish",
6
6
  "license": "UNLICENSED",
@@ -20,11 +20,11 @@
20
20
  "@swishapp/api-client": "0.43.0"
21
21
  },
22
22
  "devDependencies": {
23
- "@shopify/api-codegen-preset": "^1.2.2",
23
+ "@graphql-codegen/cli": "^7.0.0",
24
+ "@shopify/api-codegen-preset": "^2.0.0",
24
25
  "concurrently": "^9.2.1",
25
26
  "esbuild": "^0.27.2",
26
- "graphql-codegen": "^0.4.0",
27
- "graphql-config": "^5.1.5",
27
+ "graphql-config": "^5.1.6",
28
28
  "rimraf": "^6.1.2",
29
29
  "typescript": "^5.9.3"
30
30
  },