@cmssy/react 0.9.4 → 0.11.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 +54 -30
- package/dist/index.js +54 -30
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -308,46 +308,70 @@ function resolveApiUrl(apiUrl) {
|
|
|
308
308
|
return fromEnv.length > 0 ? fromEnv : DEFAULT_CMSSY_API_URL;
|
|
309
309
|
}
|
|
310
310
|
var PUBLIC_PAGE_QUERY = `query PublicPage($workspaceSlug: String!, $slug: String!, $previewSecret: String) {
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
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
|
+
}
|
|
315
319
|
}
|
|
316
320
|
}`;
|
|
317
321
|
var PUBLIC_PAGE_DEV_QUERY = `query PublicPage($workspaceSlug: String!, $slug: String!, $previewSecret: String, $devPreview: Boolean) {
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
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
|
+
}
|
|
322
330
|
}
|
|
323
331
|
}`;
|
|
324
332
|
var PUBLIC_PAGE_BY_ID_QUERY = `query PublicPageById($workspaceSlug: String!, $pageId: ID!) {
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
333
|
+
public {
|
|
334
|
+
page {
|
|
335
|
+
getById(workspaceSlug: $workspaceSlug, pageId: $pageId) {
|
|
336
|
+
id
|
|
337
|
+
publishedBlocks { id type content }
|
|
338
|
+
}
|
|
339
|
+
}
|
|
328
340
|
}
|
|
329
341
|
}`;
|
|
330
342
|
var PUBLIC_PAGES_QUERY = `query PublicPages($workspaceSlug: String!) {
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
343
|
+
public {
|
|
344
|
+
page {
|
|
345
|
+
list(workspaceSlug: $workspaceSlug) {
|
|
346
|
+
id
|
|
347
|
+
slug
|
|
348
|
+
updatedAt
|
|
349
|
+
publishedAt
|
|
350
|
+
}
|
|
351
|
+
}
|
|
336
352
|
}
|
|
337
353
|
}`;
|
|
338
354
|
var PUBLIC_PAGE_META_QUERY = `query PublicPageMeta($workspaceSlug: String!, $slug: String!) {
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
355
|
+
public {
|
|
356
|
+
page {
|
|
357
|
+
get(workspaceSlug: $workspaceSlug, slug: $slug) {
|
|
358
|
+
id
|
|
359
|
+
seoTitle
|
|
360
|
+
seoDescription
|
|
361
|
+
seoKeywords
|
|
362
|
+
displayName
|
|
363
|
+
}
|
|
364
|
+
}
|
|
345
365
|
}
|
|
346
366
|
}`;
|
|
347
367
|
var PUBLIC_PAGE_LAYOUTS_QUERY = `query PublicPageLayouts($workspaceSlug: String!, $pageSlug: String!, $previewSecret: String) {
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
368
|
+
public {
|
|
369
|
+
page {
|
|
370
|
+
layouts(workspaceSlug: $workspaceSlug, pageSlug: $pageSlug, previewSecret: $previewSecret) {
|
|
371
|
+
position
|
|
372
|
+
blocks { id type content order isActive }
|
|
373
|
+
}
|
|
374
|
+
}
|
|
351
375
|
}
|
|
352
376
|
}`;
|
|
353
377
|
function normalizeSlug(path) {
|
|
@@ -415,7 +439,7 @@ async function fetchPage(config, path, options = {}) {
|
|
|
415
439
|
const message = json.errors.map((error) => error.message ?? "GraphQL error").join("; ");
|
|
416
440
|
throw new Error(`cmssy: page fetch error - ${message}`);
|
|
417
441
|
}
|
|
418
|
-
const page = json.data?.
|
|
442
|
+
const page = json.data?.public?.page?.get;
|
|
419
443
|
if (!page) return null;
|
|
420
444
|
const draft = previewSecret !== null || devPreview;
|
|
421
445
|
const blocks = (draft ? page.blocks : page.publishedBlocks) ?? [];
|
|
@@ -461,7 +485,7 @@ async function fetchPageById(config, pageId, options = {}) {
|
|
|
461
485
|
const message = json.errors.map((error) => error.message ?? "GraphQL error").join("; ");
|
|
462
486
|
throw new Error(`cmssy: page-by-id fetch error - ${message}`);
|
|
463
487
|
}
|
|
464
|
-
const page = json.data?.
|
|
488
|
+
const page = json.data?.public?.page?.getById;
|
|
465
489
|
if (!page) return null;
|
|
466
490
|
return { id: page.id, blocks: page.publishedBlocks ?? [] };
|
|
467
491
|
}
|
|
@@ -494,7 +518,7 @@ async function fetchPages(config, options = {}) {
|
|
|
494
518
|
const message = json.errors.map((error) => error.message ?? "GraphQL error").join("; ");
|
|
495
519
|
throw new Error(`cmssy: pages fetch error - ${message}`);
|
|
496
520
|
}
|
|
497
|
-
return json.data?.
|
|
521
|
+
return json.data?.public?.page?.list ?? [];
|
|
498
522
|
}
|
|
499
523
|
async function fetchPageMeta(config, path, options = {}) {
|
|
500
524
|
const slug = normalizeSlug(path);
|
|
@@ -526,7 +550,7 @@ async function fetchPageMeta(config, path, options = {}) {
|
|
|
526
550
|
const message = json.errors.map((error) => error.message ?? "GraphQL error").join("; ");
|
|
527
551
|
throw new Error(`cmssy: page meta fetch error - ${message}`);
|
|
528
552
|
}
|
|
529
|
-
return json.data?.
|
|
553
|
+
return json.data?.public?.page?.get ?? null;
|
|
530
554
|
}
|
|
531
555
|
async function fetchLayouts(config, path, options = {}) {
|
|
532
556
|
const pageSlug = normalizeSlug(path);
|
|
@@ -564,7 +588,7 @@ async function fetchLayouts(config, path, options = {}) {
|
|
|
564
588
|
const message = json.errors.map((error) => error.message ?? "GraphQL error").join("; ");
|
|
565
589
|
throw new Error(`cmssy: layouts fetch error - ${message}`);
|
|
566
590
|
}
|
|
567
|
-
return json.data?.
|
|
591
|
+
return json.data?.public?.page?.layouts ?? [];
|
|
568
592
|
}
|
|
569
593
|
|
|
570
594
|
// src/data/graphql-request.ts
|
package/dist/index.js
CHANGED
|
@@ -306,46 +306,70 @@ function resolveApiUrl(apiUrl) {
|
|
|
306
306
|
return fromEnv.length > 0 ? fromEnv : DEFAULT_CMSSY_API_URL;
|
|
307
307
|
}
|
|
308
308
|
var PUBLIC_PAGE_QUERY = `query PublicPage($workspaceSlug: String!, $slug: String!, $previewSecret: String) {
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
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
|
+
}
|
|
313
317
|
}
|
|
314
318
|
}`;
|
|
315
319
|
var PUBLIC_PAGE_DEV_QUERY = `query PublicPage($workspaceSlug: String!, $slug: String!, $previewSecret: String, $devPreview: Boolean) {
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
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
|
+
}
|
|
320
328
|
}
|
|
321
329
|
}`;
|
|
322
330
|
var PUBLIC_PAGE_BY_ID_QUERY = `query PublicPageById($workspaceSlug: String!, $pageId: ID!) {
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
331
|
+
public {
|
|
332
|
+
page {
|
|
333
|
+
getById(workspaceSlug: $workspaceSlug, pageId: $pageId) {
|
|
334
|
+
id
|
|
335
|
+
publishedBlocks { id type content }
|
|
336
|
+
}
|
|
337
|
+
}
|
|
326
338
|
}
|
|
327
339
|
}`;
|
|
328
340
|
var PUBLIC_PAGES_QUERY = `query PublicPages($workspaceSlug: String!) {
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
341
|
+
public {
|
|
342
|
+
page {
|
|
343
|
+
list(workspaceSlug: $workspaceSlug) {
|
|
344
|
+
id
|
|
345
|
+
slug
|
|
346
|
+
updatedAt
|
|
347
|
+
publishedAt
|
|
348
|
+
}
|
|
349
|
+
}
|
|
334
350
|
}
|
|
335
351
|
}`;
|
|
336
352
|
var PUBLIC_PAGE_META_QUERY = `query PublicPageMeta($workspaceSlug: String!, $slug: String!) {
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
353
|
+
public {
|
|
354
|
+
page {
|
|
355
|
+
get(workspaceSlug: $workspaceSlug, slug: $slug) {
|
|
356
|
+
id
|
|
357
|
+
seoTitle
|
|
358
|
+
seoDescription
|
|
359
|
+
seoKeywords
|
|
360
|
+
displayName
|
|
361
|
+
}
|
|
362
|
+
}
|
|
343
363
|
}
|
|
344
364
|
}`;
|
|
345
365
|
var PUBLIC_PAGE_LAYOUTS_QUERY = `query PublicPageLayouts($workspaceSlug: String!, $pageSlug: String!, $previewSecret: String) {
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
366
|
+
public {
|
|
367
|
+
page {
|
|
368
|
+
layouts(workspaceSlug: $workspaceSlug, pageSlug: $pageSlug, previewSecret: $previewSecret) {
|
|
369
|
+
position
|
|
370
|
+
blocks { id type content order isActive }
|
|
371
|
+
}
|
|
372
|
+
}
|
|
349
373
|
}
|
|
350
374
|
}`;
|
|
351
375
|
function normalizeSlug(path) {
|
|
@@ -413,7 +437,7 @@ async function fetchPage(config, path, options = {}) {
|
|
|
413
437
|
const message = json.errors.map((error) => error.message ?? "GraphQL error").join("; ");
|
|
414
438
|
throw new Error(`cmssy: page fetch error - ${message}`);
|
|
415
439
|
}
|
|
416
|
-
const page = json.data?.
|
|
440
|
+
const page = json.data?.public?.page?.get;
|
|
417
441
|
if (!page) return null;
|
|
418
442
|
const draft = previewSecret !== null || devPreview;
|
|
419
443
|
const blocks = (draft ? page.blocks : page.publishedBlocks) ?? [];
|
|
@@ -459,7 +483,7 @@ async function fetchPageById(config, pageId, options = {}) {
|
|
|
459
483
|
const message = json.errors.map((error) => error.message ?? "GraphQL error").join("; ");
|
|
460
484
|
throw new Error(`cmssy: page-by-id fetch error - ${message}`);
|
|
461
485
|
}
|
|
462
|
-
const page = json.data?.
|
|
486
|
+
const page = json.data?.public?.page?.getById;
|
|
463
487
|
if (!page) return null;
|
|
464
488
|
return { id: page.id, blocks: page.publishedBlocks ?? [] };
|
|
465
489
|
}
|
|
@@ -492,7 +516,7 @@ async function fetchPages(config, options = {}) {
|
|
|
492
516
|
const message = json.errors.map((error) => error.message ?? "GraphQL error").join("; ");
|
|
493
517
|
throw new Error(`cmssy: pages fetch error - ${message}`);
|
|
494
518
|
}
|
|
495
|
-
return json.data?.
|
|
519
|
+
return json.data?.public?.page?.list ?? [];
|
|
496
520
|
}
|
|
497
521
|
async function fetchPageMeta(config, path, options = {}) {
|
|
498
522
|
const slug = normalizeSlug(path);
|
|
@@ -524,7 +548,7 @@ async function fetchPageMeta(config, path, options = {}) {
|
|
|
524
548
|
const message = json.errors.map((error) => error.message ?? "GraphQL error").join("; ");
|
|
525
549
|
throw new Error(`cmssy: page meta fetch error - ${message}`);
|
|
526
550
|
}
|
|
527
|
-
return json.data?.
|
|
551
|
+
return json.data?.public?.page?.get ?? null;
|
|
528
552
|
}
|
|
529
553
|
async function fetchLayouts(config, path, options = {}) {
|
|
530
554
|
const pageSlug = normalizeSlug(path);
|
|
@@ -562,7 +586,7 @@ async function fetchLayouts(config, path, options = {}) {
|
|
|
562
586
|
const message = json.errors.map((error) => error.message ?? "GraphQL error").join("; ");
|
|
563
587
|
throw new Error(`cmssy: layouts fetch error - ${message}`);
|
|
564
588
|
}
|
|
565
|
-
return json.data?.
|
|
589
|
+
return json.data?.public?.page?.layouts ?? [];
|
|
566
590
|
}
|
|
567
591
|
|
|
568
592
|
// src/data/graphql-request.ts
|