@salesforce/storefront-next-dev 0.3.1-alpha.1 → 0.4.0-alpha.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/README.md +12 -12
- package/bin/run.js +19 -9
- package/dist/cartridge-services/index.js +9 -1
- package/dist/cartridge-services/index.js.map +1 -1
- package/dist/commands/config/inspect.js +191 -0
- package/dist/commands/create-bundle.js +1 -1
- package/dist/commands/create-storefront.js +3 -3
- package/dist/commands/dev.js +1 -3
- package/dist/commands/extensions/install.js +1 -1
- package/dist/commands/extensions/list.js +1 -1
- package/dist/commands/extensions/remove.js +1 -1
- package/dist/commands/generate-cartridge.js +1 -1
- package/dist/commands/locales/aggregate-extensions.js +181 -0
- package/dist/commands/prepare-local.js +1 -1
- package/dist/commands/preview.js +1 -3
- package/dist/commands/scapi/add.js +298 -0
- package/dist/commands/scapi/list.js +35 -0
- package/dist/commands/scapi/remove.js +56 -0
- package/dist/commands/validate-cartridge.js +1 -1
- package/dist/configs/react-router.config.js +2 -1
- package/dist/configs/react-router.config.js.map +1 -1
- package/dist/data-store/local-provider.d.ts +42 -0
- package/dist/data-store/local-provider.d.ts.map +1 -0
- package/dist/data-store/local-provider.js +66 -0
- package/dist/data-store/local-provider.js.map +1 -0
- package/dist/flags.js +5 -3
- package/dist/generate-cartridge.js +9 -1
- package/dist/generate-custom-clients.js +73 -0
- package/dist/hooks/init.js +29 -4
- package/dist/index.d.ts +46 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +260 -42
- package/dist/index.js.map +1 -1
- package/dist/logger.js +1 -1
- package/dist/mrt/ssr.mjs +51 -51
- package/dist/mrt/ssr.mjs.map +1 -1
- package/dist/mrt/streamingHandler.mjs +57 -57
- package/dist/mrt/streamingHandler.mjs.map +1 -1
- package/dist/schema-utils.js +64 -0
- package/dist/utils.js +3 -11
- package/package.json +19 -3
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { r as readAllSchemaMetadata } from "./schema-utils.js";
|
|
2
|
+
import { writeFileSync } from "node:fs";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
|
|
5
|
+
//#region src/scapi/generate-custom-clients.ts
|
|
6
|
+
const COPYRIGHT_HEADER = `/**
|
|
7
|
+
* Copyright 2026 Salesforce, Inc.
|
|
8
|
+
*
|
|
9
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
10
|
+
* you may not use this file except in compliance with the License.
|
|
11
|
+
* You may obtain a copy of the License at
|
|
12
|
+
*
|
|
13
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
14
|
+
*
|
|
15
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
16
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
17
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
18
|
+
* See the License for the specific language governing permissions and
|
|
19
|
+
* limitations under the License.
|
|
20
|
+
*/`;
|
|
21
|
+
/**
|
|
22
|
+
* Generate the custom-clients.ts file in the template project.
|
|
23
|
+
*
|
|
24
|
+
* @param scapiDir - Absolute path to the src/scapi/ directory in the template project
|
|
25
|
+
*/
|
|
26
|
+
function generateCustomClientsFile(scapiDir) {
|
|
27
|
+
const entries = readAllSchemaMetadata(join(scapiDir, "schemas"));
|
|
28
|
+
const customClientsPath = join(scapiDir, "custom-clients.ts");
|
|
29
|
+
if (entries.length === 0) {
|
|
30
|
+
writeFileSync(customClientsPath, `${COPYRIGHT_HEADER}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Custom SCAPI Clients — generated by \`sfnext scapi\`, do not edit manually.
|
|
34
|
+
*
|
|
35
|
+
* Use \`sfnext scapi add --schema <file>\` to add a client from a local schema file.
|
|
36
|
+
* Use \`sfnext scapi add <family> <name> <version>\` to pull from the SCAPI Schemas API.
|
|
37
|
+
* Use \`sfnext scapi list\` to see registered custom clients.
|
|
38
|
+
*/
|
|
39
|
+
export { type Clients as AppClients } from '@salesforce/storefront-next-runtime/scapi';
|
|
40
|
+
|
|
41
|
+
export const customClients: never[] = [];
|
|
42
|
+
`, "utf-8");
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
const imports = [];
|
|
46
|
+
const typeEntries = [];
|
|
47
|
+
const clientEntries = [];
|
|
48
|
+
entries.forEach(({ clientKey, basePath, supportsLocale, orgPrefix, schemaName }, index) => {
|
|
49
|
+
imports.push(`import type { paths as P${index} } from './generated/${schemaName}';`, `import { operations as ops${index} } from './generated/${schemaName}.operations';`);
|
|
50
|
+
typeEntries.push(` ${clientKey}: ProxyClient<Client<P${index}>, typeof ops${index}>;`);
|
|
51
|
+
clientEntries.push(` { key: '${clientKey}', basePath: '${basePath}', ops: ops${index}, locale: ${supportsLocale}, orgPrefix: ${orgPrefix} },`);
|
|
52
|
+
});
|
|
53
|
+
writeFileSync(customClientsPath, `${COPYRIGHT_HEADER}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Custom SCAPI Clients — generated by \`sfnext scapi\`, do not edit manually.
|
|
57
|
+
*/
|
|
58
|
+
import { type Client, type Clients, type MergeClients, type ProxyClient } from '@salesforce/storefront-next-runtime/scapi';
|
|
59
|
+
|
|
60
|
+
${imports.join("\n")}
|
|
61
|
+
|
|
62
|
+
export type AppClients = MergeClients<Clients, {
|
|
63
|
+
${typeEntries.join("\n")}
|
|
64
|
+
}>;
|
|
65
|
+
|
|
66
|
+
export const customClients = [
|
|
67
|
+
${clientEntries.join("\n")}
|
|
68
|
+
] as const;
|
|
69
|
+
`, "utf-8");
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
//#endregion
|
|
73
|
+
export { generateCustomClientsFile as t };
|
package/dist/hooks/init.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { n as PROJECT_DIRECTORY_FLAG, t as PROJECT_DIRECTORY_CHAR } from "../flags.js";
|
|
2
|
+
import { join, resolve } from "node:path";
|
|
1
3
|
import { B2CPluginManager } from "@salesforce/b2c-tooling-sdk/plugins";
|
|
2
4
|
import { getLogger } from "@salesforce/b2c-tooling-sdk/logging";
|
|
3
5
|
|
|
@@ -34,11 +36,34 @@ async function initializePlugins() {
|
|
|
34
36
|
/**
|
|
35
37
|
* Oclif init hook — runs before any command executes.
|
|
36
38
|
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
39
|
+
* Resolves the project directory from --project-directory / -d early — before
|
|
40
|
+
* oclif parses flags — and loads the project's .env file into process.env.
|
|
41
|
+
* Using the hook instead of bin/run.js keeps the flag name as a single source
|
|
42
|
+
* of truth (imported from flags.ts) and keeps run.js minimal.
|
|
43
|
+
*
|
|
44
|
+
* Also discovers b2c-cli plugins (installed via `b2c plugins:install`) and
|
|
45
|
+
* registers their middleware and config sources with the global registries.
|
|
46
|
+
*
|
|
47
|
+
* @env {string} [MRT_PROJECT] - Project name for MRT deployments
|
|
48
|
+
* @env {string} [MRT_TARGET] - Target environment for MRT deployments
|
|
40
49
|
*/
|
|
41
|
-
const hook = async function() {
|
|
50
|
+
const hook = async function(opts) {
|
|
51
|
+
const args = opts.argv ?? [];
|
|
52
|
+
let projectDir = process.cwd();
|
|
53
|
+
for (let i = 0; i < args.length; i++) {
|
|
54
|
+
if ((args[i] === `--${PROJECT_DIRECTORY_FLAG}` || args[i] === `-${PROJECT_DIRECTORY_CHAR}`) && args[i + 1] && !args[i + 1].startsWith("-")) {
|
|
55
|
+
projectDir = resolve(args[i + 1]);
|
|
56
|
+
break;
|
|
57
|
+
}
|
|
58
|
+
const m = args[i].match(/* @__PURE__ */ new RegExp(`^--${PROJECT_DIRECTORY_FLAG}=(.+)$`));
|
|
59
|
+
if (m) {
|
|
60
|
+
projectDir = resolve(m[1]);
|
|
61
|
+
break;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
try {
|
|
65
|
+
process.loadEnvFile(join(projectDir, ".env"));
|
|
66
|
+
} catch {}
|
|
42
67
|
await initializePlugins();
|
|
43
68
|
};
|
|
44
69
|
var init_default = hook;
|
package/dist/index.d.ts
CHANGED
|
@@ -106,7 +106,7 @@ interface StorefrontNextTargetsConfig {
|
|
|
106
106
|
eventInstrumentationValidator?: EventInstrumentationValidatorConfig | false;
|
|
107
107
|
}
|
|
108
108
|
/**
|
|
109
|
-
* Storefront Next Vite plugin that powers the React Router
|
|
109
|
+
* Storefront Next Vite plugin that powers the React Router app.
|
|
110
110
|
* Supports building and optimizing for the managed runtime environment.
|
|
111
111
|
*
|
|
112
112
|
* @param config - Configuration options for the plugin
|
|
@@ -138,6 +138,50 @@ declare function transformTargetPlaceholderPlugin(): {
|
|
|
138
138
|
} | null;
|
|
139
139
|
};
|
|
140
140
|
//#endregion
|
|
141
|
+
//#region src/plugins/uiTargetDevMode.d.ts
|
|
142
|
+
interface UITargetDevModeConfig {
|
|
143
|
+
/**
|
|
144
|
+
* Enable dev mode visual markers. Defaults to false.
|
|
145
|
+
* Set via VITE_UI_TARGET_DEV_MODE=true environment variable.
|
|
146
|
+
*/
|
|
147
|
+
enabled?: boolean;
|
|
148
|
+
/**
|
|
149
|
+
* Build-time filter: only show targets matching a category prefix.
|
|
150
|
+
* Set via VITE_TARGET_FILTER_CATEGORY=pdp environment variable.
|
|
151
|
+
* @example filterCategory: 'pdp' — only shows targets whose id starts with "pdp."
|
|
152
|
+
*/
|
|
153
|
+
filterCategory?: string;
|
|
154
|
+
/**
|
|
155
|
+
* Map of targetId → hint label for overlay grouping/filtering.
|
|
156
|
+
* Built from target-config.json at config time and injected into each dev marker
|
|
157
|
+
* as a __hint__ prop, which is emitted as a data-ui-target-hint DOM attribute.
|
|
158
|
+
* Example: { 'emailSignUp.consent.marketing': 't/my-branch/W-123', 'checkout.contactInfo': 'pr:1384' }
|
|
159
|
+
*/
|
|
160
|
+
hintMap?: Record<string, string>;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Vite plugin that adds visual markers to UITarget components in development.
|
|
164
|
+
*
|
|
165
|
+
* PRODUCTION: This plugin is completely inactive - zero overhead.
|
|
166
|
+
* DEVELOPMENT: Transforms UITarget JSX to add visual debugging markers.
|
|
167
|
+
*
|
|
168
|
+
* @example
|
|
169
|
+
* // Source code:
|
|
170
|
+
* <UITarget targetId="pdp.loyalty.badge">
|
|
171
|
+
* <Widget />
|
|
172
|
+
* </UITarget>
|
|
173
|
+
*
|
|
174
|
+
* // Transformed in DEV mode:
|
|
175
|
+
* <UITargetDevMarker
|
|
176
|
+
* targetId="pdp.loyalty.badge"
|
|
177
|
+
* __file__="/src/components/product.tsx"
|
|
178
|
+
* __hasChildren__={true}
|
|
179
|
+
* >
|
|
180
|
+
* <Widget />
|
|
181
|
+
* </UITargetDevMarker>
|
|
182
|
+
*/
|
|
183
|
+
declare function uiTargetDevModePlugin(config?: UITargetDevModeConfig): Plugin;
|
|
184
|
+
//#endregion
|
|
141
185
|
//#region src/plugins/hybridProxy.d.ts
|
|
142
186
|
|
|
143
187
|
interface HybridProxyPluginOptions {
|
|
@@ -417,5 +461,5 @@ interface GenerateMetadataResult {
|
|
|
417
461
|
}
|
|
418
462
|
declare function generateMetadata(projectDirectory: string, metadataDirectory: string, options?: GenerateMetadataOptions): Promise<GenerateMetadataResult>;
|
|
419
463
|
//#endregion
|
|
420
|
-
export { type GenerateMetadataOptions, type GenerateMetadataResult, type HybridProxyPluginOptions, type StorefrontNextTargetsConfig, clearCache, createServer, storefrontNextTargets as default, extractPatterns, generateMetadata, hybridProxyPlugin, loadConfigFromEnv, loadProjectConfig, shouldRouteToNext, testPatterns, transformTargetPlaceholderPlugin, trimExtensions };
|
|
464
|
+
export { type GenerateMetadataOptions, type GenerateMetadataResult, type HybridProxyPluginOptions, type StorefrontNextTargetsConfig, type UITargetDevModeConfig, clearCache, createServer, storefrontNextTargets as default, extractPatterns, generateMetadata, hybridProxyPlugin, loadConfigFromEnv, loadProjectConfig, shouldRouteToNext, testPatterns, transformTargetPlaceholderPlugin, trimExtensions, uiTargetDevModePlugin };
|
|
421
465
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":["ExtensionMeta","ExtensionConfig","Record","default"],"sources":["../src/plugins/staticRegistry.ts","../src/plugins/eventInstrumentationValidator.ts","../src/storefront-next-targets.ts","../src/plugins/transformTargets.ts","../src/plugins/hybridProxy.ts","../src/plugins/ecdnMatcher.ts","../src/server/config.ts","../src/server/modes.ts","../src/server/index.ts","../src/extensibility/extension-config.d.ts","../src/extensibility/trim-extensions.ts","../src/cartridge-services/generate-cartridge.ts"],"sourcesContent":["/**\n * Copyright 2026 Salesforce, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nexport type ExtensionMeta = {\n name: string;\n description: string;\n installationInstructions: string;\n uninstallationInstructions: string;\n folder: string;\n dependencies: string[];\n defaultOn?: boolean;\n};\n\ndeclare const ExtensionConfig: {\n extensions: Record<string, ExtensionMeta>;\n};\n\nexport default ExtensionConfig;\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":["ExtensionMeta","ExtensionConfig","Record","default"],"sources":["../src/plugins/staticRegistry.ts","../src/plugins/eventInstrumentationValidator.ts","../src/storefront-next-targets.ts","../src/plugins/transformTargets.ts","../src/plugins/uiTargetDevMode.ts","../src/plugins/hybridProxy.ts","../src/plugins/ecdnMatcher.ts","../src/server/config.ts","../src/server/modes.ts","../src/server/index.ts","../src/extensibility/extension-config.d.ts","../src/extensibility/trim-extensions.ts","../src/cartridge-services/generate-cartridge.ts"],"sourcesContent":["/**\n * Copyright 2026 Salesforce, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nexport type ExtensionMeta = {\n name: string;\n description: string;\n installationInstructions: string;\n uninstallationInstructions: string;\n folder: string;\n dependencies: string[];\n defaultOn?: boolean;\n};\n\ndeclare const ExtensionConfig: {\n extensions: Record<string, ExtensionMeta>;\n};\n\nexport default ExtensionConfig;\n"],"mappings":";;;;;;;AMgGA;AA8CA;AA0BA;UNjHiB,0BAAA;;;AOjCjB;AAoBA;EAgDsB,aAAA,CAAA,EAAA,MAAiB;;;;AC3EvC;AAKA;;;;ACkCA;;;EAQa,kBAAA,CAAA,EAAA,MAAA;EAMF;;;;EA4BW,WAAA,CAAA,EAAA,OAAY;;;;;;;;ANrElB,UFDC,mCAAA,CEWc;;;;ACK/B;EA4CgB,UAAA,CAAA,EAAA,MAAA;;;;AC3BhB;EA2KgB,SAAA,CAAA,EAAA,MAAA,EAAiB;;;;ACzKjC;EAmCgB,aAAA,CAAA,EAAY,OAAA;AA8C5B;;;;;AHnHA;;UDUiB,2BAAA;;AEKjB;AA4CA;;;;AC3BA;AA2KA;;;;ACzKA;AAmCA;AA8CA;AA0BA;;;;AClJA;AAoBA;AAgDA;;;;EC3EY;AAKZ;;;;ACkCA;;;EAQa,cAAA,CAAA,EPSQ,0BOTR;EAMF;;;;AA4BX;;;;EAAmE,6BAAA,CAAA,EPf/B,mCOe+B,GAAA,KAAA;;;;ACjFnE;AAQE;;;;ACDoD;AAIrB;;;;;;;;AC8uBjC;AAwBA;AA8CA;AAGc,iBV1uBE,qBAAA,CU0uBF,MAAA,CAAA,EV1uBgC,2BU0uBhC,CAAA,EV1uBmE,MU0uBnE,EAAA;;;iBTtzBE,g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