@cmssy/core 9.4.0 → 9.6.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/index.cjs +145 -1
- package/dist/index.d.cts +42 -2
- package/dist/index.d.ts +42 -2
- package/dist/index.js +144 -2
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -747,6 +747,139 @@ function localizeHtmlLinks(html, locale) {
|
|
|
747
747
|
);
|
|
748
748
|
}
|
|
749
749
|
|
|
750
|
+
// src/data/relation-resolver.ts
|
|
751
|
+
var RECORDS_BY_IDS_QUERY = `query PublicRecordsByIds($workspaceId: String!, $ids: [String!]!, $locale: String) {
|
|
752
|
+
public {
|
|
753
|
+
model {
|
|
754
|
+
recordsByIds(workspaceId: $workspaceId, ids: $ids, locale: $locale) {
|
|
755
|
+
id modelId data status createdAt updatedAt
|
|
756
|
+
}
|
|
757
|
+
}
|
|
758
|
+
}
|
|
759
|
+
}`;
|
|
760
|
+
var BY_IDS_CHUNK = 50;
|
|
761
|
+
var COLLECTION_DEFAULT_LIMIT = 50;
|
|
762
|
+
function relationModel(field) {
|
|
763
|
+
return field.relationTo?.startsWith("model:") ? field.relationTo.slice("model:".length) : void 0;
|
|
764
|
+
}
|
|
765
|
+
function storedIds(value) {
|
|
766
|
+
if (typeof value === "string" && value) return [value];
|
|
767
|
+
if (Array.isArray(value)) {
|
|
768
|
+
return value.filter((id) => typeof id === "string" && !!id);
|
|
769
|
+
}
|
|
770
|
+
return [];
|
|
771
|
+
}
|
|
772
|
+
function collectRefs(entries, schemas) {
|
|
773
|
+
const refs = [];
|
|
774
|
+
for (const entry of entries) {
|
|
775
|
+
const schema = schemas[entry.type];
|
|
776
|
+
if (!schema) continue;
|
|
777
|
+
for (const [key, field] of Object.entries(schema)) {
|
|
778
|
+
if (field.type !== "relation") continue;
|
|
779
|
+
const model = relationModel(field);
|
|
780
|
+
if (!model) continue;
|
|
781
|
+
refs.push({ content: entry.content, key, field, model });
|
|
782
|
+
}
|
|
783
|
+
}
|
|
784
|
+
return refs;
|
|
785
|
+
}
|
|
786
|
+
function collectionKey(ref) {
|
|
787
|
+
return [ref.model, ref.field.sort ?? "", ref.field.limit ?? ""].join("\0");
|
|
788
|
+
}
|
|
789
|
+
async function resolveRelationContent(config, entries, schemas, locale, requestOptions = {}) {
|
|
790
|
+
const refs = collectRefs(entries, schemas);
|
|
791
|
+
if (refs.length === 0) return;
|
|
792
|
+
const client = createCmssyClient(config);
|
|
793
|
+
const pickedIds = /* @__PURE__ */ new Set();
|
|
794
|
+
const collections = /* @__PURE__ */ new Map();
|
|
795
|
+
for (const ref of refs) {
|
|
796
|
+
if (ref.field.relationMode === "all") {
|
|
797
|
+
collections.set(collectionKey(ref), {
|
|
798
|
+
model: ref.model,
|
|
799
|
+
sort: ref.field.sort,
|
|
800
|
+
limit: ref.field.limit
|
|
801
|
+
});
|
|
802
|
+
} else {
|
|
803
|
+
for (const id of storedIds(ref.content[ref.key])) pickedIds.add(id);
|
|
804
|
+
}
|
|
805
|
+
}
|
|
806
|
+
let recordsById;
|
|
807
|
+
let collectionItems;
|
|
808
|
+
try {
|
|
809
|
+
[recordsById, collectionItems] = await Promise.all([
|
|
810
|
+
fetchPickedRecords(client, [...pickedIds], locale, requestOptions),
|
|
811
|
+
fetchCollections(client, collections, locale, requestOptions)
|
|
812
|
+
]);
|
|
813
|
+
} catch (err) {
|
|
814
|
+
if (typeof console !== "undefined") {
|
|
815
|
+
console.error("[cmssy] relation resolution failed", err);
|
|
816
|
+
}
|
|
817
|
+
for (const ref of refs) {
|
|
818
|
+
if (ref.field.relationMode === "all" || Array.isArray(ref.content[ref.key])) {
|
|
819
|
+
ref.content[ref.key] = [];
|
|
820
|
+
} else {
|
|
821
|
+
delete ref.content[ref.key];
|
|
822
|
+
}
|
|
823
|
+
}
|
|
824
|
+
return;
|
|
825
|
+
}
|
|
826
|
+
for (const ref of refs) {
|
|
827
|
+
if (ref.field.relationMode === "all") {
|
|
828
|
+
ref.content[ref.key] = collectionItems.get(collectionKey(ref)) ?? [];
|
|
829
|
+
continue;
|
|
830
|
+
}
|
|
831
|
+
const value = ref.content[ref.key];
|
|
832
|
+
if (Array.isArray(value)) {
|
|
833
|
+
ref.content[ref.key] = storedIds(value).map((id) => recordsById.get(id)).filter((record) => !!record);
|
|
834
|
+
} else if (typeof value === "string" && value) {
|
|
835
|
+
const record = recordsById.get(value);
|
|
836
|
+
if (record) ref.content[ref.key] = record;
|
|
837
|
+
else delete ref.content[ref.key];
|
|
838
|
+
} else {
|
|
839
|
+
delete ref.content[ref.key];
|
|
840
|
+
}
|
|
841
|
+
}
|
|
842
|
+
}
|
|
843
|
+
async function fetchPickedRecords(client, ids, locale, requestOptions = {}) {
|
|
844
|
+
const byId = /* @__PURE__ */ new Map();
|
|
845
|
+
const chunks = [];
|
|
846
|
+
for (let i = 0; i < ids.length; i += BY_IDS_CHUNK) {
|
|
847
|
+
chunks.push(ids.slice(i, i + BY_IDS_CHUNK));
|
|
848
|
+
}
|
|
849
|
+
await Promise.all(
|
|
850
|
+
chunks.map(async (chunk) => {
|
|
851
|
+
const result = await client.queryScoped(
|
|
852
|
+
RECORDS_BY_IDS_QUERY,
|
|
853
|
+
{ ids: chunk, locale: locale ?? null },
|
|
854
|
+
requestOptions
|
|
855
|
+
);
|
|
856
|
+
for (const record of result.public.model.recordsByIds) {
|
|
857
|
+
byId.set(record.id, record);
|
|
858
|
+
}
|
|
859
|
+
})
|
|
860
|
+
);
|
|
861
|
+
return byId;
|
|
862
|
+
}
|
|
863
|
+
async function fetchCollections(client, collections, locale, requestOptions = {}) {
|
|
864
|
+
const byKey = /* @__PURE__ */ new Map();
|
|
865
|
+
await Promise.all(
|
|
866
|
+
[...collections.entries()].map(async ([key, { model, sort, limit }]) => {
|
|
867
|
+
const result = await client.queryScoped(
|
|
868
|
+
MODEL_RECORDS_QUERY,
|
|
869
|
+
{
|
|
870
|
+
modelSlug: model,
|
|
871
|
+
sort: sort ?? null,
|
|
872
|
+
limit: limit ?? COLLECTION_DEFAULT_LIMIT,
|
|
873
|
+
locale: locale ?? null
|
|
874
|
+
},
|
|
875
|
+
requestOptions
|
|
876
|
+
);
|
|
877
|
+
byKey.set(key, result.public.model.records.items);
|
|
878
|
+
})
|
|
879
|
+
);
|
|
880
|
+
return byKey;
|
|
881
|
+
}
|
|
882
|
+
|
|
750
883
|
// src/locale.ts
|
|
751
884
|
var CMSSY_LOCALE_HEADER = "x-cmssy-locale";
|
|
752
885
|
async function localeForPathname(config, pathname) {
|
|
@@ -810,7 +943,16 @@ var fields = {
|
|
|
810
943
|
radio: choice("radio"),
|
|
811
944
|
multiselect: (opts) => build("multiselect", opts),
|
|
812
945
|
media: (opts = {}) => build("media", opts),
|
|
813
|
-
repeater: (opts) => build("repeater", opts)
|
|
946
|
+
repeater: (opts) => build("repeater", opts),
|
|
947
|
+
relation: (opts) => {
|
|
948
|
+
const { model, mode, ...rest } = opts;
|
|
949
|
+
return build("relation", {
|
|
950
|
+
...rest,
|
|
951
|
+
relationTo: `model:${model}`,
|
|
952
|
+
relationType: mode === "all" || opts.multiple ? "hasMany" : "hasOne",
|
|
953
|
+
relationMode: mode ?? "picked"
|
|
954
|
+
});
|
|
955
|
+
}
|
|
814
956
|
};
|
|
815
957
|
|
|
816
958
|
// src/bridge/protocol.ts
|
|
@@ -1747,6 +1889,7 @@ exports.MODEL_DEFINITIONS_QUERY = MODEL_DEFINITIONS_QUERY;
|
|
|
1747
1889
|
exports.MODEL_RECORDS_QUERY = MODEL_RECORDS_QUERY;
|
|
1748
1890
|
exports.PRODUCTS_QUERY = PRODUCTS_QUERY;
|
|
1749
1891
|
exports.PROTOCOL_VERSION = PROTOCOL_VERSION;
|
|
1892
|
+
exports.RECORDS_BY_IDS_QUERY = RECORDS_BY_IDS_QUERY;
|
|
1750
1893
|
exports.SESSION_MAX_AGE_SECONDS = SESSION_MAX_AGE_SECONDS;
|
|
1751
1894
|
exports.SITE_CONFIG_QUERY = SITE_CONFIG_QUERY;
|
|
1752
1895
|
exports.SUBMIT_FORM_MUTATION = SUBMIT_FORM_MUTATION;
|
|
@@ -1820,6 +1963,7 @@ exports.resolveEditorOrigin = resolveEditorOrigin;
|
|
|
1820
1963
|
exports.resolveForms = resolveForms;
|
|
1821
1964
|
exports.resolveInitialTarget = resolveInitialTarget;
|
|
1822
1965
|
exports.resolvePublicUrl = resolvePublicUrl;
|
|
1966
|
+
exports.resolveRelationContent = resolveRelationContent;
|
|
1823
1967
|
exports.resolveSiteLocales = resolveSiteLocales;
|
|
1824
1968
|
exports.resolveWorkspaceId = resolveWorkspaceId;
|
|
1825
1969
|
exports.sealSession = sealSession;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _cmssy_types from '@cmssy/types';
|
|
2
|
-
import { CmssyAuthConfig, CmssyClientConfig, CmssySiteConfig, RawBlock, CmssyFormDefinition, CmssySiteLocales, BuildBlockContextExtra, CmssyBlockContext, CmssyLocaleContext, FieldOptions, TypedField, BlockPropsSchema, InferBlockContent, BlockRect, BlockSchema, BlockMeta, CmssySessionPayload, SessionCookieOptions, CmssySessionUser, CmssyAddress, CmssyCart, CmssyOrder, CmssyProduct, MyOrdersResult, FetchProductOptions, FetchProductsOptions, CmssyProductPage, FetchOrderByTokenOptions, VerifyCmssyWebhookOptions, CmssyWebhookEvent } from '@cmssy/types';
|
|
2
|
+
import { CmssyAuthConfig, CmssyClientConfig, CmssySiteConfig, RawBlock, CmssyFormDefinition, CmssySiteLocales, BuildBlockContextExtra, CmssyBlockContext, CmssyLocaleContext, FieldDefinition, FieldOptions, TypedField, BlockPropsSchema, InferBlockContent, RelationMode, CmssyModelRecord, BlockRect, BlockSchema, BlockMeta, CmssySessionPayload, SessionCookieOptions, CmssySessionUser, CmssyAddress, CmssyCart, CmssyOrder, CmssyProduct, MyOrdersResult, FetchProductOptions, FetchProductsOptions, CmssyProductPage, FetchOrderByTokenOptions, VerifyCmssyWebhookOptions, CmssyWebhookEvent } from '@cmssy/types';
|
|
3
3
|
export { BlockMeta, BlockPropsSchema, BlockRect, BlockSchema, BuildBlockContextExtra, CmssyAddress, CmssyAuthConfig, CmssyBlockAuthContext, CmssyBlockContext, CmssyBlockMember, CmssyBlockWorkspace, CmssyBranding, CmssyCart, CmssyCartDiscount, CmssyCartItem, CmssyCartItemSnapshot, CmssyClientConfig, CmssyFormDefinition, CmssyFormField, CmssyFormSettings, CmssyFormSubmitResponse, CmssyLayoutGroup, CmssyLayoutSettings, CmssyLocaleContext, CmssyLocalizedValue, CmssyModelDefinition, CmssyModelRecord, CmssyOrder, CmssyOrderDiscount, CmssyOrderItem, CmssyOrderTaxSummaryLine, CmssyPageData, CmssyPageMeta, CmssyPageSummary, CmssyPriceTier, CmssyProduct, CmssyProductPage, CmssyProductVariant, CmssyRecordList, CmssySessionPayload, CmssySessionUser, CmssyShippingMethod, CmssySiteConfig, CmssySiteLocales, CmssyStockState, CmssyTaxSummaryLine, CmssyWebhookEvent, CmssyWebhookOrder, FetchOrderByTokenOptions, FetchProductOptions, FetchProductsOptions, FieldCondition, FieldConditionGroup, FieldConditionLogic, FieldControl, FieldDefinition, FieldOptions, FieldType, InferBlockContent, MyOrdersResult, RawBlock, RawLayoutBlock, SessionCookieOptions, SubmitFormInput, TypedField, VerifyCmssyWebhookOptions, evaluateFieldConditionGroup } from '@cmssy/types';
|
|
4
4
|
import { F as FetchLike, R as RetryPolicy } from './content-client-D0EdiqbQ.cjs';
|
|
5
5
|
export { C as CmssyRequestError, D as DEFAULT_CMSSY_API_URL, a as FetchLikeResponse, b as FetchPageOptions, f as fetchLayouts, c as fetchPage, d as fetchPageById, e as fetchPageMeta, g as fetchPages, n as normalizeSlug, r as resolveApiUrl, h as resolvePublicUrl } from './content-client-D0EdiqbQ.cjs';
|
|
@@ -158,6 +158,21 @@ declare function buildLocaleSwitchHref(target: string, pathname: string, locale:
|
|
|
158
158
|
*/
|
|
159
159
|
declare function localizeHtmlLinks(html: string, locale: CmssyLocaleContext): string;
|
|
160
160
|
|
|
161
|
+
declare const RECORDS_BY_IDS_QUERY = "query PublicRecordsByIds($workspaceId: String!, $ids: [String!]!, $locale: String) {\n public {\n model {\n recordsByIds(workspaceId: $workspaceId, ids: $ids, locale: $locale) {\n id modelId data status createdAt updatedAt\n }\n }\n }\n}";
|
|
162
|
+
interface RelationContentEntry {
|
|
163
|
+
type: string;
|
|
164
|
+
content: Record<string, unknown>;
|
|
165
|
+
}
|
|
166
|
+
type BlockSchemaMap = Record<string, Record<string, FieldDefinition>>;
|
|
167
|
+
/**
|
|
168
|
+
* Resolves every `fields.relation` value on the given block contents in place:
|
|
169
|
+
* stored record ids become full records (one batched read for the whole page),
|
|
170
|
+
* and a `mode: "all"` field becomes the model's record list. A dangling id and
|
|
171
|
+
* a failed fetch both degrade to "no value" - a relation must never break a
|
|
172
|
+
* render.
|
|
173
|
+
*/
|
|
174
|
+
declare function resolveRelationContent(config: CmssyClientConfig, entries: RelationContentEntry[], schemas: BlockSchemaMap, locale?: string, requestOptions?: QueryScopedOptions): Promise<void>;
|
|
175
|
+
|
|
161
176
|
declare const CMSSY_LOCALE_HEADER = "x-cmssy-locale";
|
|
162
177
|
declare function localeForPathname(config: CmssyClientConfig, pathname: string): Promise<string>;
|
|
163
178
|
declare function splitCmssyLocale(config: CmssyClientConfig, path: string[] | undefined): Promise<{
|
|
@@ -182,6 +197,30 @@ type MediaValue<O> = O extends {
|
|
|
182
197
|
type RepeaterValue<O> = O extends {
|
|
183
198
|
itemSchema: infer Schema extends BlockPropsSchema;
|
|
184
199
|
} ? InferBlockContent<Schema>[] : Record<string, unknown>[];
|
|
200
|
+
/**
|
|
201
|
+
* The value a relation field holds AFTER server-side resolution: the SDK
|
|
202
|
+
* replaces the stored record id(s) with the records themselves before the
|
|
203
|
+
* component renders. `mode: "all"` and `multiple: true` yield a list; the
|
|
204
|
+
* default is a single record - `undefined` when the reference dangles, which
|
|
205
|
+
* no `required` flag can rule out.
|
|
206
|
+
*/
|
|
207
|
+
type RelationValue<O> = O extends {
|
|
208
|
+
mode: "all";
|
|
209
|
+
} | {
|
|
210
|
+
multiple: true;
|
|
211
|
+
} ? CmssyModelRecord[] : CmssyModelRecord | undefined;
|
|
212
|
+
interface RelationFieldOptions extends Omit<FieldOptions, "options" | "itemSchema"> {
|
|
213
|
+
/** Slug of the model the field points at. */
|
|
214
|
+
model: string;
|
|
215
|
+
/**
|
|
216
|
+
* "all" binds the field to every record of the model (no editor picking;
|
|
217
|
+
* `sort`/`limit` shape the list). Omit it for editor-picked record id(s).
|
|
218
|
+
*/
|
|
219
|
+
mode?: RelationMode;
|
|
220
|
+
multiple?: boolean;
|
|
221
|
+
sort?: string;
|
|
222
|
+
limit?: number;
|
|
223
|
+
}
|
|
185
224
|
declare const fields: {
|
|
186
225
|
text: <const O extends FieldOptions>(opts?: O) => TypedField<string, Declared<O>>;
|
|
187
226
|
textarea: <const O extends FieldOptions>(opts?: O) => TypedField<string, Declared<O>>;
|
|
@@ -204,6 +243,7 @@ declare const fields: {
|
|
|
204
243
|
multiselect: <const O extends FieldOptions>(opts: O) => TypedField<OptionValue<O>[], Declared<O>>;
|
|
205
244
|
media: <const O extends FieldOptions>(opts?: O) => TypedField<MediaValue<O>, Declared<O>>;
|
|
206
245
|
repeater: <const O extends FieldOptions>(opts: O) => TypedField<RepeaterValue<O>, Declared<O>>;
|
|
246
|
+
relation: <const O extends RelationFieldOptions>(opts: O) => TypedField<RelationValue<O>, Declared<O>>;
|
|
207
247
|
};
|
|
208
248
|
|
|
209
249
|
declare const PROTOCOL_VERSION = 2;
|
|
@@ -447,4 +487,4 @@ declare class CmssyWebhookError extends Error {
|
|
|
447
487
|
*/
|
|
448
488
|
declare function verifyCmssyWebhook(options: VerifyCmssyWebhookOptions): Promise<CmssyWebhookEvent>;
|
|
449
489
|
|
|
450
|
-
export { type AppToEditorMessage, type AuthMutationResult, type AuthTokenResult, type BoundsMessage, CMSSY_EDIT_HEADER, CMSSY_EDIT_QUERY_PARAM, CMSSY_LOCALE_HEADER, CMSSY_SECRET_QUERY_PARAM, CMSSY_SESSION_COOKIE, type CartRequestContext, type CheckoutInput, type ClickMessage, type CmssyClient, type CmssyConfig, type CmssyCspOptions, type CmssyEnvConfig, CmssyWebhookError, DEFAULT_CMSSY_EDITOR_ORIGINS, type EditorToAppMessage, FORM_QUERY, FetchLike, type GraphqlRequestOptions, MIN_SESSION_SECRET_LENGTH, MODEL_DEFINITIONS_QUERY, MODEL_RECORDS_QUERY, PRODUCTS_QUERY, PROTOCOL_VERSION, type ParentReadyMessage, type PatchMessage, type PostTarget, type QueryScopedOptions, type ReadyMessage, RetryPolicy, SESSION_MAX_AGE_SECONDS, SITE_CONFIG_QUERY, SUBMIT_FORM_MUTATION, type SelectMessage, applyCmssyCsp, asBucket, assertAuthConfig, backendAddToCart, backendApplyDiscount, backendCheckout, backendClearCart, backendForgotPassword, backendGetCart, backendMergeCart, backendMyOrder, backendMyOrders, backendOrderByToken, backendProduct, backendRefresh, backendRegister, backendRemoveDiscount, backendRemoveItem, backendResetPassword, backendSetShippingMethod, backendSignIn, backendSignOut, backendSignOutEverywhere, backendUpdateItem, backendVerifyEmail, buildBlockContext, buildLocaleSwitchHref, cachedWorkspaceId, clearWorkspaceIdCache, cmssyCspHeaders, cmssySecretsMatch, collectFormIds, createCmssyClient, decodeAccessClaims, defineCmssyConfig, fetchOrderByToken, fetchProduct, fetchProducts, fetchSiteConfig, fields, formatPrice, fractionDigits, fromMinorUnits, getBlockContentForLanguage, graphqlRequest, isAccessExpired, isDevelopment, isProtocolCompatible, isVerifiedEditUrl, localeForPath, localeForPathname, localesFromSiteConfig, localizeHref, localizeHtmlLinks, localizedPath, normalizeOrigin, openSession, parseEditorMessage, postToEditor, resolveEditorOrigin, resolveForms, resolveInitialTarget, resolveSiteLocales, resolveWorkspaceId, sealSession, sessionCookieOptions, splitCmssyLocale, splitLocaleFromPath, toCspOrigin, toMinorUnits, toSessionPayload, verifyCmssyWebhook };
|
|
490
|
+
export { type AppToEditorMessage, type AuthMutationResult, type AuthTokenResult, type BlockSchemaMap, type BoundsMessage, CMSSY_EDIT_HEADER, CMSSY_EDIT_QUERY_PARAM, CMSSY_LOCALE_HEADER, CMSSY_SECRET_QUERY_PARAM, CMSSY_SESSION_COOKIE, type CartRequestContext, type CheckoutInput, type ClickMessage, type CmssyClient, type CmssyConfig, type CmssyCspOptions, type CmssyEnvConfig, CmssyWebhookError, DEFAULT_CMSSY_EDITOR_ORIGINS, type EditorToAppMessage, FORM_QUERY, FetchLike, type GraphqlRequestOptions, MIN_SESSION_SECRET_LENGTH, MODEL_DEFINITIONS_QUERY, MODEL_RECORDS_QUERY, PRODUCTS_QUERY, PROTOCOL_VERSION, type ParentReadyMessage, type PatchMessage, type PostTarget, type QueryScopedOptions, RECORDS_BY_IDS_QUERY, type ReadyMessage, type RelationContentEntry, RetryPolicy, SESSION_MAX_AGE_SECONDS, SITE_CONFIG_QUERY, SUBMIT_FORM_MUTATION, type SelectMessage, applyCmssyCsp, asBucket, assertAuthConfig, backendAddToCart, backendApplyDiscount, backendCheckout, backendClearCart, backendForgotPassword, backendGetCart, backendMergeCart, backendMyOrder, backendMyOrders, backendOrderByToken, backendProduct, backendRefresh, backendRegister, backendRemoveDiscount, backendRemoveItem, backendResetPassword, backendSetShippingMethod, backendSignIn, backendSignOut, backendSignOutEverywhere, backendUpdateItem, backendVerifyEmail, buildBlockContext, buildLocaleSwitchHref, cachedWorkspaceId, clearWorkspaceIdCache, cmssyCspHeaders, cmssySecretsMatch, collectFormIds, createCmssyClient, decodeAccessClaims, defineCmssyConfig, fetchOrderByToken, fetchProduct, fetchProducts, fetchSiteConfig, fields, formatPrice, fractionDigits, fromMinorUnits, getBlockContentForLanguage, graphqlRequest, isAccessExpired, isDevelopment, isProtocolCompatible, isVerifiedEditUrl, localeForPath, localeForPathname, localesFromSiteConfig, localizeHref, localizeHtmlLinks, localizedPath, normalizeOrigin, openSession, parseEditorMessage, postToEditor, resolveEditorOrigin, resolveForms, resolveInitialTarget, resolveRelationContent, resolveSiteLocales, resolveWorkspaceId, sealSession, sessionCookieOptions, splitCmssyLocale, splitLocaleFromPath, toCspOrigin, toMinorUnits, toSessionPayload, verifyCmssyWebhook };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _cmssy_types from '@cmssy/types';
|
|
2
|
-
import { CmssyAuthConfig, CmssyClientConfig, CmssySiteConfig, RawBlock, CmssyFormDefinition, CmssySiteLocales, BuildBlockContextExtra, CmssyBlockContext, CmssyLocaleContext, FieldOptions, TypedField, BlockPropsSchema, InferBlockContent, BlockRect, BlockSchema, BlockMeta, CmssySessionPayload, SessionCookieOptions, CmssySessionUser, CmssyAddress, CmssyCart, CmssyOrder, CmssyProduct, MyOrdersResult, FetchProductOptions, FetchProductsOptions, CmssyProductPage, FetchOrderByTokenOptions, VerifyCmssyWebhookOptions, CmssyWebhookEvent } from '@cmssy/types';
|
|
2
|
+
import { CmssyAuthConfig, CmssyClientConfig, CmssySiteConfig, RawBlock, CmssyFormDefinition, CmssySiteLocales, BuildBlockContextExtra, CmssyBlockContext, CmssyLocaleContext, FieldDefinition, FieldOptions, TypedField, BlockPropsSchema, InferBlockContent, RelationMode, CmssyModelRecord, BlockRect, BlockSchema, BlockMeta, CmssySessionPayload, SessionCookieOptions, CmssySessionUser, CmssyAddress, CmssyCart, CmssyOrder, CmssyProduct, MyOrdersResult, FetchProductOptions, FetchProductsOptions, CmssyProductPage, FetchOrderByTokenOptions, VerifyCmssyWebhookOptions, CmssyWebhookEvent } from '@cmssy/types';
|
|
3
3
|
export { BlockMeta, BlockPropsSchema, BlockRect, BlockSchema, BuildBlockContextExtra, CmssyAddress, CmssyAuthConfig, CmssyBlockAuthContext, CmssyBlockContext, CmssyBlockMember, CmssyBlockWorkspace, CmssyBranding, CmssyCart, CmssyCartDiscount, CmssyCartItem, CmssyCartItemSnapshot, CmssyClientConfig, CmssyFormDefinition, CmssyFormField, CmssyFormSettings, CmssyFormSubmitResponse, CmssyLayoutGroup, CmssyLayoutSettings, CmssyLocaleContext, CmssyLocalizedValue, CmssyModelDefinition, CmssyModelRecord, CmssyOrder, CmssyOrderDiscount, CmssyOrderItem, CmssyOrderTaxSummaryLine, CmssyPageData, CmssyPageMeta, CmssyPageSummary, CmssyPriceTier, CmssyProduct, CmssyProductPage, CmssyProductVariant, CmssyRecordList, CmssySessionPayload, CmssySessionUser, CmssyShippingMethod, CmssySiteConfig, CmssySiteLocales, CmssyStockState, CmssyTaxSummaryLine, CmssyWebhookEvent, CmssyWebhookOrder, FetchOrderByTokenOptions, FetchProductOptions, FetchProductsOptions, FieldCondition, FieldConditionGroup, FieldConditionLogic, FieldControl, FieldDefinition, FieldOptions, FieldType, InferBlockContent, MyOrdersResult, RawBlock, RawLayoutBlock, SessionCookieOptions, SubmitFormInput, TypedField, VerifyCmssyWebhookOptions, evaluateFieldConditionGroup } from '@cmssy/types';
|
|
4
4
|
import { F as FetchLike, R as RetryPolicy } from './content-client-D0EdiqbQ.js';
|
|
5
5
|
export { C as CmssyRequestError, D as DEFAULT_CMSSY_API_URL, a as FetchLikeResponse, b as FetchPageOptions, f as fetchLayouts, c as fetchPage, d as fetchPageById, e as fetchPageMeta, g as fetchPages, n as normalizeSlug, r as resolveApiUrl, h as resolvePublicUrl } from './content-client-D0EdiqbQ.js';
|
|
@@ -158,6 +158,21 @@ declare function buildLocaleSwitchHref(target: string, pathname: string, locale:
|
|
|
158
158
|
*/
|
|
159
159
|
declare function localizeHtmlLinks(html: string, locale: CmssyLocaleContext): string;
|
|
160
160
|
|
|
161
|
+
declare const RECORDS_BY_IDS_QUERY = "query PublicRecordsByIds($workspaceId: String!, $ids: [String!]!, $locale: String) {\n public {\n model {\n recordsByIds(workspaceId: $workspaceId, ids: $ids, locale: $locale) {\n id modelId data status createdAt updatedAt\n }\n }\n }\n}";
|
|
162
|
+
interface RelationContentEntry {
|
|
163
|
+
type: string;
|
|
164
|
+
content: Record<string, unknown>;
|
|
165
|
+
}
|
|
166
|
+
type BlockSchemaMap = Record<string, Record<string, FieldDefinition>>;
|
|
167
|
+
/**
|
|
168
|
+
* Resolves every `fields.relation` value on the given block contents in place:
|
|
169
|
+
* stored record ids become full records (one batched read for the whole page),
|
|
170
|
+
* and a `mode: "all"` field becomes the model's record list. A dangling id and
|
|
171
|
+
* a failed fetch both degrade to "no value" - a relation must never break a
|
|
172
|
+
* render.
|
|
173
|
+
*/
|
|
174
|
+
declare function resolveRelationContent(config: CmssyClientConfig, entries: RelationContentEntry[], schemas: BlockSchemaMap, locale?: string, requestOptions?: QueryScopedOptions): Promise<void>;
|
|
175
|
+
|
|
161
176
|
declare const CMSSY_LOCALE_HEADER = "x-cmssy-locale";
|
|
162
177
|
declare function localeForPathname(config: CmssyClientConfig, pathname: string): Promise<string>;
|
|
163
178
|
declare function splitCmssyLocale(config: CmssyClientConfig, path: string[] | undefined): Promise<{
|
|
@@ -182,6 +197,30 @@ type MediaValue<O> = O extends {
|
|
|
182
197
|
type RepeaterValue<O> = O extends {
|
|
183
198
|
itemSchema: infer Schema extends BlockPropsSchema;
|
|
184
199
|
} ? InferBlockContent<Schema>[] : Record<string, unknown>[];
|
|
200
|
+
/**
|
|
201
|
+
* The value a relation field holds AFTER server-side resolution: the SDK
|
|
202
|
+
* replaces the stored record id(s) with the records themselves before the
|
|
203
|
+
* component renders. `mode: "all"` and `multiple: true` yield a list; the
|
|
204
|
+
* default is a single record - `undefined` when the reference dangles, which
|
|
205
|
+
* no `required` flag can rule out.
|
|
206
|
+
*/
|
|
207
|
+
type RelationValue<O> = O extends {
|
|
208
|
+
mode: "all";
|
|
209
|
+
} | {
|
|
210
|
+
multiple: true;
|
|
211
|
+
} ? CmssyModelRecord[] : CmssyModelRecord | undefined;
|
|
212
|
+
interface RelationFieldOptions extends Omit<FieldOptions, "options" | "itemSchema"> {
|
|
213
|
+
/** Slug of the model the field points at. */
|
|
214
|
+
model: string;
|
|
215
|
+
/**
|
|
216
|
+
* "all" binds the field to every record of the model (no editor picking;
|
|
217
|
+
* `sort`/`limit` shape the list). Omit it for editor-picked record id(s).
|
|
218
|
+
*/
|
|
219
|
+
mode?: RelationMode;
|
|
220
|
+
multiple?: boolean;
|
|
221
|
+
sort?: string;
|
|
222
|
+
limit?: number;
|
|
223
|
+
}
|
|
185
224
|
declare const fields: {
|
|
186
225
|
text: <const O extends FieldOptions>(opts?: O) => TypedField<string, Declared<O>>;
|
|
187
226
|
textarea: <const O extends FieldOptions>(opts?: O) => TypedField<string, Declared<O>>;
|
|
@@ -204,6 +243,7 @@ declare const fields: {
|
|
|
204
243
|
multiselect: <const O extends FieldOptions>(opts: O) => TypedField<OptionValue<O>[], Declared<O>>;
|
|
205
244
|
media: <const O extends FieldOptions>(opts?: O) => TypedField<MediaValue<O>, Declared<O>>;
|
|
206
245
|
repeater: <const O extends FieldOptions>(opts: O) => TypedField<RepeaterValue<O>, Declared<O>>;
|
|
246
|
+
relation: <const O extends RelationFieldOptions>(opts: O) => TypedField<RelationValue<O>, Declared<O>>;
|
|
207
247
|
};
|
|
208
248
|
|
|
209
249
|
declare const PROTOCOL_VERSION = 2;
|
|
@@ -447,4 +487,4 @@ declare class CmssyWebhookError extends Error {
|
|
|
447
487
|
*/
|
|
448
488
|
declare function verifyCmssyWebhook(options: VerifyCmssyWebhookOptions): Promise<CmssyWebhookEvent>;
|
|
449
489
|
|
|
450
|
-
export { type AppToEditorMessage, type AuthMutationResult, type AuthTokenResult, type BoundsMessage, CMSSY_EDIT_HEADER, CMSSY_EDIT_QUERY_PARAM, CMSSY_LOCALE_HEADER, CMSSY_SECRET_QUERY_PARAM, CMSSY_SESSION_COOKIE, type CartRequestContext, type CheckoutInput, type ClickMessage, type CmssyClient, type CmssyConfig, type CmssyCspOptions, type CmssyEnvConfig, CmssyWebhookError, DEFAULT_CMSSY_EDITOR_ORIGINS, type EditorToAppMessage, FORM_QUERY, FetchLike, type GraphqlRequestOptions, MIN_SESSION_SECRET_LENGTH, MODEL_DEFINITIONS_QUERY, MODEL_RECORDS_QUERY, PRODUCTS_QUERY, PROTOCOL_VERSION, type ParentReadyMessage, type PatchMessage, type PostTarget, type QueryScopedOptions, type ReadyMessage, RetryPolicy, SESSION_MAX_AGE_SECONDS, SITE_CONFIG_QUERY, SUBMIT_FORM_MUTATION, type SelectMessage, applyCmssyCsp, asBucket, assertAuthConfig, backendAddToCart, backendApplyDiscount, backendCheckout, backendClearCart, backendForgotPassword, backendGetCart, backendMergeCart, backendMyOrder, backendMyOrders, backendOrderByToken, backendProduct, backendRefresh, backendRegister, backendRemoveDiscount, backendRemoveItem, backendResetPassword, backendSetShippingMethod, backendSignIn, backendSignOut, backendSignOutEverywhere, backendUpdateItem, backendVerifyEmail, buildBlockContext, buildLocaleSwitchHref, cachedWorkspaceId, clearWorkspaceIdCache, cmssyCspHeaders, cmssySecretsMatch, collectFormIds, createCmssyClient, decodeAccessClaims, defineCmssyConfig, fetchOrderByToken, fetchProduct, fetchProducts, fetchSiteConfig, fields, formatPrice, fractionDigits, fromMinorUnits, getBlockContentForLanguage, graphqlRequest, isAccessExpired, isDevelopment, isProtocolCompatible, isVerifiedEditUrl, localeForPath, localeForPathname, localesFromSiteConfig, localizeHref, localizeHtmlLinks, localizedPath, normalizeOrigin, openSession, parseEditorMessage, postToEditor, resolveEditorOrigin, resolveForms, resolveInitialTarget, resolveSiteLocales, resolveWorkspaceId, sealSession, sessionCookieOptions, splitCmssyLocale, splitLocaleFromPath, toCspOrigin, toMinorUnits, toSessionPayload, verifyCmssyWebhook };
|
|
490
|
+
export { type AppToEditorMessage, type AuthMutationResult, type AuthTokenResult, type BlockSchemaMap, type BoundsMessage, CMSSY_EDIT_HEADER, CMSSY_EDIT_QUERY_PARAM, CMSSY_LOCALE_HEADER, CMSSY_SECRET_QUERY_PARAM, CMSSY_SESSION_COOKIE, type CartRequestContext, type CheckoutInput, type ClickMessage, type CmssyClient, type CmssyConfig, type CmssyCspOptions, type CmssyEnvConfig, CmssyWebhookError, DEFAULT_CMSSY_EDITOR_ORIGINS, type EditorToAppMessage, FORM_QUERY, FetchLike, type GraphqlRequestOptions, MIN_SESSION_SECRET_LENGTH, MODEL_DEFINITIONS_QUERY, MODEL_RECORDS_QUERY, PRODUCTS_QUERY, PROTOCOL_VERSION, type ParentReadyMessage, type PatchMessage, type PostTarget, type QueryScopedOptions, RECORDS_BY_IDS_QUERY, type ReadyMessage, type RelationContentEntry, RetryPolicy, SESSION_MAX_AGE_SECONDS, SITE_CONFIG_QUERY, SUBMIT_FORM_MUTATION, type SelectMessage, applyCmssyCsp, asBucket, assertAuthConfig, backendAddToCart, backendApplyDiscount, backendCheckout, backendClearCart, backendForgotPassword, backendGetCart, backendMergeCart, backendMyOrder, backendMyOrders, backendOrderByToken, backendProduct, backendRefresh, backendRegister, backendRemoveDiscount, backendRemoveItem, backendResetPassword, backendSetShippingMethod, backendSignIn, backendSignOut, backendSignOutEverywhere, backendUpdateItem, backendVerifyEmail, buildBlockContext, buildLocaleSwitchHref, cachedWorkspaceId, clearWorkspaceIdCache, cmssyCspHeaders, cmssySecretsMatch, collectFormIds, createCmssyClient, decodeAccessClaims, defineCmssyConfig, fetchOrderByToken, fetchProduct, fetchProducts, fetchSiteConfig, fields, formatPrice, fractionDigits, fromMinorUnits, getBlockContentForLanguage, graphqlRequest, isAccessExpired, isDevelopment, isProtocolCompatible, isVerifiedEditUrl, localeForPath, localeForPathname, localesFromSiteConfig, localizeHref, localizeHtmlLinks, localizedPath, normalizeOrigin, openSession, parseEditorMessage, postToEditor, resolveEditorOrigin, resolveForms, resolveInitialTarget, resolveRelationContent, resolveSiteLocales, resolveWorkspaceId, sealSession, sessionCookieOptions, splitCmssyLocale, splitLocaleFromPath, toCspOrigin, toMinorUnits, toSessionPayload, verifyCmssyWebhook };
|
package/dist/index.js
CHANGED
|
@@ -745,6 +745,139 @@ function localizeHtmlLinks(html, locale) {
|
|
|
745
745
|
);
|
|
746
746
|
}
|
|
747
747
|
|
|
748
|
+
// src/data/relation-resolver.ts
|
|
749
|
+
var RECORDS_BY_IDS_QUERY = `query PublicRecordsByIds($workspaceId: String!, $ids: [String!]!, $locale: String) {
|
|
750
|
+
public {
|
|
751
|
+
model {
|
|
752
|
+
recordsByIds(workspaceId: $workspaceId, ids: $ids, locale: $locale) {
|
|
753
|
+
id modelId data status createdAt updatedAt
|
|
754
|
+
}
|
|
755
|
+
}
|
|
756
|
+
}
|
|
757
|
+
}`;
|
|
758
|
+
var BY_IDS_CHUNK = 50;
|
|
759
|
+
var COLLECTION_DEFAULT_LIMIT = 50;
|
|
760
|
+
function relationModel(field) {
|
|
761
|
+
return field.relationTo?.startsWith("model:") ? field.relationTo.slice("model:".length) : void 0;
|
|
762
|
+
}
|
|
763
|
+
function storedIds(value) {
|
|
764
|
+
if (typeof value === "string" && value) return [value];
|
|
765
|
+
if (Array.isArray(value)) {
|
|
766
|
+
return value.filter((id) => typeof id === "string" && !!id);
|
|
767
|
+
}
|
|
768
|
+
return [];
|
|
769
|
+
}
|
|
770
|
+
function collectRefs(entries, schemas) {
|
|
771
|
+
const refs = [];
|
|
772
|
+
for (const entry of entries) {
|
|
773
|
+
const schema = schemas[entry.type];
|
|
774
|
+
if (!schema) continue;
|
|
775
|
+
for (const [key, field] of Object.entries(schema)) {
|
|
776
|
+
if (field.type !== "relation") continue;
|
|
777
|
+
const model = relationModel(field);
|
|
778
|
+
if (!model) continue;
|
|
779
|
+
refs.push({ content: entry.content, key, field, model });
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
return refs;
|
|
783
|
+
}
|
|
784
|
+
function collectionKey(ref) {
|
|
785
|
+
return [ref.model, ref.field.sort ?? "", ref.field.limit ?? ""].join("\0");
|
|
786
|
+
}
|
|
787
|
+
async function resolveRelationContent(config, entries, schemas, locale, requestOptions = {}) {
|
|
788
|
+
const refs = collectRefs(entries, schemas);
|
|
789
|
+
if (refs.length === 0) return;
|
|
790
|
+
const client = createCmssyClient(config);
|
|
791
|
+
const pickedIds = /* @__PURE__ */ new Set();
|
|
792
|
+
const collections = /* @__PURE__ */ new Map();
|
|
793
|
+
for (const ref of refs) {
|
|
794
|
+
if (ref.field.relationMode === "all") {
|
|
795
|
+
collections.set(collectionKey(ref), {
|
|
796
|
+
model: ref.model,
|
|
797
|
+
sort: ref.field.sort,
|
|
798
|
+
limit: ref.field.limit
|
|
799
|
+
});
|
|
800
|
+
} else {
|
|
801
|
+
for (const id of storedIds(ref.content[ref.key])) pickedIds.add(id);
|
|
802
|
+
}
|
|
803
|
+
}
|
|
804
|
+
let recordsById;
|
|
805
|
+
let collectionItems;
|
|
806
|
+
try {
|
|
807
|
+
[recordsById, collectionItems] = await Promise.all([
|
|
808
|
+
fetchPickedRecords(client, [...pickedIds], locale, requestOptions),
|
|
809
|
+
fetchCollections(client, collections, locale, requestOptions)
|
|
810
|
+
]);
|
|
811
|
+
} catch (err) {
|
|
812
|
+
if (typeof console !== "undefined") {
|
|
813
|
+
console.error("[cmssy] relation resolution failed", err);
|
|
814
|
+
}
|
|
815
|
+
for (const ref of refs) {
|
|
816
|
+
if (ref.field.relationMode === "all" || Array.isArray(ref.content[ref.key])) {
|
|
817
|
+
ref.content[ref.key] = [];
|
|
818
|
+
} else {
|
|
819
|
+
delete ref.content[ref.key];
|
|
820
|
+
}
|
|
821
|
+
}
|
|
822
|
+
return;
|
|
823
|
+
}
|
|
824
|
+
for (const ref of refs) {
|
|
825
|
+
if (ref.field.relationMode === "all") {
|
|
826
|
+
ref.content[ref.key] = collectionItems.get(collectionKey(ref)) ?? [];
|
|
827
|
+
continue;
|
|
828
|
+
}
|
|
829
|
+
const value = ref.content[ref.key];
|
|
830
|
+
if (Array.isArray(value)) {
|
|
831
|
+
ref.content[ref.key] = storedIds(value).map((id) => recordsById.get(id)).filter((record) => !!record);
|
|
832
|
+
} else if (typeof value === "string" && value) {
|
|
833
|
+
const record = recordsById.get(value);
|
|
834
|
+
if (record) ref.content[ref.key] = record;
|
|
835
|
+
else delete ref.content[ref.key];
|
|
836
|
+
} else {
|
|
837
|
+
delete ref.content[ref.key];
|
|
838
|
+
}
|
|
839
|
+
}
|
|
840
|
+
}
|
|
841
|
+
async function fetchPickedRecords(client, ids, locale, requestOptions = {}) {
|
|
842
|
+
const byId = /* @__PURE__ */ new Map();
|
|
843
|
+
const chunks = [];
|
|
844
|
+
for (let i = 0; i < ids.length; i += BY_IDS_CHUNK) {
|
|
845
|
+
chunks.push(ids.slice(i, i + BY_IDS_CHUNK));
|
|
846
|
+
}
|
|
847
|
+
await Promise.all(
|
|
848
|
+
chunks.map(async (chunk) => {
|
|
849
|
+
const result = await client.queryScoped(
|
|
850
|
+
RECORDS_BY_IDS_QUERY,
|
|
851
|
+
{ ids: chunk, locale: locale ?? null },
|
|
852
|
+
requestOptions
|
|
853
|
+
);
|
|
854
|
+
for (const record of result.public.model.recordsByIds) {
|
|
855
|
+
byId.set(record.id, record);
|
|
856
|
+
}
|
|
857
|
+
})
|
|
858
|
+
);
|
|
859
|
+
return byId;
|
|
860
|
+
}
|
|
861
|
+
async function fetchCollections(client, collections, locale, requestOptions = {}) {
|
|
862
|
+
const byKey = /* @__PURE__ */ new Map();
|
|
863
|
+
await Promise.all(
|
|
864
|
+
[...collections.entries()].map(async ([key, { model, sort, limit }]) => {
|
|
865
|
+
const result = await client.queryScoped(
|
|
866
|
+
MODEL_RECORDS_QUERY,
|
|
867
|
+
{
|
|
868
|
+
modelSlug: model,
|
|
869
|
+
sort: sort ?? null,
|
|
870
|
+
limit: limit ?? COLLECTION_DEFAULT_LIMIT,
|
|
871
|
+
locale: locale ?? null
|
|
872
|
+
},
|
|
873
|
+
requestOptions
|
|
874
|
+
);
|
|
875
|
+
byKey.set(key, result.public.model.records.items);
|
|
876
|
+
})
|
|
877
|
+
);
|
|
878
|
+
return byKey;
|
|
879
|
+
}
|
|
880
|
+
|
|
748
881
|
// src/locale.ts
|
|
749
882
|
var CMSSY_LOCALE_HEADER = "x-cmssy-locale";
|
|
750
883
|
async function localeForPathname(config, pathname) {
|
|
@@ -808,7 +941,16 @@ var fields = {
|
|
|
808
941
|
radio: choice("radio"),
|
|
809
942
|
multiselect: (opts) => build("multiselect", opts),
|
|
810
943
|
media: (opts = {}) => build("media", opts),
|
|
811
|
-
repeater: (opts) => build("repeater", opts)
|
|
944
|
+
repeater: (opts) => build("repeater", opts),
|
|
945
|
+
relation: (opts) => {
|
|
946
|
+
const { model, mode, ...rest } = opts;
|
|
947
|
+
return build("relation", {
|
|
948
|
+
...rest,
|
|
949
|
+
relationTo: `model:${model}`,
|
|
950
|
+
relationType: mode === "all" || opts.multiple ? "hasMany" : "hasOne",
|
|
951
|
+
relationMode: mode ?? "picked"
|
|
952
|
+
});
|
|
953
|
+
}
|
|
812
954
|
};
|
|
813
955
|
|
|
814
956
|
// src/bridge/protocol.ts
|
|
@@ -1726,4 +1868,4 @@ async function verifyCmssyWebhook(options) {
|
|
|
1726
1868
|
return parsed;
|
|
1727
1869
|
}
|
|
1728
1870
|
|
|
1729
|
-
export { CMSSY_EDIT_HEADER, CMSSY_EDIT_QUERY_PARAM, CMSSY_LOCALE_HEADER, CMSSY_SECRET_QUERY_PARAM, CMSSY_SESSION_COOKIE, CmssyRequestError, CmssyWebhookError, DEFAULT_CMSSY_API_URL, DEFAULT_CMSSY_EDITOR_ORIGINS, FORM_QUERY, MIN_SESSION_SECRET_LENGTH, MODEL_DEFINITIONS_QUERY, MODEL_RECORDS_QUERY, PRODUCTS_QUERY, PROTOCOL_VERSION, SESSION_MAX_AGE_SECONDS, SITE_CONFIG_QUERY, SUBMIT_FORM_MUTATION, applyCmssyCsp, asBucket, assertAuthConfig, backendAddToCart, backendApplyDiscount, backendCheckout, backendClearCart, backendForgotPassword, backendGetCart, backendMergeCart, backendMyOrder, backendMyOrders, backendOrderByToken, backendProduct, backendRefresh, backendRegister, backendRemoveDiscount, backendRemoveItem, backendResetPassword, backendSetShippingMethod, backendSignIn, backendSignOut, backendSignOutEverywhere, backendUpdateItem, backendVerifyEmail, buildBlockContext, buildLocaleSwitchHref, cachedWorkspaceId, clearWorkspaceIdCache, cmssyCspHeaders, cmssySecretsMatch, collectFormIds, createCmssyClient, decodeAccessClaims, defineCmssyConfig, fetchLayouts, fetchOrderByToken, fetchPage, fetchPageById, fetchPageMeta, fetchPages, fetchProduct, fetchProducts, fetchSiteConfig, fields, formatPrice, fractionDigits, fromMinorUnits, getBlockContentForLanguage, graphqlRequest, isAccessExpired, isDevelopment, isProtocolCompatible, isVerifiedEditUrl, localeForPath, localeForPathname, localesFromSiteConfig, localizeHref, localizeHtmlLinks, localizedPath, normalizeOrigin, normalizeSlug, openSession, parseEditorMessage, postToEditor, resolveApiUrl, resolveEditorOrigin, resolveForms, resolveInitialTarget, resolvePublicUrl, resolveSiteLocales, resolveWorkspaceId, sealSession, sessionCookieOptions, splitCmssyLocale, splitLocaleFromPath, toCspOrigin, toMinorUnits, toSessionPayload, verifyCmssyWebhook };
|
|
1871
|
+
export { CMSSY_EDIT_HEADER, CMSSY_EDIT_QUERY_PARAM, CMSSY_LOCALE_HEADER, CMSSY_SECRET_QUERY_PARAM, CMSSY_SESSION_COOKIE, CmssyRequestError, CmssyWebhookError, DEFAULT_CMSSY_API_URL, DEFAULT_CMSSY_EDITOR_ORIGINS, FORM_QUERY, MIN_SESSION_SECRET_LENGTH, MODEL_DEFINITIONS_QUERY, MODEL_RECORDS_QUERY, PRODUCTS_QUERY, PROTOCOL_VERSION, RECORDS_BY_IDS_QUERY, SESSION_MAX_AGE_SECONDS, SITE_CONFIG_QUERY, SUBMIT_FORM_MUTATION, applyCmssyCsp, asBucket, assertAuthConfig, backendAddToCart, backendApplyDiscount, backendCheckout, backendClearCart, backendForgotPassword, backendGetCart, backendMergeCart, backendMyOrder, backendMyOrders, backendOrderByToken, backendProduct, backendRefresh, backendRegister, backendRemoveDiscount, backendRemoveItem, backendResetPassword, backendSetShippingMethod, backendSignIn, backendSignOut, backendSignOutEverywhere, backendUpdateItem, backendVerifyEmail, buildBlockContext, buildLocaleSwitchHref, cachedWorkspaceId, clearWorkspaceIdCache, cmssyCspHeaders, cmssySecretsMatch, collectFormIds, createCmssyClient, decodeAccessClaims, defineCmssyConfig, fetchLayouts, fetchOrderByToken, fetchPage, fetchPageById, fetchPageMeta, fetchPages, fetchProduct, fetchProducts, fetchSiteConfig, fields, formatPrice, fractionDigits, fromMinorUnits, getBlockContentForLanguage, graphqlRequest, isAccessExpired, isDevelopment, isProtocolCompatible, isVerifiedEditUrl, localeForPath, localeForPathname, localesFromSiteConfig, localizeHref, localizeHtmlLinks, localizedPath, normalizeOrigin, normalizeSlug, openSession, parseEditorMessage, postToEditor, resolveApiUrl, resolveEditorOrigin, resolveForms, resolveInitialTarget, resolvePublicUrl, resolveRelationContent, resolveSiteLocales, resolveWorkspaceId, sealSession, sessionCookieOptions, splitCmssyLocale, splitLocaleFromPath, toCspOrigin, toMinorUnits, toSessionPayload, verifyCmssyWebhook };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cmssy/core",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.6.0",
|
|
4
4
|
"description": "Framework-agnostic cmssy client: content, commerce, config, editor protocol. No React, no Next.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cmssy",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"vitest": "^2.1.0"
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"@cmssy/types": "0.
|
|
55
|
+
"@cmssy/types": "0.29.0",
|
|
56
56
|
"jose": "^6.2.3"
|
|
57
57
|
},
|
|
58
58
|
"scripts": {
|