@doswiftly/storefront-operations 22.5.1 → 22.8.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/AGENTS.md CHANGED
@@ -27,7 +27,7 @@ consumer's `codegen.ts` references this package's `.graphql` files as
27
27
  live in the consumer's repo.
28
28
 
29
29
  <!-- AUTOGEN:STATS:BEGIN — auto-regenerated, do not edit by hand -->
30
- - **Schema version**: 22.5.1
30
+ - **Schema version**: 22.8.0
31
31
  - **Queries**: 52
32
32
  - **Mutations**: 44
33
33
  - **Fragments**: 105
package/CHANGELOG.md CHANGED
@@ -1,5 +1,78 @@
1
1
  # Changelog
2
2
 
3
+ ## 22.8.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 9039ba1: Add `getAssetPrefix()` for serving your build's static assets from a CDN domain.
8
+
9
+ **Why**: A build's JavaScript, CSS, and font files (`/_next/static/*`) are content-hashed and immutable. Serving them from a CDN domain — rather than your app origin — makes them cache-friendly and keeps them off your storefront server's request path.
10
+
11
+ **Additive (backward-compatible)**: a new export from `@doswiftly/storefront-sdk/next`. Nothing changes until you opt in.
12
+
13
+ **Usage** — add two lines to `next.config`:
14
+
15
+ ```ts
16
+ // next.config.ts
17
+ import { getAssetPrefix } from "@doswiftly/storefront-sdk/next";
18
+
19
+ const nextConfig = {
20
+ assetPrefix: getAssetPrefix(),
21
+ crossOrigin: "anonymous",
22
+ // ...your existing config
23
+ };
24
+ export default nextConfig;
25
+ ```
26
+
27
+ `getAssetPrefix()` returns the CDN base injected by the deploy pipeline (namespaced to your shop), or `undefined` in development and on deploys without a CDN configured — so `next dev` and un-provisioned deploys keep serving assets from the app origin. Pair it with `crossOrigin: 'anonymous'`: the assets then load cross-origin and the CDN sends the matching CORS header (required for fonts).
28
+
29
+ **Migration checklist for existing storefronts**:
30
+ - [ ] Add `assetPrefix: getAssetPrefix()` and `crossOrigin: 'anonymous'` to `next.config`.
31
+ - [ ] Redeploy — the next build's static assets are served from the CDN.
32
+
33
+ (`@doswiftly/storefront-operations` is version-synced with the SDK; no operation changes in this release.)
34
+
35
+ ## 22.6.0
36
+
37
+ ### Minor Changes
38
+
39
+ - b1e622d: Add a zero-config Next.js image loader. Re-export `createImageLoader()` from the new
40
+ `@doswiftly/storefront-sdk/next` entry in your `images.loaderFile` and every `<Image>`
41
+ is routed through the image CDN: product images get a real responsive `srcset` (a width
42
+ per entry, so you can drop `transform: { maxWidth }`) and local `public/` images are
43
+ resized and format-negotiated (AVIF/WebP) instead of shipped at full size. Build assets,
44
+ external / protocol-relative URLs and `data:` URIs pass through untouched, and
45
+ `<Image quality>` is a no-op (quality is applied server-side; the format is auto-negotiated). The pure
46
+ `buildImageLoaderUrl` helper is also exported from the package root for non-`<Image>` use.
47
+
48
+ Usage:
49
+
50
+ ```ts
51
+ // lib/image-loader.ts
52
+ import { createImageLoader } from "@doswiftly/storefront-sdk/next";
53
+ export default createImageLoader();
54
+ ```
55
+
56
+ ```ts
57
+ // next.config.ts — bound the generated widths for fewer transforms / better cache hits
58
+ export default {
59
+ images: {
60
+ loader: "custom",
61
+ loaderFile: "./lib/image-loader.ts",
62
+ deviceSizes: [640, 750, 828, 1080, 1200, 1920],
63
+ imageSizes: [16, 32, 48, 64, 96, 128, 256, 384],
64
+ },
65
+ };
66
+ ```
67
+
68
+ Migration:
69
+ - New install — nothing to do; existing `<Image>` usage keeps working.
70
+ - Optional — drop `transform: { maxWidth }` from product-image queries; the loader now sets the width per `srcset` entry.
71
+
72
+ ### Patch Changes
73
+
74
+ - 91c3b25: Ship TypeScript types for the codegen recipe (`@doswiftly/storefront-operations/codegen`). A `codegen.ts` that imports `createCodegenConfig` now type-checks under `strict` mode, so `next build` no longer fails with a missing-declaration (implicit `any`) error on the recipe import.
75
+
3
76
  ## 22.5.1
