@cloudcart/nitro 0.1.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/analytics/index.d.ts +39 -0
- package/dist/analytics/index.js +13 -0
- package/dist/analytics/index.js.map +1 -0
- package/dist/cache/index.d.ts +39 -0
- package/dist/cache/index.js +19 -0
- package/dist/cache/index.js.map +1 -0
- package/dist/cart/index.d.ts +73 -0
- package/dist/cart/index.js +9 -0
- package/dist/cart/index.js.map +1 -0
- package/dist/chunk-2VLIYNGM.js +51 -0
- package/dist/chunk-2VLIYNGM.js.map +1 -0
- package/dist/chunk-3YTOR4GE.js +25 -0
- package/dist/chunk-3YTOR4GE.js.map +1 -0
- package/dist/chunk-6DOUKEDG.js +555 -0
- package/dist/chunk-6DOUKEDG.js.map +1 -0
- package/dist/chunk-IZ4Y4UBN.js +279 -0
- package/dist/chunk-IZ4Y4UBN.js.map +1 -0
- package/dist/chunk-JHZ4UBA2.js +57 -0
- package/dist/chunk-JHZ4UBA2.js.map +1 -0
- package/dist/chunk-LVUU4ZBR.js +65 -0
- package/dist/chunk-LVUU4ZBR.js.map +1 -0
- package/dist/chunk-RKT3VKU2.js +94 -0
- package/dist/chunk-RKT3VKU2.js.map +1 -0
- package/dist/chunk-RTJ73SCX.js +45 -0
- package/dist/chunk-RTJ73SCX.js.map +1 -0
- package/dist/chunk-WJCN2EO3.js +47 -0
- package/dist/chunk-WJCN2EO3.js.map +1 -0
- package/dist/csp/index.d.ts +38 -0
- package/dist/csp/index.js +11 -0
- package/dist/csp/index.js.map +1 -0
- package/dist/errors-a5iG09pc.d.ts +42 -0
- package/dist/i18n/index.d.ts +23 -0
- package/dist/i18n/index.js +9 -0
- package/dist/i18n/index.js.map +1 -0
- package/dist/index.d.ts +54 -0
- package/dist/index.js +108 -0
- package/dist/index.js.map +1 -0
- package/dist/seo/index.d.ts +59 -0
- package/dist/seo/index.js +11 -0
- package/dist/seo/index.js.map +1 -0
- package/dist/session/index.d.ts +17 -0
- package/dist/session/index.js +7 -0
- package/dist/session/index.js.map +1 -0
- package/dist/storefront/index.d.ts +10 -0
- package/dist/storefront/index.js +14 -0
- package/dist/storefront/index.js.map +1 -0
- package/dist/types-BIsRLMWU.d.ts +152 -0
- package/dist/types-CaRAihQJ.d.ts +9 -0
- package/package.json +47 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
|
|
4
|
+
interface CspDirectives {
|
|
5
|
+
defaultSrc?: string[];
|
|
6
|
+
scriptSrc?: string[];
|
|
7
|
+
styleSrc?: string[];
|
|
8
|
+
imgSrc?: string[];
|
|
9
|
+
connectSrc?: string[];
|
|
10
|
+
fontSrc?: string[];
|
|
11
|
+
objectSrc?: string[];
|
|
12
|
+
mediaSrc?: string[];
|
|
13
|
+
frameSrc?: string[];
|
|
14
|
+
childSrc?: string[];
|
|
15
|
+
workerSrc?: string[];
|
|
16
|
+
frameAncestors?: string[];
|
|
17
|
+
formAction?: string[];
|
|
18
|
+
baseUri?: string[];
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Creates a Content Security Policy with a unique nonce per request.
|
|
22
|
+
* Mirrors Hydrogen's createContentSecurityPolicy.
|
|
23
|
+
*/
|
|
24
|
+
declare function createContentSecurityPolicy(options?: {
|
|
25
|
+
nonce?: string;
|
|
26
|
+
directives?: CspDirectives;
|
|
27
|
+
}): {
|
|
28
|
+
nonce: string;
|
|
29
|
+
header: string;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
declare function NonceProvider({ value, children }: {
|
|
33
|
+
value: string;
|
|
34
|
+
children: ReactNode;
|
|
35
|
+
}): react_jsx_runtime.JSX.Element;
|
|
36
|
+
declare function useNonce(): string;
|
|
37
|
+
|
|
38
|
+
export { type CspDirectives, NonceProvider, createContentSecurityPolicy, useNonce };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { a as StorefrontClientConfig, S as StorefrontClient } from './types-BIsRLMWU.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* createStorefrontClient — the core commerce data client.
|
|
5
|
+
*
|
|
6
|
+
* Adapted from cc-cli's GraphQLClient pattern. Key additions:
|
|
7
|
+
* - Dual-token auth (public vs private)
|
|
8
|
+
* - Automatic i18n variable injection
|
|
9
|
+
* - Query minification
|
|
10
|
+
* - Cache-aware queries
|
|
11
|
+
* - Mock fallback when no token is provided
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
declare function createStorefrontClient(config: StorefrontClientConfig): StorefrontClient;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Mock storefront client — returns sample data for development
|
|
18
|
+
* when no API token is configured.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
declare function createMockStorefrontClient(): StorefrontClient;
|
|
22
|
+
|
|
23
|
+
declare class StorefrontApiError extends Error {
|
|
24
|
+
status: number;
|
|
25
|
+
requestId?: string;
|
|
26
|
+
graphqlErrors?: Array<{
|
|
27
|
+
message: string;
|
|
28
|
+
locations?: unknown[];
|
|
29
|
+
path?: string[];
|
|
30
|
+
}>;
|
|
31
|
+
constructor(message: string, options: {
|
|
32
|
+
status: number;
|
|
33
|
+
requestId?: string;
|
|
34
|
+
graphqlErrors?: Array<{
|
|
35
|
+
message: string;
|
|
36
|
+
locations?: unknown[];
|
|
37
|
+
path?: string[];
|
|
38
|
+
}>;
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export { StorefrontApiError as S, createStorefrontClient as a, createMockStorefrontClient as c };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
interface Locale {
|
|
2
|
+
country: string;
|
|
3
|
+
language: string;
|
|
4
|
+
pathPrefix?: string;
|
|
5
|
+
}
|
|
6
|
+
interface I18nConfig {
|
|
7
|
+
defaultLocale: Locale;
|
|
8
|
+
locales: Locale[];
|
|
9
|
+
strategy: 'url-path' | 'domain' | 'subdomain' | 'cookie';
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Detects the locale from the request URL based on the i18n strategy.
|
|
14
|
+
*/
|
|
15
|
+
declare function getLocaleFromRequest(request: Request, config: I18nConfig): Locale;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Injects i18n variables ($country, $language) into a GraphQL variables object
|
|
19
|
+
* when the query references them via @inContext directive.
|
|
20
|
+
*/
|
|
21
|
+
declare function injectI18nVariables(query: string, variables: Record<string, unknown>, locale: Locale): Record<string, unknown>;
|
|
22
|
+
|
|
23
|
+
export { type I18nConfig, type Locale, getLocaleFromRequest, injectI18nVariables };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { S as StorefrontClient } from './types-BIsRLMWU.js';
|
|
2
|
+
export { A as Article, B as Blog, C as Collection, I as Image, M as Menu, b as MenuItem, c as Money, P as Page, d as Policy, e as Product, f as ProductVariant, Q as QueryOptions, g as Shop, a as StorefrontClientConfig } from './types-BIsRLMWU.js';
|
|
3
|
+
import { CartHandler } from './cart/index.js';
|
|
4
|
+
export { BuyerIdentityInput, CartData, CartHandlerConfig, CartLine, createCartHandler, createMockCartHandler } from './cart/index.js';
|
|
5
|
+
import { AppSession } from './session/index.js';
|
|
6
|
+
export { S as StorefrontApiError, c as createMockStorefrontClient, a as createStorefrontClient } from './errors-a5iG09pc.js';
|
|
7
|
+
export { C as CacheStrategy } from './types-CaRAihQJ.js';
|
|
8
|
+
export { CacheCustom, CacheLong, CacheNone, CacheShort, InMemoryCache, generateCacheControlHeader } from './cache/index.js';
|
|
9
|
+
export { MetaDescriptor, RobotsConfig, SeoConfig, SitemapEntry, generateRobots, generateSitemap, getSeoMeta } from './seo/index.js';
|
|
10
|
+
export { CspDirectives, NonceProvider, createContentSecurityPolicy, useNonce } from './csp/index.js';
|
|
11
|
+
export { AnalyticsEvent, AnalyticsEventName, AnalyticsPayload, AnalyticsProvider, AnalyticsSubscriber, useAnalytics, useAnalyticsContext } from './analytics/index.js';
|
|
12
|
+
export { I18nConfig, Locale, getLocaleFromRequest, injectI18nVariables } from './i18n/index.js';
|
|
13
|
+
import 'react-router';
|
|
14
|
+
import 'react/jsx-runtime';
|
|
15
|
+
import 'react';
|
|
16
|
+
|
|
17
|
+
interface NitroContextConfig {
|
|
18
|
+
request: Request;
|
|
19
|
+
env: {
|
|
20
|
+
SESSION_SECRET: string;
|
|
21
|
+
PUBLIC_STORE_DOMAIN?: string;
|
|
22
|
+
PUBLIC_STOREFRONT_API_TOKEN?: string;
|
|
23
|
+
PRIVATE_STOREFRONT_API_TOKEN?: string;
|
|
24
|
+
};
|
|
25
|
+
i18n?: {
|
|
26
|
+
country: string;
|
|
27
|
+
language: string;
|
|
28
|
+
};
|
|
29
|
+
/** Force mock data even when tokens are present */
|
|
30
|
+
useMock?: boolean;
|
|
31
|
+
}
|
|
32
|
+
interface NitroContext {
|
|
33
|
+
env: NitroContextConfig['env'];
|
|
34
|
+
storefront: StorefrontClient;
|
|
35
|
+
cart: CartHandler;
|
|
36
|
+
session: AppSession;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Creates the full Nitro application context.
|
|
41
|
+
* Wires together storefront client, cart handler, and session.
|
|
42
|
+
*/
|
|
43
|
+
declare function createNitroContext(config: NitroContextConfig): Promise<NitroContext>;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Helper for route loaders that works in both dev and production.
|
|
47
|
+
*
|
|
48
|
+
* In production, server.ts injects context via getLoadContext.
|
|
49
|
+
* In dev mode, the React Router Vite dev server doesn't inject context,
|
|
50
|
+
* so this function creates it lazily per-request.
|
|
51
|
+
*/
|
|
52
|
+
declare function getContext(context: Record<string, unknown> | undefined, request: Request): Promise<NitroContext>;
|
|
53
|
+
|
|
54
|
+
export { AppSession, CartHandler, type NitroContext, type NitroContextConfig, StorefrontClient, createNitroContext, getContext };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import {
|
|
2
|
+
StorefrontApiError,
|
|
3
|
+
createMockStorefrontClient,
|
|
4
|
+
createStorefrontClient
|
|
5
|
+
} from "./chunk-6DOUKEDG.js";
|
|
6
|
+
import {
|
|
7
|
+
AnalyticsEvent,
|
|
8
|
+
AnalyticsProvider,
|
|
9
|
+
useAnalytics,
|
|
10
|
+
useAnalyticsContext
|
|
11
|
+
} from "./chunk-LVUU4ZBR.js";
|
|
12
|
+
import {
|
|
13
|
+
generateCacheControlHeader
|
|
14
|
+
} from "./chunk-3YTOR4GE.js";
|
|
15
|
+
import {
|
|
16
|
+
CacheCustom,
|
|
17
|
+
CacheLong,
|
|
18
|
+
CacheNone,
|
|
19
|
+
CacheShort,
|
|
20
|
+
InMemoryCache
|
|
21
|
+
} from "./chunk-JHZ4UBA2.js";
|
|
22
|
+
import {
|
|
23
|
+
createCartHandler,
|
|
24
|
+
createMockCartHandler
|
|
25
|
+
} from "./chunk-IZ4Y4UBN.js";
|
|
26
|
+
import {
|
|
27
|
+
NonceProvider,
|
|
28
|
+
createContentSecurityPolicy,
|
|
29
|
+
useNonce
|
|
30
|
+
} from "./chunk-RTJ73SCX.js";
|
|
31
|
+
import {
|
|
32
|
+
getLocaleFromRequest,
|
|
33
|
+
injectI18nVariables
|
|
34
|
+
} from "./chunk-2VLIYNGM.js";
|
|
35
|
+
import {
|
|
36
|
+
generateRobots,
|
|
37
|
+
generateSitemap,
|
|
38
|
+
getSeoMeta
|
|
39
|
+
} from "./chunk-RKT3VKU2.js";
|
|
40
|
+
import {
|
|
41
|
+
AppSession
|
|
42
|
+
} from "./chunk-WJCN2EO3.js";
|
|
43
|
+
|
|
44
|
+
// src/context/context.ts
|
|
45
|
+
async function createNitroContext(config) {
|
|
46
|
+
const { request, env, i18n, useMock } = config;
|
|
47
|
+
if (!env.SESSION_SECRET) {
|
|
48
|
+
throw new Error("SESSION_SECRET environment variable is not set");
|
|
49
|
+
}
|
|
50
|
+
const session = await AppSession.init(request, [env.SESSION_SECRET]);
|
|
51
|
+
const useRealApi = !useMock && !!env.PUBLIC_STOREFRONT_API_TOKEN;
|
|
52
|
+
const storefront = createStorefrontClient({
|
|
53
|
+
storeDomain: env.PUBLIC_STORE_DOMAIN ?? "localhost",
|
|
54
|
+
publicStorefrontToken: useRealApi ? env.PUBLIC_STOREFRONT_API_TOKEN : "",
|
|
55
|
+
privateStorefrontToken: env.PRIVATE_STOREFRONT_API_TOKEN,
|
|
56
|
+
i18n
|
|
57
|
+
});
|
|
58
|
+
const cart = useRealApi ? createCartHandler(storefront, {
|
|
59
|
+
getCartId: () => session.get("cartId"),
|
|
60
|
+
setCartId: (id) => session.set("cartId", id)
|
|
61
|
+
}) : createMockCartHandler();
|
|
62
|
+
return { env, storefront, cart, session };
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// src/context/dev-context.ts
|
|
66
|
+
async function getContext(context, request) {
|
|
67
|
+
if (context?.storefront) {
|
|
68
|
+
return context;
|
|
69
|
+
}
|
|
70
|
+
return createNitroContext({
|
|
71
|
+
request,
|
|
72
|
+
env: {
|
|
73
|
+
SESSION_SECRET: process.env.SESSION_SECRET ?? "nitro-dev-secret",
|
|
74
|
+
PUBLIC_STORE_DOMAIN: process.env.PUBLIC_STORE_DOMAIN,
|
|
75
|
+
PUBLIC_STOREFRONT_API_TOKEN: process.env.PUBLIC_STOREFRONT_API_TOKEN,
|
|
76
|
+
PRIVATE_STOREFRONT_API_TOKEN: process.env.PRIVATE_STOREFRONT_API_TOKEN
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
export {
|
|
81
|
+
AnalyticsEvent,
|
|
82
|
+
AnalyticsProvider,
|
|
83
|
+
AppSession,
|
|
84
|
+
CacheCustom,
|
|
85
|
+
CacheLong,
|
|
86
|
+
CacheNone,
|
|
87
|
+
CacheShort,
|
|
88
|
+
InMemoryCache,
|
|
89
|
+
NonceProvider,
|
|
90
|
+
StorefrontApiError,
|
|
91
|
+
createCartHandler,
|
|
92
|
+
createContentSecurityPolicy,
|
|
93
|
+
createMockCartHandler,
|
|
94
|
+
createMockStorefrontClient,
|
|
95
|
+
createNitroContext,
|
|
96
|
+
createStorefrontClient,
|
|
97
|
+
generateCacheControlHeader,
|
|
98
|
+
generateRobots,
|
|
99
|
+
generateSitemap,
|
|
100
|
+
getContext,
|
|
101
|
+
getLocaleFromRequest,
|
|
102
|
+
getSeoMeta,
|
|
103
|
+
injectI18nVariables,
|
|
104
|
+
useAnalytics,
|
|
105
|
+
useAnalyticsContext,
|
|
106
|
+
useNonce
|
|
107
|
+
};
|
|
108
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/context/context.ts","../src/context/dev-context.ts"],"sourcesContent":["import type {NitroContextConfig, NitroContext} from './types.js';\nimport {createStorefrontClient} from '../storefront/client.js';\nimport {createCartHandler} from '../cart/handler.js';\nimport {createMockCartHandler} from '../cart/mock.js';\nimport {AppSession} from '../session/session.js';\n\n/**\n * Creates the full Nitro application context.\n * Wires together storefront client, cart handler, and session.\n */\nexport async function createNitroContext(\n config: NitroContextConfig,\n): Promise<NitroContext> {\n const {request, env, i18n, useMock} = config;\n\n if (!env.SESSION_SECRET) {\n throw new Error('SESSION_SECRET environment variable is not set');\n }\n\n const session = await AppSession.init(request, [env.SESSION_SECRET]);\n\n const useRealApi = !useMock && !!env.PUBLIC_STOREFRONT_API_TOKEN;\n\n const storefront = createStorefrontClient({\n storeDomain: env.PUBLIC_STORE_DOMAIN ?? 'localhost',\n publicStorefrontToken: useRealApi ? env.PUBLIC_STOREFRONT_API_TOKEN! : '',\n privateStorefrontToken: env.PRIVATE_STOREFRONT_API_TOKEN,\n i18n,\n });\n\n // Use real cart handler when API is available, mock otherwise\n const cart = useRealApi\n ? createCartHandler(storefront, {\n getCartId: () => session.get('cartId') as string | undefined,\n setCartId: (id: string) => session.set('cartId', id),\n })\n : createMockCartHandler();\n\n return {env, storefront, cart, session};\n}\n","import type {NitroContext} from './types.js';\nimport {createNitroContext} from './context.js';\n\n/**\n * Helper for route loaders that works in both dev and production.\n *\n * In production, server.ts injects context via getLoadContext.\n * In dev mode, the React Router Vite dev server doesn't inject context,\n * so this function creates it lazily per-request.\n */\nexport async function getContext(\n context: Record<string, unknown> | undefined,\n request: Request,\n): Promise<NitroContext> {\n // Production: context was injected by server.ts\n if (context?.storefront) {\n return context as unknown as NitroContext;\n }\n\n // Dev mode: create context on the fly\n return createNitroContext({\n request,\n env: {\n SESSION_SECRET: process.env.SESSION_SECRET ?? 'nitro-dev-secret',\n PUBLIC_STORE_DOMAIN: process.env.PUBLIC_STORE_DOMAIN,\n PUBLIC_STOREFRONT_API_TOKEN: process.env.PUBLIC_STOREFRONT_API_TOKEN,\n PRIVATE_STOREFRONT_API_TOKEN: process.env.PRIVATE_STOREFRONT_API_TOKEN,\n },\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAUA,eAAsB,mBACpB,QACuB;AACvB,QAAM,EAAC,SAAS,KAAK,MAAM,QAAO,IAAI;AAEtC,MAAI,CAAC,IAAI,gBAAgB;AACvB,UAAM,IAAI,MAAM,gDAAgD;AAAA,EAClE;AAEA,QAAM,UAAU,MAAM,WAAW,KAAK,SAAS,CAAC,IAAI,cAAc,CAAC;AAEnE,QAAM,aAAa,CAAC,WAAW,CAAC,CAAC,IAAI;AAErC,QAAM,aAAa,uBAAuB;AAAA,IACxC,aAAa,IAAI,uBAAuB;AAAA,IACxC,uBAAuB,aAAa,IAAI,8BAA+B;AAAA,IACvE,wBAAwB,IAAI;AAAA,IAC5B;AAAA,EACF,CAAC;AAGD,QAAM,OAAO,aACT,kBAAkB,YAAY;AAAA,IAC5B,WAAW,MAAM,QAAQ,IAAI,QAAQ;AAAA,IACrC,WAAW,CAAC,OAAe,QAAQ,IAAI,UAAU,EAAE;AAAA,EACrD,CAAC,IACD,sBAAsB;AAE1B,SAAO,EAAC,KAAK,YAAY,MAAM,QAAO;AACxC;;;AC7BA,eAAsB,WACpB,SACA,SACuB;AAEvB,MAAI,SAAS,YAAY;AACvB,WAAO;AAAA,EACT;AAGA,SAAO,mBAAmB;AAAA,IACxB;AAAA,IACA,KAAK;AAAA,MACH,gBAAgB,QAAQ,IAAI,kBAAkB;AAAA,MAC9C,qBAAqB,QAAQ,IAAI;AAAA,MACjC,6BAA6B,QAAQ,IAAI;AAAA,MACzC,8BAA8B,QAAQ,IAAI;AAAA,IAC5C;AAAA,EACF,CAAC;AACH;","names":[]}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* getSeoMeta — generates React Router meta descriptors from SEO config.
|
|
3
|
+
* Mirrors Hydrogen's getSeoMeta utility.
|
|
4
|
+
*/
|
|
5
|
+
interface SeoConfig {
|
|
6
|
+
title?: string;
|
|
7
|
+
description?: string;
|
|
8
|
+
url?: string;
|
|
9
|
+
image?: {
|
|
10
|
+
url: string;
|
|
11
|
+
width?: number;
|
|
12
|
+
height?: number;
|
|
13
|
+
altText?: string;
|
|
14
|
+
};
|
|
15
|
+
type?: 'website' | 'product' | 'article';
|
|
16
|
+
jsonLd?: Record<string, unknown> | Record<string, unknown>[];
|
|
17
|
+
}
|
|
18
|
+
interface MetaDescriptor {
|
|
19
|
+
title?: string;
|
|
20
|
+
name?: string;
|
|
21
|
+
property?: string;
|
|
22
|
+
content?: string;
|
|
23
|
+
rel?: string;
|
|
24
|
+
href?: string;
|
|
25
|
+
'script:ld+json'?: Record<string, unknown> | Record<string, unknown>[];
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Generates an array of meta descriptors compatible with React Router's
|
|
29
|
+
* `meta` export. Supports title, description, Open Graph, Twitter, and JSON-LD.
|
|
30
|
+
*
|
|
31
|
+
* Merge multiple configs by spreading: `getSeoMeta(parentSeo, childSeo)`
|
|
32
|
+
*/
|
|
33
|
+
declare function getSeoMeta(...configs: (SeoConfig | undefined)[]): MetaDescriptor[];
|
|
34
|
+
|
|
35
|
+
interface SitemapEntry {
|
|
36
|
+
url: string;
|
|
37
|
+
lastmod?: string;
|
|
38
|
+
changefreq?: 'always' | 'hourly' | 'daily' | 'weekly' | 'monthly' | 'yearly' | 'never';
|
|
39
|
+
priority?: number;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Generates an XML sitemap string from an array of entries.
|
|
43
|
+
*/
|
|
44
|
+
declare function generateSitemap(entries: SitemapEntry[]): string;
|
|
45
|
+
|
|
46
|
+
interface RobotsConfig {
|
|
47
|
+
rules: Array<{
|
|
48
|
+
userAgent: string;
|
|
49
|
+
allow?: string[];
|
|
50
|
+
disallow?: string[];
|
|
51
|
+
}>;
|
|
52
|
+
sitemap?: string;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Generates a robots.txt string from configuration.
|
|
56
|
+
*/
|
|
57
|
+
declare function generateRobots(config: RobotsConfig): string;
|
|
58
|
+
|
|
59
|
+
export { type MetaDescriptor, type RobotsConfig, type SeoConfig, type SitemapEntry, generateRobots, generateSitemap, getSeoMeta };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { SessionStorage, Session } from 'react-router';
|
|
2
|
+
|
|
3
|
+
declare class AppSession {
|
|
4
|
+
#private;
|
|
5
|
+
isPending: boolean;
|
|
6
|
+
constructor(sessionStorage: SessionStorage, session: Session);
|
|
7
|
+
static init(request: Request, secrets: string[]): Promise<AppSession>;
|
|
8
|
+
get has(): (name: string) => boolean;
|
|
9
|
+
get get(): <Key extends string>(name: Key) => (Key extends string | number ? any : undefined) | (Key extends string | number ? any : undefined) | undefined;
|
|
10
|
+
get flash(): <Key extends string>(name: Key, value: any) => void;
|
|
11
|
+
set(key: string, value: unknown): void;
|
|
12
|
+
unset(key: string): void;
|
|
13
|
+
destroy(): Promise<string>;
|
|
14
|
+
commit(): Promise<string>;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export { AppSession };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { S as StorefrontApiError, c as createMockStorefrontClient, a as createStorefrontClient } from '../errors-a5iG09pc.js';
|
|
2
|
+
export { Q as QueryOptions, S as StorefrontClient, a as StorefrontClientConfig } from '../types-BIsRLMWU.js';
|
|
3
|
+
import '../types-CaRAihQJ.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Minifies a GraphQL query string by removing comments and excess whitespace.
|
|
7
|
+
*/
|
|
8
|
+
declare function minifyQuery(query: string): string;
|
|
9
|
+
|
|
10
|
+
export { minifyQuery };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import {
|
|
2
|
+
StorefrontApiError,
|
|
3
|
+
createMockStorefrontClient,
|
|
4
|
+
createStorefrontClient,
|
|
5
|
+
minifyQuery
|
|
6
|
+
} from "../chunk-6DOUKEDG.js";
|
|
7
|
+
import "../chunk-JHZ4UBA2.js";
|
|
8
|
+
export {
|
|
9
|
+
StorefrontApiError,
|
|
10
|
+
createMockStorefrontClient,
|
|
11
|
+
createStorefrontClient,
|
|
12
|
+
minifyQuery
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { C as CacheStrategy } from './types-CaRAihQJ.js';
|
|
2
|
+
|
|
3
|
+
interface Money {
|
|
4
|
+
amount: string;
|
|
5
|
+
currencyCode: string;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
interface Image {
|
|
9
|
+
id: string;
|
|
10
|
+
url: string;
|
|
11
|
+
altText: string | null;
|
|
12
|
+
width: number;
|
|
13
|
+
height: number;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
interface ProductVariant {
|
|
17
|
+
id: string;
|
|
18
|
+
title: string;
|
|
19
|
+
availableForSale: boolean;
|
|
20
|
+
price: Money;
|
|
21
|
+
compareAtPrice: Money | null;
|
|
22
|
+
image: Image | null;
|
|
23
|
+
selectedOptions: {
|
|
24
|
+
name: string;
|
|
25
|
+
value: string;
|
|
26
|
+
}[];
|
|
27
|
+
}
|
|
28
|
+
interface Product {
|
|
29
|
+
id: string;
|
|
30
|
+
title: string;
|
|
31
|
+
handle: string;
|
|
32
|
+
description: string;
|
|
33
|
+
descriptionHtml: string;
|
|
34
|
+
featuredImage: Image | null;
|
|
35
|
+
options: {
|
|
36
|
+
name: string;
|
|
37
|
+
values: string[];
|
|
38
|
+
}[];
|
|
39
|
+
variants: {
|
|
40
|
+
nodes: ProductVariant[];
|
|
41
|
+
};
|
|
42
|
+
priceRange: {
|
|
43
|
+
minVariantPrice: Money;
|
|
44
|
+
maxVariantPrice: Money;
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
interface Collection {
|
|
48
|
+
id: string;
|
|
49
|
+
title: string;
|
|
50
|
+
handle: string;
|
|
51
|
+
description: string;
|
|
52
|
+
image: Image | null;
|
|
53
|
+
products?: {
|
|
54
|
+
nodes: Product[];
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
interface MenuItem {
|
|
58
|
+
id: string;
|
|
59
|
+
title: string;
|
|
60
|
+
url: string;
|
|
61
|
+
items: MenuItem[];
|
|
62
|
+
}
|
|
63
|
+
interface Menu {
|
|
64
|
+
id: string;
|
|
65
|
+
items: MenuItem[];
|
|
66
|
+
}
|
|
67
|
+
interface Shop {
|
|
68
|
+
name: string;
|
|
69
|
+
description: string | null;
|
|
70
|
+
}
|
|
71
|
+
interface Page {
|
|
72
|
+
id: string;
|
|
73
|
+
title: string;
|
|
74
|
+
handle: string;
|
|
75
|
+
body: string;
|
|
76
|
+
}
|
|
77
|
+
interface Blog {
|
|
78
|
+
id: string;
|
|
79
|
+
title: string;
|
|
80
|
+
handle: string;
|
|
81
|
+
}
|
|
82
|
+
interface Article {
|
|
83
|
+
id: string;
|
|
84
|
+
title: string;
|
|
85
|
+
handle: string;
|
|
86
|
+
contentHtml: string;
|
|
87
|
+
excerpt: string;
|
|
88
|
+
publishedAt: string;
|
|
89
|
+
image: Image | null;
|
|
90
|
+
blog: {
|
|
91
|
+
handle: string;
|
|
92
|
+
};
|
|
93
|
+
author: {
|
|
94
|
+
name: string;
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
interface Policy {
|
|
98
|
+
id: string;
|
|
99
|
+
title: string;
|
|
100
|
+
handle: string;
|
|
101
|
+
body: string;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
interface StorefrontClientConfig {
|
|
105
|
+
/** Store domain, e.g. "mystore.cloudcart.com" */
|
|
106
|
+
storeDomain: string;
|
|
107
|
+
/** Public API token (safe for client-side use) */
|
|
108
|
+
publicStorefrontToken: string;
|
|
109
|
+
/** Private API token (server-side only) */
|
|
110
|
+
privateStorefrontToken?: string;
|
|
111
|
+
/** API version, defaults to '2026-01' */
|
|
112
|
+
apiVersion?: string;
|
|
113
|
+
/** Storefront API endpoint path, defaults to '/api/sf' */
|
|
114
|
+
apiPath?: string;
|
|
115
|
+
/** Default i18n context injected into all queries */
|
|
116
|
+
i18n?: {
|
|
117
|
+
country: string;
|
|
118
|
+
language: string;
|
|
119
|
+
};
|
|
120
|
+
/** Default cache strategy for queries */
|
|
121
|
+
defaultCache?: CacheStrategy;
|
|
122
|
+
}
|
|
123
|
+
interface QueryOptions {
|
|
124
|
+
variables?: Record<string, unknown>;
|
|
125
|
+
cache?: CacheStrategy;
|
|
126
|
+
}
|
|
127
|
+
interface StorefrontClient {
|
|
128
|
+
/** Execute a raw GraphQL query */
|
|
129
|
+
query<T = unknown>(query: string, options?: QueryOptions): Promise<T>;
|
|
130
|
+
/** Execute a raw GraphQL mutation */
|
|
131
|
+
mutate<T = unknown>(mutation: string, options?: QueryOptions): Promise<T>;
|
|
132
|
+
getShop(): Promise<Shop>;
|
|
133
|
+
getProducts(first?: number): Promise<Product[]>;
|
|
134
|
+
getProduct(handle: string): Promise<Product | null>;
|
|
135
|
+
getCollections(first?: number): Promise<Collection[]>;
|
|
136
|
+
getCollection(handle: string): Promise<Collection | null>;
|
|
137
|
+
getMenu(handle: string): Promise<Menu | null>;
|
|
138
|
+
getPage(handle: string): Promise<Page | null>;
|
|
139
|
+
searchProducts(query: string, first?: number): Promise<Product[]>;
|
|
140
|
+
getBlogs(first?: number): Promise<Blog[]>;
|
|
141
|
+
getBlog(handle: string): Promise<Blog | null>;
|
|
142
|
+
getArticle(blogHandle: string, articleHandle: string): Promise<Article | null>;
|
|
143
|
+
getArticles(blogHandle: string, first?: number): Promise<Article[]>;
|
|
144
|
+
getPolicies(): Promise<Policy[]>;
|
|
145
|
+
getPolicy(handle: string): Promise<Policy | null>;
|
|
146
|
+
CacheShort: () => CacheStrategy;
|
|
147
|
+
CacheLong: () => CacheStrategy;
|
|
148
|
+
CacheNone: () => CacheStrategy;
|
|
149
|
+
CacheCustom: (options: Partial<CacheStrategy>) => CacheStrategy;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
export type { Article as A, Blog as B, Collection as C, Image as I, Menu as M, Page as P, QueryOptions as Q, StorefrontClient as S, StorefrontClientConfig as a, MenuItem as b, Money as c, Policy as d, Product as e, ProductVariant as f, Shop as g };
|
package/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@cloudcart/nitro",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "CloudCart Nitro — headless commerce framework for React Router",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "dist/index.js",
|
|
8
|
+
"types": "dist/index.d.ts",
|
|
9
|
+
"files": [
|
|
10
|
+
"dist"
|
|
11
|
+
],
|
|
12
|
+
"exports": {
|
|
13
|
+
".": "./dist/index.js",
|
|
14
|
+
"./storefront": "./dist/storefront/index.js",
|
|
15
|
+
"./cart": "./dist/cart/index.js",
|
|
16
|
+
"./cache": "./dist/cache/index.js",
|
|
17
|
+
"./seo": "./dist/seo/index.js",
|
|
18
|
+
"./csp": "./dist/csp/index.js",
|
|
19
|
+
"./analytics": "./dist/analytics/index.js",
|
|
20
|
+
"./i18n": "./dist/i18n/index.js",
|
|
21
|
+
"./session": "./dist/session/index.js"
|
|
22
|
+
},
|
|
23
|
+
"scripts": {
|
|
24
|
+
"build": "tsup",
|
|
25
|
+
"dev": "tsup --watch",
|
|
26
|
+
"clean": "rm -rf dist",
|
|
27
|
+
"typecheck": "tsc --noEmit"
|
|
28
|
+
},
|
|
29
|
+
"peerDependencies": {
|
|
30
|
+
"react": "^18.0.0 || ^19.0.0",
|
|
31
|
+
"react-router": "^7.0.0"
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"@types/node": "^25.5.0",
|
|
35
|
+
"@types/react": "^19.1.0",
|
|
36
|
+
"react": "^19.1.0",
|
|
37
|
+
"react-router": "^7.12.0",
|
|
38
|
+
"tsup": "^8.3.6",
|
|
39
|
+
"typescript": "^5.7.3"
|
|
40
|
+
},
|
|
41
|
+
"publishConfig": {
|
|
42
|
+
"access": "public"
|
|
43
|
+
},
|
|
44
|
+
"engines": {
|
|
45
|
+
"node": ">=20.0.0"
|
|
46
|
+
}
|
|
47
|
+
}
|