@distinctagency/cms-client 1.24.0 → 1.26.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.d.mts +74 -3
- package/dist/index.d.ts +74 -3
- package/dist/index.js +27 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +23 -1
- package/dist/index.mjs.map +1 -1
- package/dist/visual-editing.d.mts +14 -0
- package/dist/visual-editing.d.ts +14 -0
- package/dist/visual-editing.js +251 -0
- package/dist/visual-editing.js.map +1 -0
- package/dist/visual-editing.mjs +227 -0
- package/dist/visual-editing.mjs.map +1 -0
- package/package.json +6 -1
package/dist/index.d.mts
CHANGED
|
@@ -7,10 +7,10 @@ import { SupabaseClient } from '@supabase/supabase-js';
|
|
|
7
7
|
* report installed-version telemetry and to send `x-cms-client-version` on
|
|
8
8
|
* outgoing requests.
|
|
9
9
|
*/
|
|
10
|
-
declare const CMS_CLIENT_VERSION = "1.
|
|
10
|
+
declare const CMS_CLIENT_VERSION = "1.26.0";
|
|
11
11
|
|
|
12
12
|
/** Field types supported by the CMS schema */
|
|
13
|
-
type FieldType = "text" | "textarea" | "richtext" | "date" | "datetime" | "select" | "number" | "boolean" | "image" | "gallery" | "url" | "file" | "reference" | "multi-reference" | "computed" | "color" | "tags" | "json" | "embed" | "flipbook";
|
|
13
|
+
type FieldType = "text" | "textarea" | "richtext" | "date" | "datetime" | "select" | "number" | "boolean" | "image" | "gallery" | "url" | "file" | "reference" | "multi-reference" | "computed" | "color" | "tags" | "json" | "embed" | "flipbook" | "group";
|
|
14
14
|
/**
|
|
15
15
|
* Date field precision. Controls which parts of a date the admin editor collects
|
|
16
16
|
* and the partial-ISO shape the value is stored in:
|
|
@@ -62,6 +62,10 @@ interface FieldDefinition {
|
|
|
62
62
|
max_length?: number;
|
|
63
63
|
/** For text/textarea/richtext fields: soft target character count. Exceeding it shows a warning but does not block saving. */
|
|
64
64
|
recommended_length?: number;
|
|
65
|
+
/** For group (repeater) fields: the item sub-schema (scalar fields only — no nested group/reference). */
|
|
66
|
+
fields?: FieldDefinition[];
|
|
67
|
+
/** For group fields: singular noun for the add button (e.g. "card"). Defaults to "item". */
|
|
68
|
+
item_label?: string;
|
|
65
69
|
}
|
|
66
70
|
interface Tenant {
|
|
67
71
|
id: string;
|
|
@@ -117,6 +121,8 @@ interface ContentType {
|
|
|
117
121
|
required_membership_tier_id?: string | null;
|
|
118
122
|
/** When true, this content type is a "page": it holds exactly one item, edited as a singleton document rather than a collection. */
|
|
119
123
|
is_singleton?: boolean;
|
|
124
|
+
/** For singleton pages: the site path the visual editor previews (e.g. "/", "/about"). Defaults to "/". */
|
|
125
|
+
preview_path?: string;
|
|
120
126
|
created_at: string;
|
|
121
127
|
}
|
|
122
128
|
interface ContentItem {
|
|
@@ -933,4 +939,69 @@ declare function revalidateAllTags(payload: Pick<WebhookEventPayload, "cache_tag
|
|
|
933
939
|
expire?: number;
|
|
934
940
|
}) => unknown): string[];
|
|
935
941
|
|
|
936
|
-
|
|
942
|
+
/** Discriminator stamped on every visual-editing postMessage. */
|
|
943
|
+
declare const CMS_VISUAL_SOURCE: "cms-visual";
|
|
944
|
+
/** CMS origins the bridge will trust by default. */
|
|
945
|
+
declare const DEFAULT_TRUSTED_ORIGINS: readonly string[];
|
|
946
|
+
type VisualFieldType = "text" | "image";
|
|
947
|
+
/** Compact wire type announced in `ready`; the schema adds length constraints. */
|
|
948
|
+
interface VisualFieldMeta {
|
|
949
|
+
name: string;
|
|
950
|
+
type: VisualFieldType;
|
|
951
|
+
}
|
|
952
|
+
interface VisualFieldSchema {
|
|
953
|
+
name: string;
|
|
954
|
+
type: VisualFieldType;
|
|
955
|
+
max_length?: number;
|
|
956
|
+
recommended_length?: number;
|
|
957
|
+
}
|
|
958
|
+
interface ReadyMessage {
|
|
959
|
+
source: typeof CMS_VISUAL_SOURCE;
|
|
960
|
+
type: "ready";
|
|
961
|
+
fields: VisualFieldMeta[];
|
|
962
|
+
}
|
|
963
|
+
interface EditMessage {
|
|
964
|
+
source: typeof CMS_VISUAL_SOURCE;
|
|
965
|
+
type: "edit";
|
|
966
|
+
name: string;
|
|
967
|
+
value: string;
|
|
968
|
+
length: number;
|
|
969
|
+
/** When the field is inside a repeating group item, the group field name. */
|
|
970
|
+
list?: string;
|
|
971
|
+
/** Item index within the group (document order). */
|
|
972
|
+
index?: number;
|
|
973
|
+
}
|
|
974
|
+
interface PickImageMessage {
|
|
975
|
+
source: typeof CMS_VISUAL_SOURCE;
|
|
976
|
+
type: "pick-image";
|
|
977
|
+
name: string;
|
|
978
|
+
/** When the field is inside a repeating group item, the group field name. */
|
|
979
|
+
list?: string;
|
|
980
|
+
/** Item index within the group (document order). */
|
|
981
|
+
index?: number;
|
|
982
|
+
}
|
|
983
|
+
interface InitMessage {
|
|
984
|
+
source: typeof CMS_VISUAL_SOURCE;
|
|
985
|
+
type: "init";
|
|
986
|
+
values: Record<string, string>;
|
|
987
|
+
schema: Record<string, VisualFieldSchema>;
|
|
988
|
+
}
|
|
989
|
+
interface SetMessage {
|
|
990
|
+
source: typeof CMS_VISUAL_SOURCE;
|
|
991
|
+
type: "set";
|
|
992
|
+
name: string;
|
|
993
|
+
value: string;
|
|
994
|
+
/** When the field is inside a repeating group item, the group field name. */
|
|
995
|
+
list?: string;
|
|
996
|
+
/** Item index within the group (document order). */
|
|
997
|
+
index?: number;
|
|
998
|
+
}
|
|
999
|
+
type BridgeOutbound = ReadyMessage | EditMessage | PickImageMessage;
|
|
1000
|
+
type BridgeInbound = InitMessage | SetMessage;
|
|
1001
|
+
type VisualMessage = BridgeOutbound | BridgeInbound;
|
|
1002
|
+
/** Exact-match origin allowlist, plus any localhost port for local dev. */
|
|
1003
|
+
declare function isTrustedOrigin(origin: string, allowlist: readonly string[]): boolean;
|
|
1004
|
+
/** Narrow an unknown postMessage payload to a visual message, or null. */
|
|
1005
|
+
declare function parseVisualMessage(data: unknown): VisualMessage | null;
|
|
1006
|
+
|
|
1007
|
+
export { type BookingStatus, type BridgeInbound, type BridgeOutbound, CMS_CLIENT_VERSION, CMS_VISUAL_SOURCE, type CmsClientOptions, type CmsEvent, type CmsTicketTier, type ContentItem, type ContentQueryOptions, type ContentType, type ContentTypeSeoConfig, type CreateBookingParams, type CreateBookingResult, type CreateOrderParams, type CreateOrderResult, DEFAULT_TRUSTED_ORIGINS, type DateGranularity, type DiscountType, type EditMessage, type EmbedValue, type EventQueryOptions, type EventStatus, type EventWithTiers, type FieldDefinition, type FieldType, type FlipbookPagePublic, type FlipbookPublic, type FlipbookTocEntryPublic, type FormatPartialDateOptions, type GeocodeOptions, type GeocodeResult, type GoogleReview, IMAGE_PRESETS, type ImageConfig, type ImageTransformOptions, type InitMessage, MAPBOX_CONFIG_TAG, type MapboxConfig, type MapboxConfigOptions, type MapsClientOptions, type MediaFolder, type MediaItem, type Member, type MembershipTier, type OrderAddress, type OrderLineItem, type OrderStatus, type ParsedPartialDate, type PaymentStatus, type PickImageMessage, type Product, type ProductCategory, type ProductOption, type ProductQueryOptions, type ProductStatus, type ProductVariant, type Profile, type ReadyMessage, type ReviewQueryOptions, type SetMessage, TRACKING_CONFIG_TAG, type Tenant, type TenantMembership, type TrackingConfig, type TrackingConfigOptions, type VisualFieldMeta, type VisualFieldSchema, type VisualFieldType, type VisualMessage, WEBHOOK_EVENTS, type WebhookEvent, type WebhookEventPayload, createCmsClient, createEventsClient, createMapsClient, createShopClient, formatPartialDate, getEmbedHtml, getSrcSet, getTransformUrl, isTrustedOrigin, parsePartialDate, parseVisualMessage, revalidateAllTags, singletonTag, verifyWebhookSignature };
|
package/dist/index.d.ts
CHANGED
|
@@ -7,10 +7,10 @@ import { SupabaseClient } from '@supabase/supabase-js';
|
|
|
7
7
|
* report installed-version telemetry and to send `x-cms-client-version` on
|
|
8
8
|
* outgoing requests.
|
|
9
9
|
*/
|
|
10
|
-
declare const CMS_CLIENT_VERSION = "1.
|
|
10
|
+
declare const CMS_CLIENT_VERSION = "1.26.0";
|
|
11
11
|
|
|
12
12
|
/** Field types supported by the CMS schema */
|
|
13
|
-
type FieldType = "text" | "textarea" | "richtext" | "date" | "datetime" | "select" | "number" | "boolean" | "image" | "gallery" | "url" | "file" | "reference" | "multi-reference" | "computed" | "color" | "tags" | "json" | "embed" | "flipbook";
|
|
13
|
+
type FieldType = "text" | "textarea" | "richtext" | "date" | "datetime" | "select" | "number" | "boolean" | "image" | "gallery" | "url" | "file" | "reference" | "multi-reference" | "computed" | "color" | "tags" | "json" | "embed" | "flipbook" | "group";
|
|
14
14
|
/**
|
|
15
15
|
* Date field precision. Controls which parts of a date the admin editor collects
|
|
16
16
|
* and the partial-ISO shape the value is stored in:
|
|
@@ -62,6 +62,10 @@ interface FieldDefinition {
|
|
|
62
62
|
max_length?: number;
|
|
63
63
|
/** For text/textarea/richtext fields: soft target character count. Exceeding it shows a warning but does not block saving. */
|
|
64
64
|
recommended_length?: number;
|
|
65
|
+
/** For group (repeater) fields: the item sub-schema (scalar fields only — no nested group/reference). */
|
|
66
|
+
fields?: FieldDefinition[];
|
|
67
|
+
/** For group fields: singular noun for the add button (e.g. "card"). Defaults to "item". */
|
|
68
|
+
item_label?: string;
|
|
65
69
|
}
|
|
66
70
|
interface Tenant {
|
|
67
71
|
id: string;
|
|
@@ -117,6 +121,8 @@ interface ContentType {
|
|
|
117
121
|
required_membership_tier_id?: string | null;
|
|
118
122
|
/** When true, this content type is a "page": it holds exactly one item, edited as a singleton document rather than a collection. */
|
|
119
123
|
is_singleton?: boolean;
|
|
124
|
+
/** For singleton pages: the site path the visual editor previews (e.g. "/", "/about"). Defaults to "/". */
|
|
125
|
+
preview_path?: string;
|
|
120
126
|
created_at: string;
|
|
121
127
|
}
|
|
122
128
|
interface ContentItem {
|
|
@@ -933,4 +939,69 @@ declare function revalidateAllTags(payload: Pick<WebhookEventPayload, "cache_tag
|
|
|
933
939
|
expire?: number;
|
|
934
940
|
}) => unknown): string[];
|
|
935
941
|
|
|
936
|
-
|
|
942
|
+
/** Discriminator stamped on every visual-editing postMessage. */
|
|
943
|
+
declare const CMS_VISUAL_SOURCE: "cms-visual";
|
|
944
|
+
/** CMS origins the bridge will trust by default. */
|
|
945
|
+
declare const DEFAULT_TRUSTED_ORIGINS: readonly string[];
|
|
946
|
+
type VisualFieldType = "text" | "image";
|
|
947
|
+
/** Compact wire type announced in `ready`; the schema adds length constraints. */
|
|
948
|
+
interface VisualFieldMeta {
|
|
949
|
+
name: string;
|
|
950
|
+
type: VisualFieldType;
|
|
951
|
+
}
|
|
952
|
+
interface VisualFieldSchema {
|
|
953
|
+
name: string;
|
|
954
|
+
type: VisualFieldType;
|
|
955
|
+
max_length?: number;
|
|
956
|
+
recommended_length?: number;
|
|
957
|
+
}
|
|
958
|
+
interface ReadyMessage {
|
|
959
|
+
source: typeof CMS_VISUAL_SOURCE;
|
|
960
|
+
type: "ready";
|
|
961
|
+
fields: VisualFieldMeta[];
|
|
962
|
+
}
|
|
963
|
+
interface EditMessage {
|
|
964
|
+
source: typeof CMS_VISUAL_SOURCE;
|
|
965
|
+
type: "edit";
|
|
966
|
+
name: string;
|
|
967
|
+
value: string;
|
|
968
|
+
length: number;
|
|
969
|
+
/** When the field is inside a repeating group item, the group field name. */
|
|
970
|
+
list?: string;
|
|
971
|
+
/** Item index within the group (document order). */
|
|
972
|
+
index?: number;
|
|
973
|
+
}
|
|
974
|
+
interface PickImageMessage {
|
|
975
|
+
source: typeof CMS_VISUAL_SOURCE;
|
|
976
|
+
type: "pick-image";
|
|
977
|
+
name: string;
|
|
978
|
+
/** When the field is inside a repeating group item, the group field name. */
|
|
979
|
+
list?: string;
|
|
980
|
+
/** Item index within the group (document order). */
|
|
981
|
+
index?: number;
|
|
982
|
+
}
|
|
983
|
+
interface InitMessage {
|
|
984
|
+
source: typeof CMS_VISUAL_SOURCE;
|
|
985
|
+
type: "init";
|
|
986
|
+
values: Record<string, string>;
|
|
987
|
+
schema: Record<string, VisualFieldSchema>;
|
|
988
|
+
}
|
|
989
|
+
interface SetMessage {
|
|
990
|
+
source: typeof CMS_VISUAL_SOURCE;
|
|
991
|
+
type: "set";
|
|
992
|
+
name: string;
|
|
993
|
+
value: string;
|
|
994
|
+
/** When the field is inside a repeating group item, the group field name. */
|
|
995
|
+
list?: string;
|
|
996
|
+
/** Item index within the group (document order). */
|
|
997
|
+
index?: number;
|
|
998
|
+
}
|
|
999
|
+
type BridgeOutbound = ReadyMessage | EditMessage | PickImageMessage;
|
|
1000
|
+
type BridgeInbound = InitMessage | SetMessage;
|
|
1001
|
+
type VisualMessage = BridgeOutbound | BridgeInbound;
|
|
1002
|
+
/** Exact-match origin allowlist, plus any localhost port for local dev. */
|
|
1003
|
+
declare function isTrustedOrigin(origin: string, allowlist: readonly string[]): boolean;
|
|
1004
|
+
/** Narrow an unknown postMessage payload to a visual message, or null. */
|
|
1005
|
+
declare function parseVisualMessage(data: unknown): VisualMessage | null;
|
|
1006
|
+
|
|
1007
|
+
export { type BookingStatus, type BridgeInbound, type BridgeOutbound, CMS_CLIENT_VERSION, CMS_VISUAL_SOURCE, type CmsClientOptions, type CmsEvent, type CmsTicketTier, type ContentItem, type ContentQueryOptions, type ContentType, type ContentTypeSeoConfig, type CreateBookingParams, type CreateBookingResult, type CreateOrderParams, type CreateOrderResult, DEFAULT_TRUSTED_ORIGINS, type DateGranularity, type DiscountType, type EditMessage, type EmbedValue, type EventQueryOptions, type EventStatus, type EventWithTiers, type FieldDefinition, type FieldType, type FlipbookPagePublic, type FlipbookPublic, type FlipbookTocEntryPublic, type FormatPartialDateOptions, type GeocodeOptions, type GeocodeResult, type GoogleReview, IMAGE_PRESETS, type ImageConfig, type ImageTransformOptions, type InitMessage, MAPBOX_CONFIG_TAG, type MapboxConfig, type MapboxConfigOptions, type MapsClientOptions, type MediaFolder, type MediaItem, type Member, type MembershipTier, type OrderAddress, type OrderLineItem, type OrderStatus, type ParsedPartialDate, type PaymentStatus, type PickImageMessage, type Product, type ProductCategory, type ProductOption, type ProductQueryOptions, type ProductStatus, type ProductVariant, type Profile, type ReadyMessage, type ReviewQueryOptions, type SetMessage, TRACKING_CONFIG_TAG, type Tenant, type TenantMembership, type TrackingConfig, type TrackingConfigOptions, type VisualFieldMeta, type VisualFieldSchema, type VisualFieldType, type VisualMessage, WEBHOOK_EVENTS, type WebhookEvent, type WebhookEventPayload, createCmsClient, createEventsClient, createMapsClient, createShopClient, formatPartialDate, getEmbedHtml, getSrcSet, getTransformUrl, isTrustedOrigin, parsePartialDate, parseVisualMessage, revalidateAllTags, singletonTag, verifyWebhookSignature };
|
package/dist/index.js
CHANGED
|
@@ -21,6 +21,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
21
21
|
var src_exports = {};
|
|
22
22
|
__export(src_exports, {
|
|
23
23
|
CMS_CLIENT_VERSION: () => CMS_CLIENT_VERSION,
|
|
24
|
+
CMS_VISUAL_SOURCE: () => CMS_VISUAL_SOURCE,
|
|
25
|
+
DEFAULT_TRUSTED_ORIGINS: () => DEFAULT_TRUSTED_ORIGINS,
|
|
24
26
|
IMAGE_PRESETS: () => IMAGE_PRESETS,
|
|
25
27
|
MAPBOX_CONFIG_TAG: () => MAPBOX_CONFIG_TAG,
|
|
26
28
|
TRACKING_CONFIG_TAG: () => TRACKING_CONFIG_TAG,
|
|
@@ -33,7 +35,9 @@ __export(src_exports, {
|
|
|
33
35
|
getEmbedHtml: () => getEmbedHtml,
|
|
34
36
|
getSrcSet: () => getSrcSet,
|
|
35
37
|
getTransformUrl: () => getTransformUrl,
|
|
38
|
+
isTrustedOrigin: () => isTrustedOrigin,
|
|
36
39
|
parsePartialDate: () => parsePartialDate,
|
|
40
|
+
parseVisualMessage: () => parseVisualMessage,
|
|
37
41
|
revalidateAllTags: () => revalidateAllTags,
|
|
38
42
|
singletonTag: () => singletonTag,
|
|
39
43
|
verifyWebhookSignature: () => verifyWebhookSignature
|
|
@@ -41,7 +45,7 @@ __export(src_exports, {
|
|
|
41
45
|
module.exports = __toCommonJS(src_exports);
|
|
42
46
|
|
|
43
47
|
// src/version.ts
|
|
44
|
-
var CMS_CLIENT_VERSION = "1.
|
|
48
|
+
var CMS_CLIENT_VERSION = "1.26.0";
|
|
45
49
|
|
|
46
50
|
// src/queries.ts
|
|
47
51
|
var import_supabase_js = require("@supabase/supabase-js");
|
|
@@ -797,9 +801,29 @@ function timingSafeEqualHex(a, b) {
|
|
|
797
801
|
}
|
|
798
802
|
return mismatch === 0;
|
|
799
803
|
}
|
|
804
|
+
|
|
805
|
+
// src/visual-editing/protocol.ts
|
|
806
|
+
var CMS_VISUAL_SOURCE = "cms-visual";
|
|
807
|
+
var DEFAULT_TRUSTED_ORIGINS = [
|
|
808
|
+
"https://cms.distinctstudio.co.nz",
|
|
809
|
+
"https://distinctcms.com"
|
|
810
|
+
];
|
|
811
|
+
function isTrustedOrigin(origin, allowlist) {
|
|
812
|
+
if (allowlist.includes(origin)) return true;
|
|
813
|
+
return /^https?:\/\/localhost(:\d+)?$/.test(origin);
|
|
814
|
+
}
|
|
815
|
+
var VALID_VISUAL_TYPES = /* @__PURE__ */ new Set(["ready", "edit", "pick-image", "init", "set"]);
|
|
816
|
+
function parseVisualMessage(data) {
|
|
817
|
+
if (typeof data === "object" && data !== null && data.source === CMS_VISUAL_SOURCE && typeof data.type === "string" && VALID_VISUAL_TYPES.has(data.type)) {
|
|
818
|
+
return data;
|
|
819
|
+
}
|
|
820
|
+
return null;
|
|
821
|
+
}
|
|
800
822
|
// Annotate the CommonJS export names for ESM import in node:
|
|
801
823
|
0 && (module.exports = {
|
|
802
824
|
CMS_CLIENT_VERSION,
|
|
825
|
+
CMS_VISUAL_SOURCE,
|
|
826
|
+
DEFAULT_TRUSTED_ORIGINS,
|
|
803
827
|
IMAGE_PRESETS,
|
|
804
828
|
MAPBOX_CONFIG_TAG,
|
|
805
829
|
TRACKING_CONFIG_TAG,
|
|
@@ -812,7 +836,9 @@ function timingSafeEqualHex(a, b) {
|
|
|
812
836
|
getEmbedHtml,
|
|
813
837
|
getSrcSet,
|
|
814
838
|
getTransformUrl,
|
|
839
|
+
isTrustedOrigin,
|
|
815
840
|
parsePartialDate,
|
|
841
|
+
parseVisualMessage,
|
|
816
842
|
revalidateAllTags,
|
|
817
843
|
singletonTag,
|
|
818
844
|
verifyWebhookSignature
|