@obelism/content 0.17.0 → 0.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +45 -7
- package/dist/bridge.d.mts +16 -3
- package/dist/bridge.d.mts.map +1 -1
- package/dist/bridge.d.ts +16 -3
- package/dist/bridge.d.ts.map +1 -1
- package/dist/bridge.global.js +3 -3
- package/dist/bridge.js +90 -14
- package/dist/bridge.mjs +90 -14
- package/dist/index.d.mts +15 -4
- package/dist/index.d.mts.map +1 -1
- package/dist/index.d.ts +15 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -3
- package/dist/index.mjs +3 -3
- package/dist/{preview-mpwfmnla.js → preview-ijk3ixwb.js} +17 -0
- package/dist/{preview-h7rwp06v.mjs → preview-jcmxxj92.mjs} +15 -1
- package/dist/site.js +5 -0
- package/dist/site.mjs +5 -0
- package/dist/{types-e5nvgudo.d.ts → types-mtjco3a5.d.ts} +10 -2
- package/dist/types-mtjco3a5.d.ts.map +1 -0
- package/package.json +1 -1
- package/dist/types-e5nvgudo.d.ts.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2
2
|
|
|
3
3
|
var config = require('./config-ci2hxmas.js');
|
|
4
|
-
var preview = require('./preview-
|
|
4
|
+
var preview = require('./preview-ijk3ixwb.js');
|
|
5
5
|
|
|
6
6
|
// A response from the API that wasn't a success. `message` is the API's own
|
|
7
7
|
// `error` text when it sent one.
|
|
@@ -266,10 +266,10 @@ const pickImproveVariant = (block, option, fallback)=>{
|
|
|
266
266
|
return Object.values(variants)[0] ?? [];
|
|
267
267
|
};
|
|
268
268
|
|
|
269
|
-
const linkHref = (link, { url = (path)=>`/${path}` } = {})=>{
|
|
269
|
+
const linkHref = (link, { url = (path)=>`/${path}`, product = ({ handle })=>`/products/${handle}` } = {})=>{
|
|
270
270
|
if (!link) return null;
|
|
271
271
|
if (link.type === 'entry' && link.entry.path === null) return null;
|
|
272
|
-
const base = link.type === 'url' ? link.url : url(link.entry.path);
|
|
272
|
+
const base = link.type === 'url' ? link.url : link.type === 'product' ? product(link.product, link.entry) : url(link.entry.path);
|
|
273
273
|
const hashAt = base.indexOf('#');
|
|
274
274
|
const address = hashAt === -1 ? base : base.slice(0, hashAt);
|
|
275
275
|
const ownHash = hashAt === -1 ? null : base.slice(hashAt + 1);
|
|
@@ -509,8 +509,11 @@ const sitemapXml = (entries, { exclude = hidden, ...options })=>{
|
|
|
509
509
|
exports.DEFAULT_URL = config.DEFAULT_URL;
|
|
510
510
|
exports.ENTRY_ATTRIBUTE = preview.ENTRY_ATTRIBUTE;
|
|
511
511
|
exports.PREVIEW_PARAMS = preview.PREVIEW_PARAMS;
|
|
512
|
+
exports.PRODUCT_ATTRIBUTE = preview.PRODUCT_ATTRIBUTE;
|
|
513
|
+
exports.PRODUCT_HANDLE_ATTRIBUTE = preview.PRODUCT_HANDLE_ATTRIBUTE;
|
|
512
514
|
exports.UID_ATTRIBUTE = preview.UID_ATTRIBUTE;
|
|
513
515
|
exports.editable = preview.editable;
|
|
516
|
+
exports.editableProduct = preview.editableProduct;
|
|
514
517
|
exports.readPreviewParams = preview.readPreviewParams;
|
|
515
518
|
exports.ContentApiError = ContentApiError;
|
|
516
519
|
exports.ContentClient = ContentClient;
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { n as normalizeUrl, a as DEFAULT_TIMEOUT, b as DELIVERY_PATH, D as DEFAULT_URL } from './config-c6qktlz6.mjs';
|
|
2
|
-
export { E as ENTRY_ATTRIBUTE, P as PREVIEW_PARAMS, U as UID_ATTRIBUTE, e as editable, r as readPreviewParams } from './preview-
|
|
2
|
+
export { E as ENTRY_ATTRIBUTE, P as PREVIEW_PARAMS, a as PRODUCT_ATTRIBUTE, b as PRODUCT_HANDLE_ATTRIBUTE, U as UID_ATTRIBUTE, e as editable, c as editableProduct, r as readPreviewParams } from './preview-jcmxxj92.mjs';
|
|
3
3
|
|
|
4
4
|
// A response from the API that wasn't a success. `message` is the API's own
|
|
5
5
|
// `error` text when it sent one.
|
|
@@ -264,10 +264,10 @@ const pickImproveVariant = (block, option, fallback)=>{
|
|
|
264
264
|
return Object.values(variants)[0] ?? [];
|
|
265
265
|
};
|
|
266
266
|
|
|
267
|
-
const linkHref = (link, { url = (path)=>`/${path}` } = {})=>{
|
|
267
|
+
const linkHref = (link, { url = (path)=>`/${path}`, product = ({ handle })=>`/products/${handle}` } = {})=>{
|
|
268
268
|
if (!link) return null;
|
|
269
269
|
if (link.type === 'entry' && link.entry.path === null) return null;
|
|
270
|
-
const base = link.type === 'url' ? link.url : url(link.entry.path);
|
|
270
|
+
const base = link.type === 'url' ? link.url : link.type === 'product' ? product(link.product, link.entry) : url(link.entry.path);
|
|
271
271
|
const hashAt = base.indexOf('#');
|
|
272
272
|
const address = hashAt === -1 ? base : base.slice(0, hashAt);
|
|
273
273
|
const ownHash = hashAt === -1 ? null : base.slice(hashAt + 1);
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
const UID_ATTRIBUTE = 'data-cms-uid';
|
|
2
2
|
const ENTRY_ATTRIBUTE = 'data-cms-entry';
|
|
3
|
+
const PRODUCT_ATTRIBUTE = 'data-cms-product';
|
|
4
|
+
const PRODUCT_HANDLE_ATTRIBUTE = 'data-cms-product-handle';
|
|
3
5
|
// The attribute that lets editors select a block on the page, in the visual
|
|
4
6
|
// editor and on the site. Spread it on the block's outermost element:
|
|
5
7
|
//
|
|
@@ -22,6 +24,18 @@ const editable = (target)=>{
|
|
|
22
24
|
}
|
|
23
25
|
return {};
|
|
24
26
|
};
|
|
27
|
+
// The Shopify product a page shows, on a product route: editing on the site
|
|
28
|
+
// then offers "Add a product page" when the page has no product page yet
|
|
29
|
+
// (no `editable(entry)`), and makes one for this product.
|
|
30
|
+
//
|
|
31
|
+
// <main {...editableProduct(product)} {...editable(page)}>…</main>
|
|
32
|
+
//
|
|
33
|
+
// `product` is the store's (its GID and handle), from the Storefront API or
|
|
34
|
+
// a Shopify field.
|
|
35
|
+
const editableProduct = (product)=>product?.id ? {
|
|
36
|
+
'data-cms-product': product.id,
|
|
37
|
+
'data-cms-product-handle': product.handle
|
|
38
|
+
} : {};
|
|
25
39
|
|
|
26
40
|
// The visual editor loads the site in an iframe at the environment's preview
|
|
27
41
|
// URL plus the entry's path, with these parameters added. `cms_token` is a
|
|
@@ -72,6 +86,9 @@ const readPreviewParams = (input)=>{
|
|
|
72
86
|
|
|
73
87
|
exports.ENTRY_ATTRIBUTE = ENTRY_ATTRIBUTE;
|
|
74
88
|
exports.PREVIEW_PARAMS = PREVIEW_PARAMS;
|
|
89
|
+
exports.PRODUCT_ATTRIBUTE = PRODUCT_ATTRIBUTE;
|
|
90
|
+
exports.PRODUCT_HANDLE_ATTRIBUTE = PRODUCT_HANDLE_ATTRIBUTE;
|
|
75
91
|
exports.UID_ATTRIBUTE = UID_ATTRIBUTE;
|
|
76
92
|
exports.editable = editable;
|
|
93
|
+
exports.editableProduct = editableProduct;
|
|
77
94
|
exports.readPreviewParams = readPreviewParams;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
const UID_ATTRIBUTE = 'data-cms-uid';
|
|
2
2
|
const ENTRY_ATTRIBUTE = 'data-cms-entry';
|
|
3
|
+
const PRODUCT_ATTRIBUTE = 'data-cms-product';
|
|
4
|
+
const PRODUCT_HANDLE_ATTRIBUTE = 'data-cms-product-handle';
|
|
3
5
|
// The attribute that lets editors select a block on the page, in the visual
|
|
4
6
|
// editor and on the site. Spread it on the block's outermost element:
|
|
5
7
|
//
|
|
@@ -22,6 +24,18 @@ const editable = (target)=>{
|
|
|
22
24
|
}
|
|
23
25
|
return {};
|
|
24
26
|
};
|
|
27
|
+
// The Shopify product a page shows, on a product route: editing on the site
|
|
28
|
+
// then offers "Add a product page" when the page has no product page yet
|
|
29
|
+
// (no `editable(entry)`), and makes one for this product.
|
|
30
|
+
//
|
|
31
|
+
// <main {...editableProduct(product)} {...editable(page)}>…</main>
|
|
32
|
+
//
|
|
33
|
+
// `product` is the store's (its GID and handle), from the Storefront API or
|
|
34
|
+
// a Shopify field.
|
|
35
|
+
const editableProduct = (product)=>product?.id ? {
|
|
36
|
+
'data-cms-product': product.id,
|
|
37
|
+
'data-cms-product-handle': product.handle
|
|
38
|
+
} : {};
|
|
25
39
|
|
|
26
40
|
// The visual editor loads the site in an iframe at the environment's preview
|
|
27
41
|
// URL plus the entry's path, with these parameters added. `cms_token` is a
|
|
@@ -70,4 +84,4 @@ const readPreviewParams = (input)=>{
|
|
|
70
84
|
};
|
|
71
85
|
};
|
|
72
86
|
|
|
73
|
-
export { ENTRY_ATTRIBUTE as E, PREVIEW_PARAMS as P, UID_ATTRIBUTE as U, editable as e, readPreviewParams as r };
|
|
87
|
+
export { ENTRY_ATTRIBUTE as E, PREVIEW_PARAMS as P, UID_ATTRIBUTE as U, PRODUCT_ATTRIBUTE as a, PRODUCT_HANDLE_ATTRIBUTE as b, editableProduct as c, editable as e, readPreviewParams as r };
|
package/dist/site.js
CHANGED
|
@@ -94,6 +94,11 @@ const PROXY_ROUTES = [
|
|
|
94
94
|
method: 'POST',
|
|
95
95
|
pattern: /^entries$/
|
|
96
96
|
},
|
|
97
|
+
// "Add a product page" on a product the site marks (editableProduct).
|
|
98
|
+
{
|
|
99
|
+
method: 'POST',
|
|
100
|
+
pattern: /^product-pages$/
|
|
101
|
+
},
|
|
97
102
|
// The one-time address of the CMS's entry form (the prompt box's Form).
|
|
98
103
|
{
|
|
99
104
|
method: 'POST',
|
package/dist/site.mjs
CHANGED
|
@@ -92,6 +92,11 @@ const PROXY_ROUTES = [
|
|
|
92
92
|
method: 'POST',
|
|
93
93
|
pattern: /^entries$/
|
|
94
94
|
},
|
|
95
|
+
// "Add a product page" on a product the site marks (editableProduct).
|
|
96
|
+
{
|
|
97
|
+
method: 'POST',
|
|
98
|
+
pattern: /^product-pages$/
|
|
99
|
+
},
|
|
95
100
|
// The one-time address of the CMS's entry form (the prompt box's Form).
|
|
96
101
|
{
|
|
97
102
|
method: 'POST',
|
|
@@ -47,6 +47,12 @@ type Link = {
|
|
|
47
47
|
url: string;
|
|
48
48
|
query: string | null;
|
|
49
49
|
hash: string | null;
|
|
50
|
+
} | {
|
|
51
|
+
type: 'product';
|
|
52
|
+
product: ShopifyItem;
|
|
53
|
+
entry: LinkTarget | null;
|
|
54
|
+
query: string | null;
|
|
55
|
+
hash: string | null;
|
|
50
56
|
};
|
|
51
57
|
type Block<TFields extends Record<string, unknown> = Record<string, unknown>, TType extends string = string> = {
|
|
52
58
|
_uid: string;
|
|
@@ -152,6 +158,7 @@ type FieldDefinition = BaseField & ({
|
|
|
152
158
|
} | {
|
|
153
159
|
type: 'link';
|
|
154
160
|
contentTypes?: string[];
|
|
161
|
+
products?: boolean;
|
|
155
162
|
} | {
|
|
156
163
|
type: 'blocks';
|
|
157
164
|
allowedBlocks?: string[];
|
|
@@ -161,6 +168,7 @@ type FieldDefinition = BaseField & ({
|
|
|
161
168
|
type: 'shopify';
|
|
162
169
|
resource: 'collection' | 'product';
|
|
163
170
|
multiple?: boolean;
|
|
171
|
+
unique?: boolean;
|
|
164
172
|
min?: number;
|
|
165
173
|
max?: number;
|
|
166
174
|
} | {
|
|
@@ -180,5 +188,5 @@ type ModelFile = {
|
|
|
180
188
|
contentTypes: ContentTypeDefinition[];
|
|
181
189
|
};
|
|
182
190
|
|
|
183
|
-
export type { Asset as A, Block as B, ContentTypeDefinition as C, Entry as E, FieldDefinition as F, ImproveBlock as I,
|
|
184
|
-
//# sourceMappingURL=types-
|
|
191
|
+
export type { Asset as A, Block as B, ContentTypeDefinition as C, Entry as E, FieldDefinition as F, ImproveBlock as I, LinkTarget as L, ModelFile as M, RichTextFormat as R, ShopifyItem as S, RedirectList as a, Redirect as b, EntryList as c, Link as d, EntryStub as e, RichTextNode as f, ContentTypeKind as g, Environment as h, FieldType as i, RichTextDocument as j, RichTextMark as k };
|
|
192
|
+
//# sourceMappingURL=types-mtjco3a5.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types-mtjco3a5.d.ts","sources":["../src/types.ts"],"mappings":"AAAA,KAAK,WAAW;AAChB,KAAK,cAAc;AACnB,KAAK,KAAK;AACV;AACA;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB,MAAM;AAC1B,kBAAkB,MAAM;AACxB;AACA;AACA;AACA;AACA;AACA,KAAK,KAAK,iBAAiB,MAAM,oBAAoB,MAAM;AAC3D;AACA;AACA;AACA;AACA;AACA,WAAW,MAAM;AACjB;AACA;AACA;AACA;AACA;AACA,KAAK,SAAS;AACd;AACA;AACA;AACA,KAAK,UAAU;AACf;AACA,oBAAoB,MAAM;AAC1B;AACA;AACA;AACA,KAAK,IAAI;AACT;AACA,WAAW,UAAU;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,WAAW;AACxB,WAAW,UAAU;AACrB;AACA;AACA;AACA,KAAK,KAAK,iBAAiB,MAAM,oBAAoB,MAAM;AAC3D;AACA;AACA;AACA,KAAK,YAAY,gBAAgB,KAAK,GAAG,KAAK,IAAI,KAAK;AACvD;AACA;AACA,cAAc,MAAM;AACpB;AACA,KAAK,YAAY;AACjB;AACA,YAAY,MAAM;AAClB;AACA,KAAK,YAAY;AACjB;AACA,YAAY,MAAM;AAClB,cAAc,YAAY;AAC1B;AACA,YAAY,YAAY;AACxB;AACA,KAAK,gBAAgB,GAAG,YAAY;AACpC;AACA;AACA,KAAK,SAAS,gBAAgB,KAAK,GAAG,KAAK;AAC3C;AACA;AACA;AACA;AACA;AACA,KAAK,QAAQ;AACb;AACA;AACA;AACA;AACA,KAAK,YAAY;AACjB,WAAW,QAAQ;AACnB;AACA;AACA;AACA;AACA,KAAK,WAAW;AAChB;AACA;AACA;AACA,KAAK,eAAe;AACpB,KAAK,SAAS;AACd;AACA;AACA;AACA;AACA;AACA;AACA,KAAK,eAAe,GAAG,SAAS;AAChC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK,SAAS,GAAG,eAAe;AAChC,KAAK,qBAAqB;AAC1B;AACA;AACA,UAAU,eAAe;AACzB;AACA,YAAY,eAAe;AAC3B;AACA,KAAK,SAAS;AACd;AACA;AACA,kBAAkB,qBAAqB;AACvC;;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@obelism/content",
|
|
3
3
|
"description": "Obelism Content SDK: the delivery API client, the visual editor bridge with prompt editing, editing on your own site, webhook verification, and the content model CLI",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.18.0",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cms",
|
|
7
7
|
"headless-cms",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types-e5nvgudo.d.ts","sources":["../src/types.ts"],"mappings":"AAAA,KAAK,WAAW;AAChB,KAAK,cAAc;AACnB,KAAK,KAAK;AACV;AACA;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB,MAAM;AAC1B,kBAAkB,MAAM;AACxB;AACA;AACA;AACA;AACA;AACA,KAAK,KAAK,iBAAiB,MAAM,oBAAoB,MAAM;AAC3D;AACA;AACA;AACA;AACA;AACA,WAAW,MAAM;AACjB;AACA;AACA;AACA;AACA;AACA,KAAK,SAAS;AACd;AACA;AACA;AACA,KAAK,UAAU;AACf;AACA,oBAAoB,MAAM;AAC1B;AACA;AACA;AACA,KAAK,IAAI;AACT;AACA,WAAW,UAAU;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK,KAAK,iBAAiB,MAAM,oBAAoB,MAAM;AAC3D;AACA;AACA;AACA,KAAK,YAAY,gBAAgB,KAAK,GAAG,KAAK,IAAI,KAAK;AACvD;AACA;AACA,cAAc,MAAM;AACpB;AACA,KAAK,YAAY;AACjB;AACA,YAAY,MAAM;AAClB;AACA,KAAK,YAAY;AACjB;AACA,YAAY,MAAM;AAClB,cAAc,YAAY;AAC1B;AACA,YAAY,YAAY;AACxB;AACA,KAAK,gBAAgB,GAAG,YAAY;AACpC;AACA;AACA,KAAK,SAAS,gBAAgB,KAAK,GAAG,KAAK;AAC3C;AACA;AACA;AACA;AACA;AACA,KAAK,QAAQ;AACb;AACA;AACA;AACA;AACA,KAAK,YAAY;AACjB,WAAW,QAAQ;AACnB;AACA;AACA;AACA;AACA,KAAK,WAAW;AAChB;AACA;AACA;AACA,KAAK,eAAe;AACpB,KAAK,SAAS;AACd;AACA;AACA;AACA;AACA;AACA;AACA,KAAK,eAAe,GAAG,SAAS;AAChC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK,SAAS,GAAG,eAAe;AAChC,KAAK,qBAAqB;AAC1B;AACA;AACA,UAAU,eAAe;AACzB;AACA,YAAY,eAAe;AAC3B;AACA,KAAK,SAAS;AACd;AACA;AACA,kBAAkB,qBAAqB;AACvC;;","names":[]}
|