4
77
 
5
78
  ### Patch Changes
package/codegen.d.ts ADDED
@@ -0,0 +1,47 @@
1
+ import type { CodegenConfig } from '@graphql-codegen/cli';
2
+
3
+ /**
4
+ * Options for {@link createCodegenConfig}.
5
+ */
6
+ export interface CreateCodegenConfigOptions {
7
+ /** Glob(s) pointing at the files where you write your GraphQL operations (`gql(...)`). */
8
+ documents: string | string[];
9
+ /** Output directory for the generated code. Defaults to `./src/gql/`. */
10
+ outDir?: string;
11
+ /**
12
+ * Name of the generated operation tag. Defaults to `gql`. Override (e.g.
13
+ * `'graphql'`) when your project already imports a `gql` from another GraphQL
14
+ * client (Apollo, urql, graphql-request) to avoid a name clash.
15
+ */
16
+ gqlTagName?: string;
17
+ }
18
+
19
+ /**
20
+ * Build a `graphql-codegen` configuration (client preset + persisted documents)
21
+ * pointed at this package's schema. Generated operation ids use the Storefront
22
+ * API's trusted-document format (`sha256:<hex>`), so the published manifest is
23
+ * accepted verbatim and the runtime `documentId` resolves server-side, which is
24
+ * what lets public reads be served from cache at the edge.
25
+ *
26
+ * `export default` the result from your codegen file.
27
+ *
28
+ * @example
29
+ * // codegen.ts
30
+ * import { createCodegenConfig } from '@doswiftly/storefront-operations/codegen';
31
+ * export default createCodegenConfig({ documents: 'src/**\/*.{ts,tsx}' });
32
+ */
33
+ export declare function createCodegenConfig(options: CreateCodegenConfigOptions): CodegenConfig;
34
+
35
+ /**
36
+ * Compute a persisted-document id for a printed GraphQL document, in the exact
37
+ * format the Storefront API stores and validates: `sha256:` followed by the
38
+ * lowercase hex SHA-256 of the document body. Useful to assert a generated
39
+ * manifest matches what the API expects.
40
+ *
41
+ * @param documentBody - the printed GraphQL document (operation + its fragments).
42
+ * @returns `sha256:` followed by 64 hex characters.
43
+ */
44
+ export declare function trustedDocumentHash(documentBody: string): string;
45
+
46
+ /** Absolute path to the GraphQL schema file shipped in this package. */
47
+ export declare const SCHEMA_PATH: string;
package/llms-full.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  # DoSwiftly Storefront Operations — Full Reference
2
2
 
3
- > Schema version: **22.5.1**
3
+ > Schema version: **22.8.0**
4
4
  > 52 queries · 44 mutations · 105 fragments
5
5
 
6
6
  Auto-generated from `.graphql` source files. Do not edit by hand — this file is
package/operations.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "schemaVersion": "22.5.1",
2
+ "schemaVersion": "22.8.0",
3
3
  "queries": [
4
4
  {
5
5
  "name": "Shop",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@doswiftly/storefront-operations",
3
- "version": "22.5.1",
3
+ "version": "22.8.0",
4
4
  "description": "GraphQL operations for DoSwiftly Storefront - SSOT from backend",
5
5
  "homepage": "https://doswiftly.pl",
6
6
  "publishConfig": {
@@ -13,7 +13,10 @@
13
13
  "./mutations.graphql": "./mutations.graphql",
14
14
  "./fragments.graphql": "./fragments.graphql",
15
15
  "./operations.json": "./operations.json",
16
- "./codegen": "./codegen.js",
16
+ "./codegen": {
17
+ "types": "./codegen.d.ts",
18
+ "default": "./codegen.js"
19
+ },
17
20
  "./*.graphql": "./*.graphql"
18
21
  },
19
22
  "devDependencies": {
@@ -35,6 +38,7 @@
35
38
  "fragments.graphql",
36
39
  "operations.json",
37
40
  "codegen.js",
41
+ "codegen.d.ts",
38
42
  "README.md",
39
43
  "AGENTS.md",
40
44
  "llms-full.txt",