@vtex/faststore-catalog 0.0.0-bootstrap.0 → 0.0.4

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 VTEX
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,67 @@
1
+ # @vtex/faststore-catalog
2
+
3
+ The Catalog Build for a FastStore package. It scans the package's `defineComponent` and
4
+ `defineActions` declarations in source `.tsx`, closes every GraphQL fragment they spread against the
5
+ package's codegen output, and writes `dist/catalog.json`, the file a store compiler reads to know
6
+ which components exist, what props they take, and what data they need. The scan reads `src/` and
7
+ never `dist/`, so it and `tsc` can run in either order.
8
+
9
+ ```bash
10
+ npm install --save-dev @vtex/faststore-catalog
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ ```js
16
+ import { buildPackageCatalog } from '@vtex/faststore-catalog';
17
+
18
+ const result = buildPackageCatalog({ packageDir: process.cwd() });
19
+ console.log(`catalog.json: ${result.catalogEntries} entries`);
20
+ ```
21
+
22
+ `buildPackageCatalog(options)` is the only export. The call is synchronous. A scanner hard error,
23
+ such as a duplicate component name or a fragment that does not resolve, throws.
24
+
25
+ ### Options
26
+
27
+ | Option | Required | Meaning |
28
+ | --- | --- | --- |
29
+ | `packageDir` | yes | The package root. The scanner reads source from `<packageDir>/src`. |
30
+ | `outDir` | no | Where the artifacts land. Defaults to `<packageDir>/dist`. |
31
+ | `fragmentMapPath` | no | A UI extension's codegen `graphql.ts`, absolute or relative to `packageDir` (never the process cwd). Without it the fragment map is empty, so any fragment spread hard-errors. Throws for `@vtex/faststore`, which keeps its own default. |
32
+
33
+ The layout follows the package kind, derived from `package.json#name`. `@vtex/faststore` scans
34
+ `src/particles` and `src/matter` and keys entries by bare name. A `(@<vendor>/)?fs-extension-<name>`
35
+ UI extension scans `src/components`, keys entries `<packageName>:<ComponentName>`, and may not
36
+ declare actions. Any other name throws.
37
+
38
+ ### Result
39
+
40
+ ```ts
41
+ {
42
+ catalogPath: string
43
+ actionsPath: string | null // null unless the package declares actions
44
+ contentTypesPath: string | null // null unless the package declares content models
45
+ catalogEntries: number
46
+ actionNamespaces: number
47
+ contentTypes: number
48
+ diagnostics: [] // catalog build failures throw
49
+ }
50
+ ```
51
+
52
+ ## Platform packages
53
+
54
+ The scanner is a Rust native addon. This package ships no binary itself. It declares one
55
+ `@vtex/faststore-catalog-<target>` package per supported target as an optional dependency, and the
56
+ loader picks the one matching the host:
57
+
58
+ `darwin-arm64`, `darwin-x64`, `linux-x64-gnu`, `linux-arm64-gnu`, `win32-x64`
59
+
60
+ The two linux prebuilds link glibc. On musl (Alpine) neither resolves, and the loader says so rather
61
+ than pointing at a package that could not work; use a glibc base image instead.
62
+
63
+ ## Links
64
+
65
+ - [FastStore documentation](https://developers.vtex.com/docs/guides/faststore)
66
+ - Source and issues: [vtex/faststore-ai-native](https://github.com/vtex/faststore-ai-native), private
67
+ for the pre-1.0 line
package/index.d.ts ADDED
@@ -0,0 +1,40 @@
1
+ export type BuildPackageCatalogOptions = {
2
+ /** The package root; the scanner reads source `.tsx` under `<packageDir>/src`, never `dist/`. */
3
+ packageDir: string;
4
+ /** Artifact destination (default: `<packageDir>/dist`). */
5
+ outDir?: string;
6
+ /**
7
+ * A UI extension's fragment-map path (its codegen `graphql.ts`), absolute or relative to
8
+ * `packageDir` — never the process cwd. Throws for the core package (`@vtex/faststore`),
9
+ * which keeps its `src/sdk/generated/graphql.ts` default and so could not honor one. Without it
10
+ * the fragment map is empty, so any fragment spread hard-errors; a path that is not a file throws,
11
+ * naming the resolved path.
12
+ */
13
+ fragmentMapPath?: string;
14
+ };
15
+
16
+ export type BuildPackageCatalogResult = {
17
+ /** The emitted `catalog.json`. */
18
+ catalogPath: string;
19
+ /** The emitted `actions.json`, or `null` when the package declares no actions. */
20
+ actionsPath: string | null;
21
+ /** The emitted `content-types.json`, or `null` when the package declares no content models. */
22
+ contentTypesPath: string | null;
23
+ catalogEntries: number;
24
+ actionNamespaces: number;
25
+ contentTypes: number;
26
+ /** Catalog build failures throw; this addon does not emit non-fatal diagnostics. */
27
+ diagnostics: [];
28
+ };
29
+
30
+ /**
31
+ * The per-package catalog build: scans `defineComponent` / `defineActions` declarations in source,
32
+ * closes GraphQL fragments transitively against the package's codegen output, and emits
33
+ * `dist/catalog.json` (+ `dist/actions.json`, + `dist/content-types.json`).
34
+ *
35
+ * The layout follows the package kind, derived from `package.json#name`: `@vtex/faststore` scans
36
+ * `src/particles`/`src/matter` and keys entries by bare name; a `(@<vendor>/)?fs-extension-<name>` UI
37
+ * extension scans `src/components`, keys them `<packageName>:<ComponentName>`, and may not declare
38
+ * actions. Any other package name throws.
39
+ */
40
+ export function buildPackageCatalog(options: BuildPackageCatalogOptions): BuildPackageCatalogResult;
package/index.js ADDED
@@ -0,0 +1,71 @@
1
+ // The JS surface of the Catalog Build napi addon: loads the platform-matched cdylib (built + renamed
2
+ // by scripts/build-node-addon.mjs) and wraps its string-in/string-out native export in the
3
+ // JSON-object surface a package's build script consumes. The native call is synchronous.
4
+
5
+ const { existsSync } = require('node:fs');
6
+ const { join } = require('node:path');
7
+
8
+ const NATIVE_BY_PLATFORM = {
9
+ 'darwin-arm64': 'faststore-catalog.darwin-arm64.node',
10
+ 'darwin-x64': 'faststore-catalog.darwin-x64.node',
11
+ 'linux-x64': 'faststore-catalog.linux-x64-gnu.node',
12
+ 'linux-arm64': 'faststore-catalog.linux-arm64-gnu.node',
13
+ 'win32-x64': 'faststore-catalog.win32-x64.node',
14
+ };
15
+
16
+ // The per-platform binary packages installed as optionalDependencies of the published package
17
+ // (napi-rs prebuild pattern). Inside the workspace the crate-local .node file wins instead.
18
+ const PACKAGE_BY_PLATFORM = {
19
+ 'darwin-arm64': '@vtex/faststore-catalog-darwin-arm64',
20
+ 'darwin-x64': '@vtex/faststore-catalog-darwin-x64',
21
+ 'linux-x64': '@vtex/faststore-catalog-linux-x64-gnu',
22
+ 'linux-arm64': '@vtex/faststore-catalog-linux-arm64-gnu',
23
+ 'win32-x64': '@vtex/faststore-catalog-win32-x64',
24
+ };
25
+
26
+ // The prebuilt linux binaries link glibc; on musl (Alpine) the gnu platform package either won't
27
+ // resolve or won't load, so name the real problem instead of suggesting a package that can't work.
28
+ function isMusl() {
29
+ return process.platform === 'linux' && !process.report?.getReport?.()?.header?.glibcVersionRuntime;
30
+ }
31
+
32
+ function loadNative() {
33
+ const key = `${process.platform}-${process.arch}`;
34
+ const file = NATIVE_BY_PLATFORM[key];
35
+ if (!file) {
36
+ throw new Error(`@vtex/faststore-catalog: unsupported platform '${key}'`);
37
+ }
38
+ const local = join(__dirname, file);
39
+ if (existsSync(local)) {
40
+ return require(local);
41
+ }
42
+ if (isMusl()) {
43
+ throw new Error(
44
+ `@vtex/faststore-catalog: musl libc is not supported — the '${key}' prebuilds are glibc-only (use a glibc base image instead of Alpine)`,
45
+ );
46
+ }
47
+ try {
48
+ return require(PACKAGE_BY_PLATFORM[key]);
49
+ } catch (error) {
50
+ const detail = error instanceof Error && error.message ? ` (${error.message})` : '';
51
+ throw new Error(
52
+ `@vtex/faststore-catalog: native addon '${file}' is missing — in the workspace, build it with ` +
53
+ `'node scripts/build-node-addon.mjs'; in an installed package, ensure the platform package ` +
54
+ `'${PACKAGE_BY_PLATFORM[key]}' installed (it ships as an optionalDependency)${detail}`,
55
+ { cause: error },
56
+ );
57
+ }
58
+ }
59
+
60
+ const native = loadNative();
61
+
62
+ // The per-package catalog build: scans defineComponent/defineActions in source, closes GraphQL
63
+ // fragments, emits dist/catalog.json (+ dist/actions.json, + dist/content-types.json). Scanner
64
+ // hard errors throw.
65
+ function buildPackageCatalog(options) {
66
+ return JSON.parse(native.buildPackageCatalog(JSON.stringify(options)));
67
+ }
68
+
69
+ module.exports = {
70
+ buildPackageCatalog,
71
+ };
package/package.json CHANGED
@@ -1,7 +1,20 @@
1
1
  {
2
2
  "name": "@vtex/faststore-catalog",
3
- "version": "0.0.0-bootstrap.0",
4
- "description": "Placeholder that reserves the name for trusted publishing. Do not install.",
3
+ "version": "0.0.4",
4
+ "description": "Build a FastStore package's component catalog: scans its defineComponent declarations, closes their GraphQL fragments, and emits dist/catalog.json.",
5
5
  "license": "MIT",
6
- "repository": { "type": "git", "url": "git+https://github.com/vtex/faststore-ai-native.git" }
6
+ "main": "index.js",
7
+ "types": "index.d.ts",
8
+ "files": [
9
+ "index.js",
10
+ "index.d.ts",
11
+ "*.node"
12
+ ],
13
+ "optionalDependencies": {
14
+ "@vtex/faststore-catalog-darwin-arm64": "0.0.4",
15
+ "@vtex/faststore-catalog-darwin-x64": "0.0.4",
16
+ "@vtex/faststore-catalog-linux-x64-gnu": "0.0.4",
17
+ "@vtex/faststore-catalog-linux-arm64-gnu": "0.0.4",
18
+ "@vtex/faststore-catalog-win32-x64": "0.0.4"
19
+ }
7
20
  }