@cmssy/react 0.9.3 → 0.10.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/client.cjs +1 -0
- package/dist/client.js +1 -0
- package/dist/index.cjs +55 -30
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +55 -30
- package/package.json +2 -2
package/dist/client.cjs
CHANGED
package/dist/client.js
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -31,6 +31,7 @@ var fields = {
|
|
|
31
31
|
radio: control("radio"),
|
|
32
32
|
repeater: control("repeater"),
|
|
33
33
|
table: control("table"),
|
|
34
|
+
json: control("json"),
|
|
34
35
|
form: control("form"),
|
|
35
36
|
pageSelector: control("pageSelector")
|
|
36
37
|
};
|
|
@@ -307,46 +308,70 @@ function resolveApiUrl(apiUrl) {
|
|
|
307
308
|
return fromEnv.length > 0 ? fromEnv : DEFAULT_CMSSY_API_URL;
|
|
308
309
|
}
|
|
309
310
|
var PUBLIC_PAGE_QUERY = `query PublicPage($workspaceSlug: String!, $slug: String!, $previewSecret: String) {
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
311
|
+
public {
|
|
312
|
+
page {
|
|
313
|
+
get(workspaceSlug: $workspaceSlug, slug: $slug, previewSecret: $previewSecret) {
|
|
314
|
+
id
|
|
315
|
+
blocks { id type content }
|
|
316
|
+
publishedBlocks { id type content }
|
|
317
|
+
}
|
|
318
|
+
}
|
|
314
319
|
}
|
|
315
320
|
}`;
|
|
316
321
|
var PUBLIC_PAGE_DEV_QUERY = `query PublicPage($workspaceSlug: String!, $slug: String!, $previewSecret: String, $devPreview: Boolean) {
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
322
|
+
public {
|
|
323
|
+
page {
|
|
324
|
+
get(workspaceSlug: $workspaceSlug, slug: $slug, previewSecret: $previewSecret, devPreview: $devPreview) {
|
|
325
|
+
id
|
|
326
|
+
blocks { id type content }
|
|
327
|
+
publishedBlocks { id type content }
|
|
328
|
+
}
|
|
329
|
+
}
|
|
321
330
|
}
|
|
322
331
|
}`;
|
|
323
332
|
var PUBLIC_PAGE_BY_ID_QUERY = `query PublicPageById($workspaceSlug: String!, $pageId: ID!) {
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
333
|
+
public {
|
|
334
|
+
page {
|
|
335
|
+
getById(workspaceSlug: $workspaceSlug, pageId: $pageId) {
|
|
336
|
+
id
|
|
337
|
+
publishedBlocks { id type content }
|
|
338
|
+
}
|
|
339
|
+
}
|
|
327
340
|
}
|
|
328
341
|
}`;
|
|
329
342
|
var PUBLIC_PAGES_QUERY = `query PublicPages($workspaceSlug: String!) {
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
343
|
+
public {
|
|
344
|
+
page {
|
|
345
|
+
list(workspaceSlug: $workspaceSlug) {
|
|
346
|
+
id
|
|
347
|
+
slug
|
|
348
|
+
updatedAt
|
|
349
|
+
publishedAt
|
|
350
|
+
}
|
|
351
|
+
}
|
|
335
352
|
}
|
|
336
353
|
}`;
|
|
337
354
|
var PUBLIC_PAGE_META_QUERY = `query PublicPageMeta($workspaceSlug: String!, $slug: String!) {
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
355
|
+
public {
|
|
356
|
+
page {
|
|
357
|
+
get(workspaceSlug: $workspaceSlug, slug: $slug) {
|
|
358
|
+
id
|
|
359
|
+
seoTitle
|
|
360
|
+
seoDescription
|
|
361
|
+
seoKeywords
|
|
362
|
+
displayName
|
|
363
|
+
}
|
|
364
|
+
}
|
|
344
365
|
}
|
|
345
366
|
}`;
|
|
346
367
|
var PUBLIC_PAGE_LAYOUTS_QUERY = `query PublicPageLayouts($workspaceSlug: String!, $pageSlug: String!, $previewSecret: String) {
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
368
|
+
public {
|
|
369
|
+
page {
|
|
370
|
+
layouts(workspaceSlug: $workspaceSlug, pageSlug: $pageSlug, previewSecret: $previewSecret) {
|
|
371
|
+
position
|
|
372
|
+
blocks { id type content order isActive }
|
|
373
|
+
}
|
|
374
|
+
}
|
|
350
375
|
}
|
|
351
376
|
}`;
|
|
352
377
|
function normalizeSlug(path) {
|
|
@@ -414,7 +439,7 @@ async function fetchPage(config, path, options = {}) {
|
|
|
414
439
|
const message = json.errors.map((error) => error.message ?? "GraphQL error").join("; ");
|
|
415
440
|
throw new Error(`cmssy: page fetch error - ${message}`);
|
|
416
441
|
}
|
|
417
|
-
const page = json.data?.
|
|
442
|
+
const page = json.data?.public?.page?.get;
|
|
418
443
|
if (!page) return null;
|
|
419
444
|
const draft = previewSecret !== null || devPreview;
|
|
420
445
|
const blocks = (draft ? page.blocks : page.publishedBlocks) ?? [];
|
|
@@ -460,7 +485,7 @@ async function fetchPageById(config, pageId, options = {}) {
|
|
|
460
485
|
const message = json.errors.map((error) => error.message ?? "GraphQL error").join("; ");
|
|
461
486
|
throw new Error(`cmssy: page-by-id fetch error - ${message}`);
|
|
462
487
|
}
|
|
463
|
-
const page = json.data?.
|
|
488
|
+
const page = json.data?.public?.page?.getById;
|
|
464
489
|
if (!page) return null;
|
|
465
490
|
return { id: page.id, blocks: page.publishedBlocks ?? [] };
|
|
466
491
|
}
|
|
@@ -493,7 +518,7 @@ async function fetchPages(config, options = {}) {
|
|
|
493
518
|
const message = json.errors.map((error) => error.message ?? "GraphQL error").join("; ");
|
|
494
519
|
throw new Error(`cmssy: pages fetch error - ${message}`);
|
|
495
520
|
}
|
|
496
|
-
return json.data?.
|
|
521
|
+
return json.data?.public?.page?.list ?? [];
|
|
497
522
|
}
|
|
498
523
|
async function fetchPageMeta(config, path, options = {}) {
|
|
499
524
|
const slug = normalizeSlug(path);
|
|
@@ -525,7 +550,7 @@ async function fetchPageMeta(config, path, options = {}) {
|
|
|
525
550
|
const message = json.errors.map((error) => error.message ?? "GraphQL error").join("; ");
|
|
526
551
|
throw new Error(`cmssy: page meta fetch error - ${message}`);
|
|
527
552
|
}
|
|
528
|
-
return json.data?.
|
|
553
|
+
return json.data?.public?.page?.get ?? null;
|
|
529
554
|
}
|
|
530
555
|
async function fetchLayouts(config, path, options = {}) {
|
|
531
556
|
const pageSlug = normalizeSlug(path);
|
|
@@ -563,7 +588,7 @@ async function fetchLayouts(config, path, options = {}) {
|
|
|
563
588
|
const message = json.errors.map((error) => error.message ?? "GraphQL error").join("; ");
|
|
564
589
|
throw new Error(`cmssy: layouts fetch error - ${message}`);
|
|
565
590
|
}
|
|
566
|
-
return json.data?.
|
|
591
|
+
return json.data?.public?.page?.layouts ?? [];
|
|
567
592
|
}
|
|
568
593
|
|
|
569
594
|
// src/data/graphql-request.ts
|
package/dist/index.d.cts
CHANGED
|
@@ -26,6 +26,7 @@ declare const fields: {
|
|
|
26
26
|
radio: (opts?: FieldControl) => FieldDefinition;
|
|
27
27
|
repeater: (opts?: FieldControl) => FieldDefinition;
|
|
28
28
|
table: (opts?: FieldControl) => FieldDefinition;
|
|
29
|
+
json: (opts?: FieldControl) => FieldDefinition;
|
|
29
30
|
form: (opts?: FieldControl) => FieldDefinition;
|
|
30
31
|
pageSelector: (opts?: FieldControl) => FieldDefinition;
|
|
31
32
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -26,6 +26,7 @@ declare const fields: {
|
|
|
26
26
|
radio: (opts?: FieldControl) => FieldDefinition;
|
|
27
27
|
repeater: (opts?: FieldControl) => FieldDefinition;
|
|
28
28
|
table: (opts?: FieldControl) => FieldDefinition;
|
|
29
|
+
json: (opts?: FieldControl) => FieldDefinition;
|
|
29
30
|
form: (opts?: FieldControl) => FieldDefinition;
|
|
30
31
|
pageSelector: (opts?: FieldControl) => FieldDefinition;
|
|
31
32
|
};
|
package/dist/index.js
CHANGED
|
@@ -29,6 +29,7 @@ var fields = {
|
|
|
29
29
|
radio: control("radio"),
|
|
30
30
|
repeater: control("repeater"),
|
|
31
31
|
table: control("table"),
|
|
32
|
+
json: control("json"),
|
|
32
33
|
form: control("form"),
|
|
33
34
|
pageSelector: control("pageSelector")
|
|
34
35
|
};
|
|
@@ -305,46 +306,70 @@ function resolveApiUrl(apiUrl) {
|
|
|
305
306
|
return fromEnv.length > 0 ? fromEnv : DEFAULT_CMSSY_API_URL;
|
|
306
307
|
}
|
|
307
308
|
var PUBLIC_PAGE_QUERY = `query PublicPage($workspaceSlug: String!, $slug: String!, $previewSecret: String) {
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
309
|
+
public {
|
|
310
|
+
page {
|
|
311
|
+
get(workspaceSlug: $workspaceSlug, slug: $slug, previewSecret: $previewSecret) {
|
|
312
|
+
id
|
|
313
|
+
blocks { id type content }
|
|
314
|
+
publishedBlocks { id type content }
|
|
315
|
+
}
|
|
316
|
+
}
|
|
312
317
|
}
|
|
313
318
|
}`;
|
|
314
319
|
var PUBLIC_PAGE_DEV_QUERY = `query PublicPage($workspaceSlug: String!, $slug: String!, $previewSecret: String, $devPreview: Boolean) {
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
320
|
+
public {
|
|
321
|
+
page {
|
|
322
|
+
get(workspaceSlug: $workspaceSlug, slug: $slug, previewSecret: $previewSecret, devPreview: $devPreview) {
|
|
323
|
+
id
|
|
324
|
+
blocks { id type content }
|
|
325
|
+
publishedBlocks { id type content }
|
|
326
|
+
}
|
|
327
|
+
}
|
|
319
328
|
}
|
|
320
329
|
}`;
|
|
321
330
|
var PUBLIC_PAGE_BY_ID_QUERY = `query PublicPageById($workspaceSlug: String!, $pageId: ID!) {
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
331
|
+
public {
|
|
332
|
+
page {
|
|
333
|
+
getById(workspaceSlug: $workspaceSlug, pageId: $pageId) {
|
|
334
|
+
id
|
|
335
|
+
publishedBlocks { id type content }
|
|
336
|
+
}
|
|
337
|
+
}
|
|
325
338
|
}
|
|
326
339
|
}`;
|
|
327
340
|
var PUBLIC_PAGES_QUERY = `query PublicPages($workspaceSlug: String!) {
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
341
|
+
public {
|
|
342
|
+
page {
|
|
343
|
+
list(workspaceSlug: $workspaceSlug) {
|
|
344
|
+
id
|
|
345
|
+
slug
|
|
346
|
+
updatedAt
|
|
347
|
+
publishedAt
|
|
348
|
+
}
|
|
349
|
+
}
|
|
333
350
|
}
|
|
334
351
|
}`;
|
|
335
352
|
var PUBLIC_PAGE_META_QUERY = `query PublicPageMeta($workspaceSlug: String!, $slug: String!) {
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
353
|
+
public {
|
|
354
|
+
page {
|
|
355
|
+
get(workspaceSlug: $workspaceSlug, slug: $slug) {
|
|
356
|
+
id
|
|
357
|
+
seoTitle
|
|
358
|
+
seoDescription
|
|
359
|
+
seoKeywords
|
|
360
|
+
displayName
|
|
361
|
+
}
|
|
362
|
+
}
|
|
342
363
|
}
|
|
343
364
|
}`;
|
|
344
365
|
var PUBLIC_PAGE_LAYOUTS_QUERY = `query PublicPageLayouts($workspaceSlug: String!, $pageSlug: String!, $previewSecret: String) {
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
366
|
+
public {
|
|
367
|
+
page {
|
|
368
|
+
layouts(workspaceSlug: $workspaceSlug, pageSlug: $pageSlug, previewSecret: $previewSecret) {
|
|
369
|
+
position
|
|
370
|
+
blocks { id type content order isActive }
|
|
371
|
+
}
|
|
372
|
+
}
|
|
348
373
|
}
|
|
349
374
|
}`;
|
|
350
375
|
function normalizeSlug(path) {
|
|
@@ -412,7 +437,7 @@ async function fetchPage(config, path, options = {}) {
|
|
|
412
437
|
const message = json.errors.map((error) => error.message ?? "GraphQL error").join("; ");
|
|
413
438
|
throw new Error(`cmssy: page fetch error - ${message}`);
|
|
414
439
|
}
|
|
415
|
-
const page = json.data?.
|
|
440
|
+
const page = json.data?.public?.page?.get;
|
|
416
441
|
if (!page) return null;
|
|
417
442
|
const draft = previewSecret !== null || devPreview;
|
|
418
443
|
const blocks = (draft ? page.blocks : page.publishedBlocks) ?? [];
|
|
@@ -458,7 +483,7 @@ async function fetchPageById(config, pageId, options = {}) {
|
|
|
458
483
|
const message = json.errors.map((error) => error.message ?? "GraphQL error").join("; ");
|
|
459
484
|
throw new Error(`cmssy: page-by-id fetch error - ${message}`);
|
|
460
485
|
}
|
|
461
|
-
const page = json.data?.
|
|
486
|
+
const page = json.data?.public?.page?.getById;
|
|
462
487
|
if (!page) return null;
|
|
463
488
|
return { id: page.id, blocks: page.publishedBlocks ?? [] };
|
|
464
489
|
}
|
|
@@ -491,7 +516,7 @@ async function fetchPages(config, options = {}) {
|
|
|
491
516
|
const message = json.errors.map((error) => error.message ?? "GraphQL error").join("; ");
|
|
492
517
|
throw new Error(`cmssy: pages fetch error - ${message}`);
|
|
493
518
|
}
|
|
494
|
-
return json.data?.
|
|
519
|
+
return json.data?.public?.page?.list ?? [];
|
|
495
520
|
}
|
|
496
521
|
async function fetchPageMeta(config, path, options = {}) {
|
|
497
522
|
const slug = normalizeSlug(path);
|
|
@@ -523,7 +548,7 @@ async function fetchPageMeta(config, path, options = {}) {
|
|
|
523
548
|
const message = json.errors.map((error) => error.message ?? "GraphQL error").join("; ");
|
|
524
549
|
throw new Error(`cmssy: page meta fetch error - ${message}`);
|
|
525
550
|
}
|
|
526
|
-
return json.data?.
|
|
551
|
+
return json.data?.public?.page?.get ?? null;
|
|
527
552
|
}
|
|
528
553
|
async function fetchLayouts(config, path, options = {}) {
|
|
529
554
|
const pageSlug = normalizeSlug(path);
|
|
@@ -561,7 +586,7 @@ async function fetchLayouts(config, path, options = {}) {
|
|
|
561
586
|
const message = json.errors.map((error) => error.message ?? "GraphQL error").join("; ");
|
|
562
587
|
throw new Error(`cmssy: layouts fetch error - ${message}`);
|
|
563
588
|
}
|
|
564
|
-
return json.data?.
|
|
589
|
+
return json.data?.public?.page?.layouts ?? [];
|
|
565
590
|
}
|
|
566
591
|
|
|
567
592
|
// src/data/graphql-request.ts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cmssy/react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"description": "React blocks, renderers, data client and editor bridge for cmssy headless sites",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cmssy",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"vitest": "^2.1.0"
|
|
57
57
|
},
|
|
58
58
|
"dependencies": {
|
|
59
|
-
"@cmssy/types": "0.
|
|
59
|
+
"@cmssy/types": "0.22.0"
|
|
60
60
|
},
|
|
61
61
|
"scripts": {
|
|
62
62
|
"build": "tsup",
|