@salesforce/storefront-next-dev 0.4.2 → 1.0.0-alpha.1

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/index.d.ts CHANGED
@@ -1,7 +1,5 @@
1
1
  import { Project } from "ts-morph";
2
- import { Express } from "express";
3
- import { Plugin, ResolvedConfig, ViteDevServer } from "vite";
4
- import { ServerBuild } from "react-router";
2
+ import { Plugin, ResolvedConfig } from "vite";
5
3
 
6
4
  //#region src/plugins/staticRegistry.d.ts
7
5
 
@@ -202,8 +200,8 @@ interface HybridProxyPluginOptions {
202
200
  * hybridProxyPlugin({ routeMatcher: shouldRouteToNext, ... })
203
201
  */
204
202
  routeMatcher: (pathname: string, routingRules: string) => boolean;
205
- /** SFCC Site ID (e.g., 'RefArchGlobal') */
206
- siteId: string;
203
+ /** SFCC default site ID (e.g., 'RefArchGlobal'). Required when `enabled` is true. */
204
+ defaultSiteId?: string;
207
205
  /** Locale for SFRA paths (e.g., 'en-GB'). Defaults to 'default' if not provided. */
208
206
  locale?: string;
209
207
  }
@@ -223,60 +221,7 @@ interface HybridProxyPluginOptions {
223
221
  declare function hybridProxyPlugin(options: HybridProxyPluginOptions): Plugin;
224
222
  //#endregion
225
223
  //#region src/plugins/ecdnMatcher.d.ts
226
- /**
227
- * Copyright 2026 Salesforce, Inc.
228
- *
229
- * Licensed under the Apache License, Version 2.0 (the "License");
230
- * you may not use this file except in compliance with the License.
231
- * You may obtain a copy of the License at
232
- *
233
- * http://www.apache.org/licenses/LICENSE-2.0
234
- *
235
- * Unless required by applicable law or agreed to in writing, software
236
- * distributed under the License is distributed on an "AS IS" BASIS,
237
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
238
- * See the License for the specific language governing permissions and
239
- * limitations under the License.
240
- */
241
- /**
242
- * Extracts regex patterns from a Cloudflare routing expression.
243
- *
244
- * Parses Cloudflare "matches" expressions like:
245
- * (http.request.uri.path matches "^/$" or http.request.uri.path matches "^/category.*")
246
- *
247
- * And extracts the regex patterns: ["^/$", "^/category.*"]
248
- *
249
- * @param expression - Cloudflare expression string
250
- * @returns Array of regex pattern strings
251
- *
252
- * @example
253
- * ```typescript
254
- * extractPatterns('(http.request.uri.path matches "^/$")');
255
- * // Returns: ["^/$"]
256
- *
257
- * extractPatterns('(http.request.uri.path matches "^/$" or http.request.uri.path matches "^/search.*")');
258
- * // Returns: ["^/$", "^/search.*"]
259
- * ```
260
- */
261
- declare function extractPatterns(expression: string): string[];
262
- /**
263
- * Tests if a pathname matches any of the provided regex patterns (logical OR).
264
- * Uses caching to optimize repeated pattern compilations.
265
- *
266
- * @param pathname - URL pathname to test (e.g., "/search", "/category/shoes")
267
- * @param patterns - Array of regex pattern strings
268
- * @returns true if pathname matches any pattern, false otherwise
269
- *
270
- * @example
271
- * ```typescript
272
- * testPatterns('/category/shoes', ['^/category.*', '^/search.*']);
273
- * // Returns: true (matches first pattern)
274
- *
275
- * testPatterns('/checkout', ['^/category.*', '^/search.*']);
276
- * // Returns: false (matches no patterns)
277
- * ```
278
- */
279
- declare function testPatterns(pathname: string, patterns: string[]): boolean;
224
+
280
225
  /**
281
226
  * Main function: Determines if a pathname should route to Storefront Next
282
227
  * or be proxied/redirected to SFRA/legacy backend.
@@ -296,170 +241,6 @@ declare function testPatterns(pathname: string, patterns: string[]): boolean;
296
241
  * ```
297
242
  */
298
243
  declare function shouldRouteToNext(pathname: string, routingRules?: string): boolean;
299
- /**
300
- * Clears the regex cache. Useful for testing or when routing rules change.
301
- *
302
- * @example
303
- * ```typescript
304
- * clearCache();
305
- * // All cached regex patterns are removed
306
- * ```
307
- */
308
- declare function clearCache(): void;
309
- //#endregion
310
- //#region src/server/config.d.ts
311
- /**
312
- * Server configuration extracted from environment variables
313
- */
314
- interface ServerConfig {
315
- commerce: {
316
- api: {
317
- shortCode: string;
318
- organizationId: string;
319
- clientId: string;
320
- proxy: string;
321
- proxyHost?: string;
322
- };
323
- };
324
- }
325
- /**
326
- * This is a temporary function before we move the config implementation from
327
- * template-retail-rsc-app to the SDK.
328
- *
329
- * @ TODO: Remove this function after we move the config implementation from
330
- * template-retail-rsc-app to the SDK.
331
- *
332
- */
333
- declare function loadConfigFromEnv(): ServerConfig;
334
- /**
335
- * Load storefront-next project configuration from config.server.ts.
336
- * Requires projectDirectory to be provided.
337
- *
338
- * @param projectDirectory - Project directory to load config.server.ts from
339
- * @throws Error if config.server.ts is not found or invalid
340
- */
341
- declare function loadProjectConfig(projectDirectory: string): Promise<ServerConfig>;
342
- //#endregion
343
- //#region src/server/modes.d.ts
344
- /**
345
- * Copyright 2026 Salesforce, Inc.
346
- *
347
- * Licensed under the Apache License, Version 2.0 (the "License");
348
- * you may not use this file except in compliance with the License.
349
- * You may obtain a copy of the License at
350
- *
351
- * http://www.apache.org/licenses/LICENSE-2.0
352
- *
353
- * Unless required by applicable law or agreed to in writing, software
354
- * distributed under the License is distributed on an "AS IS" BASIS,
355
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
356
- * See the License for the specific language governing permissions and
357
- * limitations under the License.
358
- */
359
- type ServerMode = 'development' | 'preview' | 'production';
360
- /**
361
- * Feature flags for each server mode
362
- */
363
- interface ServerModeFeatures {
364
- /** Enable Commerce API proxy middleware to forward /mobify/proxy/api requests to SCAPI */
365
- enableProxy: boolean;
366
- /** Enable static file serving from build/client directory */
367
- enableStaticServing: boolean;
368
- /** Enable gzip/brotli compression middleware for responses */
369
- enableCompression: boolean;
370
- /** Enable HTTP request/response logging */
371
- enableLogging: boolean;
372
- /** Enable patching of asset URLs with bundle path (for CDN deployment) */
373
- enableAssetUrlPatching: boolean;
374
- }
375
- //#endregion
376
- //#region src/server/index.d.ts
377
- interface ServerOptions extends Partial<ServerModeFeatures> {
378
- /** Server mode: development (with Vite), preview (preview), or production (minimal) */
379
- mode: ServerMode;
380
- /** Project root directory (optional, defaults to process.cwd()) */
381
- projectDirectory?: string;
382
- /** Server configuration (optional, will load from env vars if not provided) */
383
- config?: ServerConfig;
384
- /** Server port (optional, for logging) */
385
- port?: number;
386
- /** Vite dev server instance (required for development mode) */
387
- vite?: ViteDevServer;
388
- /** React Router server build (required for preview/production modes) */
389
- build?: ServerBuild;
390
- /** Enable streaming of responses */
391
- streaming?: boolean;
392
- }
393
- /**
394
- * Create a unified Express server for development, preview, or production mode
395
- */
396
- declare function createServer(options: ServerOptions): Promise<Express>;
397
- //#endregion
398
- //#region src/extensibility/extension-config.d.ts
399
- /**
400
- * Copyright 2026 Salesforce, Inc.
401
- *
402
- * Licensed under the Apache License, Version 2.0 (the "License");
403
- * you may not use this file except in compliance with the License.
404
- * You may obtain a copy of the License at
405
- *
406
- * http://www.apache.org/licenses/LICENSE-2.0
407
- *
408
- * Unless required by applicable law or agreed to in writing, software
409
- * distributed under the License is distributed on an "AS IS" BASIS,
410
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
411
- * See the License for the specific language governing permissions and
412
- * limitations under the License.
413
- */
414
- type ExtensionMeta = {
415
- name: string;
416
- description: string;
417
- installationInstructions: string;
418
- uninstallationInstructions: string;
419
- folder: string;
420
- dependencies: string[];
421
- defaultOn?: boolean;
422
- };
423
- declare const ExtensionConfig: {
424
- extensions: Record<string, ExtensionMeta>;
425
- };
426
- //#endregion
427
- //#region src/extensibility/trim-extensions.d.ts
428
- type ExtensionsSelection = Record<string, boolean>;
429
- declare function trimExtensions(directory: string, selectedExtensions?: Partial<ExtensionsSelection>, extensionConfig?: typeof ExtensionConfig): void;
430
- //#endregion
431
- //#region src/cartridge-services/generate-cartridge.d.ts
432
- /**
433
- * Options for generateMetadata function
434
- */
435
- interface GenerateMetadataOptions {
436
- /**
437
- * Optional array of specific file paths to process.
438
- * If provided, only these files will be processed and existing cartridge files will NOT be deleted.
439
- * If omitted, the entire src/ directory will be scanned and all existing cartridge files will be deleted first.
440
- */
441
- filePaths?: string[];
442
- /**
443
- * Whether to run ESLint with --fix on generated JSON files to format them according to project settings.
444
- * Defaults to true.
445
- */
446
- lintFix?: boolean;
447
- /**
448
- * If true, scans files and reports what would be generated without actually writing any files or deleting directories.
449
- * Defaults to false.
450
- */
451
- dryRun?: boolean;
452
- }
453
- /**
454
- * Result returned by generateMetadata function
455
- */
456
- interface GenerateMetadataResult {
457
- componentsGenerated: number;
458
- pageTypesGenerated: number;
459
- aspectsGenerated: number;
460
- totalFiles: number;
461
- }
462
- declare function generateMetadata(projectDirectory: string, metadataDirectory: string, options?: GenerateMetadataOptions): Promise<GenerateMetadataResult>;
463
244
  //#endregion
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 };
245
+ export { type HybridProxyPluginOptions, type StorefrontNextTargetsConfig, type UITargetDevModeConfig, storefrontNextTargets as default, hybridProxyPlugin, shouldRouteToNext, transformTargetPlaceholderPlugin, uiTargetDevModePlugin };
465
246
  //# sourceMappingURL=index.d.ts.map
@@ -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/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,gCAAA,CAAA;;;yBAUe;;EHkBd,SAAA,CAAA,IAAA,EAAA,MAAA,EAAA,EAAA,EAAA,MAA0B,CAAA,EAAA;;;;A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,CAAA,GAAqB;AHArC;AA4CA;;;;AC3BA;AA2KA;iBE5IsB,iBAAA,4BAA6C,QAAQ;;;;;;;;;APnC3E;;;;AC7BA;;;;ACWA;AAkEgB,KMxFJ,UAAA,GNwFI,aAAqB,GAAS,SAAA,GAAA,YAAA;;;;AC5E9B,UKPC,kBAAA,CLOD;;;;ECeC,mBAAA,EAAA,OAAqB;EA4CtB;;;;EC3BC;EA2KD,sBAAiB,EAAA,OAAA;;;;UIhLhB,aAAA,SAAsB,QAAQ;;QAErC;ELdO;EA4CD,gBAAA,CAAA,EAAA,MAAqB;;WKxBxB;;EJHI,IAAA,CAAA,EAAA,MAAA;EA2KD;SIlKL;;UAGC;EHVI;EAmCA,SAAA,CAAA,EAAA,OAAY;AA8C5B;AE/HA;AAKA;;iBC4EsB,YAAA,UAAsB,gBAAgB,QAAQ;;;;;;;;;ATzCpE;;;;AC7BA;;;;ACWA;AAkEgB,KQxFJA,aAAAA,GRwFyB;;;;EC5ErB,0BAAA,EAAA,MAAA;;;;ACehB,CAAA;cMjBcC;cACEC,eAAeF;;;;KCA1B,mBAAA,GAAsB;iBAOH,cAAA,yCAEC,QAAQ,+CACJ;;;;;;AXmBZ,UYitBA,uBAAA,CZjtB0B;;;;AC7B3C;;;;ACWA;AAkEA;;;;AC5EA;;;;ACeA;AA4CA;;;UQ0sBiB,sBAAA;EPruBA,mBAAA,EAAA,MAAwB;EA2KzB,kBAAA,EAAiB,MAAA;;;;ACzKjB,iBMixBM,gBAAA,CNjxBS,gBAAA,EAAA,MAAA,EAAA,iBAAA,EAAA,MAAA,EAAA,OAAA,CAAA,EMoxBjB,uBNpxBiB,CAAA,EMqxB5B,ONrxB4B,CMqxBpB,sBNrxBoB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","names":[],"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"],"sourcesContent":[],"mappings":";;;;;;;;UAuDiB,0BAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;AG5BjB;;UFDiB,mCAAA;;AGgBjB;AA4CA;;;;AC1BA;AA+PA;;;;AC7KA;;;;;;;;;;;AFpGiB,UFHA,2BAAA,CEuBH;EAwBE;;;;AC1BhB;AA+PA;;;;AC7KA;;;;;;;;;;;;;;;;;;;;;;;mBJrEqB;;;;;;;;;kCAUe;;;;;;;;;;;;;;;;;;;;;iBAsBpB,qBAAA,UAA8B,8BAAmC;;;iBC9EjE,gCAAA,CAAA;;;EH4BC,cAAA,CAAA,MAAA,EGlBc,cHkBY,CAAA,EAAA,IAAA;;;;IC7B1B,GAAA,EAAA,IAAA;;;;;UGgBA,qBAAA;EDfD;;;;ECeC,OAAA,CAAA,EAAA,OAAA;EA4CD;;;;AC1BhB;EA+PgB,cAAA,CAAA,EAAA,MAAiB;;;;AC7KjC;;;YFhFc;;;;;;;;;;;;;;;;;;;;;;;iBAwBE,qBAAA,UAA8B,wBAA6B;;;;UC1B1D,wBAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA+PD,iBAAA,UAA2B,2BAA2B;;;;;;;;;;;;;;;;;;;;;;iBC7KtD,iBAAA"}