@raketa-cloud/next 1.0.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/package.json +22 -0
- package/src/Cache.js +95 -0
- package/src/cloud/public.js +7 -0
- package/src/dxp/graphql.js +11 -0
- package/src/dxp/private/Articles.js +30 -0
- package/src/dxp/private/Dxp.js +17 -0
- package/src/dxp/private/DxpClient.js +32 -0
- package/src/dxp/private/DxpModel.js +5 -0
- package/src/dxp/private/Events.js +30 -0
- package/src/dxp/private/Pages.js +30 -0
- package/src/dxp/private/Settings.js +12 -0
- package/src/dxp/private/Tags.js +26 -0
- package/src/dxp/private/documents/articlesDocuments.js +69 -0
- package/src/dxp/private/documents/common.js +44 -0
- package/src/dxp/private/documents/eventsDocuments.js +69 -0
- package/src/dxp/private/documents/pagesDocuments.js +64 -0
- package/src/dxp/private/documents/settingsDocuments.js +11 -0
- package/src/dxp/private/documents/tagDocuments.js +13 -0
- package/src/dxp/private/index.js +3 -0
- package/src/dxp/public/Articles.js +38 -0
- package/src/dxp/public/Dxp.js +19 -0
- package/src/dxp/public/DxpClient.js +40 -0
- package/src/dxp/public/DxpModel.js +44 -0
- package/src/dxp/public/Events.js +38 -0
- package/src/dxp/public/Pages.js +38 -0
- package/src/dxp/public/Redirects.js +23 -0
- package/src/dxp/public/Settings.js +21 -0
- package/src/dxp/public/Tags.js +24 -0
- package/src/dxp/public/documents.js +299 -0
- package/src/dxp/public/index.js +3 -0
- package/src/index.js +4 -0
- package/tsconfig.json +8 -0
package/package.json
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@raketa-cloud/next",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"main": "src/index.js",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"check-types": "tsc --noEmit"
|
|
7
|
+
},
|
|
8
|
+
"devDependencies": {
|
|
9
|
+
"@repo/typescript-config": "*",
|
|
10
|
+
"@turbo/gen": "^1.12.4",
|
|
11
|
+
"@types/node": "^20.11.24",
|
|
12
|
+
"@types/react": "18.3.0",
|
|
13
|
+
"@types/react-dom": "18.3.1",
|
|
14
|
+
"typescript": "5.5.4"
|
|
15
|
+
},
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"react": "^19.0.0",
|
|
18
|
+
"react-dom": "^19.0.0",
|
|
19
|
+
"graphql-request": "7.1.2",
|
|
20
|
+
"lru-cache": "11.0.2"
|
|
21
|
+
}
|
|
22
|
+
}
|
package/src/Cache.js
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { LRUCache } from "lru-cache";
|
|
2
|
+
|
|
3
|
+
const UNDEFINED_VALUE = Symbol("udef");
|
|
4
|
+
|
|
5
|
+
export default class Cache {
|
|
6
|
+
constructor(opts = {}) {
|
|
7
|
+
const cacheOptions = {
|
|
8
|
+
max: opts.max || 5000,
|
|
9
|
+
ttl: opts.ttl || 1000 * 60 * 2,
|
|
10
|
+
allowStale: true,
|
|
11
|
+
noDeleteOnStaleGet: true,
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
this.debugMode = opts.debugMode || false;
|
|
15
|
+
this.cacheInstance = new LRUCache({
|
|
16
|
+
...cacheOptions,
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
_debug(msg) {
|
|
21
|
+
if (this.debugMode) {
|
|
22
|
+
console.log(msg);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
_fetchFromCache(key) {
|
|
27
|
+
const status = {};
|
|
28
|
+
|
|
29
|
+
const cachedValue = this.cacheInstance.get(key, { status });
|
|
30
|
+
|
|
31
|
+
return {
|
|
32
|
+
cachedValue: cachedValue === UNDEFINED_VALUE ? null : cachedValue,
|
|
33
|
+
status,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
_cloneObject(obj) {
|
|
38
|
+
// Ah the JS world! See the official docs https://developer.mozilla.org/en-US/docs/Glossary/Deep_copy.
|
|
39
|
+
// Important note - this works only for objects with primitive types to copy. If an object property is
|
|
40
|
+
// a function - well it will not work correctly...
|
|
41
|
+
return JSON.parse(JSON.stringify(obj));
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
_setInCache(key, value) {
|
|
45
|
+
this.cacheInstance.set(
|
|
46
|
+
key,
|
|
47
|
+
value ? this._cloneObject(value) : UNDEFINED_VALUE
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
async fetch(cacheKey, fetcher) {
|
|
52
|
+
const { cachedValue, status } = this._fetchFromCache(cacheKey);
|
|
53
|
+
|
|
54
|
+
if (status.get === "hit") {
|
|
55
|
+
this._debug(`Cache HIT: ${cacheKey}`);
|
|
56
|
+
return this._cloneObject(cachedValue);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (status.get === "stale") {
|
|
60
|
+
this._debug(`Cache STALE: ${cacheKey}`);
|
|
61
|
+
|
|
62
|
+
try {
|
|
63
|
+
const freshEntity = await fetcher();
|
|
64
|
+
|
|
65
|
+
this._setInCache(cacheKey, freshEntity);
|
|
66
|
+
|
|
67
|
+
return this._cloneObject(freshEntity);
|
|
68
|
+
} catch (e) {
|
|
69
|
+
console.error(e);
|
|
70
|
+
|
|
71
|
+
// Reset TTL
|
|
72
|
+
this._setInCache(cacheKey, cachedValue);
|
|
73
|
+
|
|
74
|
+
return this._cloneObject(cachedValue);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
try {
|
|
79
|
+
this._debug(`Cache MISS: ${cacheKey}`);
|
|
80
|
+
|
|
81
|
+
const freshEntity = await fetcher();
|
|
82
|
+
|
|
83
|
+
this._setInCache(cacheKey, freshEntity);
|
|
84
|
+
|
|
85
|
+
return this._cloneObject(freshEntity);
|
|
86
|
+
} catch (e) {
|
|
87
|
+
console.error(e);
|
|
88
|
+
|
|
89
|
+
// Reset TTL
|
|
90
|
+
this._setInCache(cacheKey, cachedValue);
|
|
91
|
+
|
|
92
|
+
return this._cloneObject(cachedValue);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import DxpModel from "./DxpModel";
|
|
2
|
+
import {
|
|
3
|
+
ArticleChangePreviewDocument,
|
|
4
|
+
MiniArticlesDocument,
|
|
5
|
+
} from "./documents/articlesDocuments";
|
|
6
|
+
|
|
7
|
+
export default class Pages extends DxpModel {
|
|
8
|
+
async articleChangePreview(locale, id, version) {
|
|
9
|
+
const response = await this.client.query(ArticleChangePreviewDocument, {
|
|
10
|
+
input: {
|
|
11
|
+
locale,
|
|
12
|
+
articleId: id,
|
|
13
|
+
version,
|
|
14
|
+
},
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
return response?.articleChangePreview;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
async miniArticles(locale, input = {}) {
|
|
21
|
+
const response = await this.client.query(MiniArticlesDocument, {
|
|
22
|
+
input: {
|
|
23
|
+
locale,
|
|
24
|
+
...input,
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
return response?.miniArticles;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import DxpClient from "./DxpClient";
|
|
2
|
+
import Pages from "./Pages";
|
|
3
|
+
import Articles from "./Articles";
|
|
4
|
+
import Events from "./Events";
|
|
5
|
+
import Settings from "./Settings";
|
|
6
|
+
import Tags from "./Tags";
|
|
7
|
+
|
|
8
|
+
export default class Dxp {
|
|
9
|
+
constructor(getConfig, getToken) {
|
|
10
|
+
this.client = new DxpClient(getConfig, getToken);
|
|
11
|
+
this.pages = new Pages(this.client);
|
|
12
|
+
this.articles = new Articles(this.client);
|
|
13
|
+
this.events = new Events(this.client);
|
|
14
|
+
this.settings = new Settings(this.client);
|
|
15
|
+
this.tags = new Tags(this.client);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { gql, request } from "graphql-request";
|
|
2
|
+
|
|
3
|
+
export default class DxpClient {
|
|
4
|
+
constructor(getConfig, getToken) {
|
|
5
|
+
this.getConfig = getConfig;
|
|
6
|
+
this.getToken = getToken;
|
|
7
|
+
this.gql = gql;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
_gqlRequest(url, query, variables = {}, headers = {}) {
|
|
11
|
+
return request({
|
|
12
|
+
url,
|
|
13
|
+
document: query,
|
|
14
|
+
variables: variables,
|
|
15
|
+
requestHeaders: headers,
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
async query(query, variables = {}) {
|
|
20
|
+
const token = await this.getToken();
|
|
21
|
+
return this._gqlRequest(
|
|
22
|
+
`${this.getConfig().cloud.gateway_url}/dispatch`,
|
|
23
|
+
query,
|
|
24
|
+
variables,
|
|
25
|
+
{
|
|
26
|
+
"x-raketa-project": this.getConfig().cloud.gateway_project,
|
|
27
|
+
"x-raketa-service": this.getConfig().cloud.dxp_service_private,
|
|
28
|
+
"x-raketa-identity": token,
|
|
29
|
+
}
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import DxpModel from "./DxpModel";
|
|
2
|
+
import {
|
|
3
|
+
EventChangePreviewDocument,
|
|
4
|
+
MiniEventsDocument,
|
|
5
|
+
} from "./documents/eventsDocuments";
|
|
6
|
+
|
|
7
|
+
export default class Pages extends DxpModel {
|
|
8
|
+
async eventChangePreview(locale, id, version) {
|
|
9
|
+
const response = await this.client.query(EventChangePreviewDocument, {
|
|
10
|
+
input: {
|
|
11
|
+
locale,
|
|
12
|
+
eventId: id,
|
|
13
|
+
version,
|
|
14
|
+
},
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
return response?.eventChangePreview;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
async miniEvents(locale, input = {}) {
|
|
21
|
+
const response = await this.client.query(MiniEventsDocument, {
|
|
22
|
+
input: {
|
|
23
|
+
locale,
|
|
24
|
+
...input,
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
return response?.miniEvents;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import DxpModel from "./DxpModel";
|
|
2
|
+
import {
|
|
3
|
+
PageChangePreviewDocument,
|
|
4
|
+
MiniPagesDocument,
|
|
5
|
+
} from "./documents/pagesDocuments";
|
|
6
|
+
|
|
7
|
+
export default class Pages extends DxpModel {
|
|
8
|
+
async pageChangePreview(locale, id, version) {
|
|
9
|
+
const response = await this.client.query(PageChangePreviewDocument, {
|
|
10
|
+
input: {
|
|
11
|
+
locale,
|
|
12
|
+
pageId: id,
|
|
13
|
+
version,
|
|
14
|
+
},
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
return response?.pageChangePreview;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
async miniPages(locale, input = {}) {
|
|
21
|
+
const response = await this.client.query(MiniPagesDocument, {
|
|
22
|
+
input: {
|
|
23
|
+
locale,
|
|
24
|
+
...input,
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
return response?.miniPages;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import DxpModel from "./DxpModel";
|
|
2
|
+
import { SettingDocument } from "./documents/settingsDocuments";
|
|
3
|
+
|
|
4
|
+
export default class Settings extends DxpModel {
|
|
5
|
+
async find(locale) {
|
|
6
|
+
const response = await this.client.query(SettingDocument, {
|
|
7
|
+
locale,
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
return response?.setting;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import DxpModel from "./DxpModel";
|
|
2
|
+
import { TagsDocument } from "./documents/tagDocuments";
|
|
3
|
+
|
|
4
|
+
export default class Tags extends DxpModel {
|
|
5
|
+
async list(locale, input = {}) {
|
|
6
|
+
let inp = {};
|
|
7
|
+
|
|
8
|
+
if (input?.pagination?.page) {
|
|
9
|
+
inp = Object.assign({}, input, {
|
|
10
|
+
pagination: {
|
|
11
|
+
page: this.coercePageNumber(input.pagination?.page || 1),
|
|
12
|
+
pageSize: input.pagination?.pageSize || 12,
|
|
13
|
+
},
|
|
14
|
+
locale,
|
|
15
|
+
});
|
|
16
|
+
} else {
|
|
17
|
+
inp = { ...input, locale };
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const response = await this.client.query(TagsDocument, {
|
|
21
|
+
input: inp,
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
return response?.tags;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { gql } from "../../graphql";
|
|
2
|
+
import { tagFragment, categoryFragment, resourceTypeFragment } from "./common";
|
|
3
|
+
|
|
4
|
+
const ArticleByIdDocument = gql`
|
|
5
|
+
query ArticleByID($input: IdInput!) {
|
|
6
|
+
article(input: $input) {
|
|
7
|
+
id
|
|
8
|
+
slug
|
|
9
|
+
title
|
|
10
|
+
widgets
|
|
11
|
+
settings
|
|
12
|
+
visibility
|
|
13
|
+
publishAt
|
|
14
|
+
translations
|
|
15
|
+
tags ${tagFragment()}
|
|
16
|
+
categories ${categoryFragment()}
|
|
17
|
+
articleType ${resourceTypeFragment()}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
`;
|
|
21
|
+
|
|
22
|
+
const ArticleChangePreviewDocument = gql`
|
|
23
|
+
query ($input: ArticleChangePreviewInput!) {
|
|
24
|
+
articleChangePreview(input: $input) {
|
|
25
|
+
article {
|
|
26
|
+
id
|
|
27
|
+
slug
|
|
28
|
+
title
|
|
29
|
+
widgets
|
|
30
|
+
settings
|
|
31
|
+
visibility
|
|
32
|
+
publishAt
|
|
33
|
+
translations
|
|
34
|
+
websiteSettings
|
|
35
|
+
tags ${tagFragment()}
|
|
36
|
+
categories ${categoryFragment()}
|
|
37
|
+
articleType ${resourceTypeFragment()}
|
|
38
|
+
}
|
|
39
|
+
articleChange {
|
|
40
|
+
version
|
|
41
|
+
title
|
|
42
|
+
description
|
|
43
|
+
operator
|
|
44
|
+
operatorMeta
|
|
45
|
+
source
|
|
46
|
+
insertedAt
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
`;
|
|
51
|
+
|
|
52
|
+
const MiniArticlesDocument = gql`
|
|
53
|
+
query ($input: ArticlesInput!) {
|
|
54
|
+
miniArticles(input: $input) {
|
|
55
|
+
list {
|
|
56
|
+
id
|
|
57
|
+
slug
|
|
58
|
+
title
|
|
59
|
+
visibility
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
`;
|
|
64
|
+
|
|
65
|
+
export {
|
|
66
|
+
ArticleByIdDocument,
|
|
67
|
+
ArticleChangePreviewDocument,
|
|
68
|
+
MiniArticlesDocument,
|
|
69
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { gql } from "../../graphql";
|
|
2
|
+
|
|
3
|
+
export function tagFragment() {
|
|
4
|
+
return gql`
|
|
5
|
+
{
|
|
6
|
+
id
|
|
7
|
+
name
|
|
8
|
+
slug
|
|
9
|
+
}
|
|
10
|
+
`;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function categoryFragment() {
|
|
14
|
+
return gql`
|
|
15
|
+
{
|
|
16
|
+
id
|
|
17
|
+
type
|
|
18
|
+
slug
|
|
19
|
+
name
|
|
20
|
+
settings
|
|
21
|
+
}
|
|
22
|
+
`;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function resourceTypeFragment() {
|
|
26
|
+
return gql`
|
|
27
|
+
{
|
|
28
|
+
id
|
|
29
|
+
slug
|
|
30
|
+
title
|
|
31
|
+
}
|
|
32
|
+
`;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function paginationFragment() {
|
|
36
|
+
return gql`
|
|
37
|
+
{
|
|
38
|
+
currentPage
|
|
39
|
+
pagesCount
|
|
40
|
+
entriesCount
|
|
41
|
+
pageSize
|
|
42
|
+
}
|
|
43
|
+
`;
|
|
44
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { gql } from "../../graphql";
|
|
2
|
+
import { tagFragment, categoryFragment, resourceTypeFragment } from "./common";
|
|
3
|
+
|
|
4
|
+
const EventByIdDocument = gql`
|
|
5
|
+
query EventByID($input: IdInput!) {
|
|
6
|
+
event(input: $input) {
|
|
7
|
+
id
|
|
8
|
+
slug
|
|
9
|
+
title
|
|
10
|
+
widgets
|
|
11
|
+
settings
|
|
12
|
+
visibility
|
|
13
|
+
publishAt
|
|
14
|
+
startsAt
|
|
15
|
+
endsAt
|
|
16
|
+
translations
|
|
17
|
+
tags ${tagFragment()}
|
|
18
|
+
categories ${categoryFragment()}
|
|
19
|
+
eventType ${resourceTypeFragment()}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
`;
|
|
23
|
+
|
|
24
|
+
const EventChangePreviewDocument = gql`
|
|
25
|
+
query ($input: EventChangePreviewInput!) {
|
|
26
|
+
eventChangePreview(input: $input) {
|
|
27
|
+
event {
|
|
28
|
+
id
|
|
29
|
+
slug
|
|
30
|
+
title
|
|
31
|
+
widgets
|
|
32
|
+
settings
|
|
33
|
+
visibility
|
|
34
|
+
publishAt
|
|
35
|
+
startsAt
|
|
36
|
+
endsAt
|
|
37
|
+
translations
|
|
38
|
+
websiteSettings
|
|
39
|
+
tags ${tagFragment()}
|
|
40
|
+
categories ${categoryFragment()}
|
|
41
|
+
eventType ${resourceTypeFragment()}
|
|
42
|
+
}
|
|
43
|
+
eventChange {
|
|
44
|
+
version
|
|
45
|
+
title
|
|
46
|
+
description
|
|
47
|
+
operator
|
|
48
|
+
operatorMeta
|
|
49
|
+
source
|
|
50
|
+
insertedAt
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
`;
|
|
55
|
+
|
|
56
|
+
const MiniEventsDocument = gql`
|
|
57
|
+
query ($input: EventsInput!) {
|
|
58
|
+
miniEvents(input: $input) {
|
|
59
|
+
list {
|
|
60
|
+
id
|
|
61
|
+
slug
|
|
62
|
+
title
|
|
63
|
+
visibility
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
`;
|
|
68
|
+
|
|
69
|
+
export { EventByIdDocument, EventChangePreviewDocument, MiniEventsDocument };
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { gql } from "../../graphql";
|
|
2
|
+
import { tagFragment, categoryFragment, resourceTypeFragment } from "./common";
|
|
3
|
+
|
|
4
|
+
const PageByIdDocument = gql`
|
|
5
|
+
query PageByID($input: IdInput!) {
|
|
6
|
+
page(input: $input) {
|
|
7
|
+
id
|
|
8
|
+
slug
|
|
9
|
+
title
|
|
10
|
+
widgets
|
|
11
|
+
settings
|
|
12
|
+
visibility
|
|
13
|
+
translations
|
|
14
|
+
revisionsCount
|
|
15
|
+
tags ${tagFragment()}
|
|
16
|
+
categories ${categoryFragment()}
|
|
17
|
+
pageType ${resourceTypeFragment()}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
`;
|
|
21
|
+
|
|
22
|
+
const PageChangePreviewDocument = gql`
|
|
23
|
+
query ($input: PageChangePreviewInput!) {
|
|
24
|
+
pageChangePreview(input: $input) {
|
|
25
|
+
page {
|
|
26
|
+
id
|
|
27
|
+
slug
|
|
28
|
+
title
|
|
29
|
+
widgets
|
|
30
|
+
settings
|
|
31
|
+
visibility
|
|
32
|
+
translations
|
|
33
|
+
websiteSettings
|
|
34
|
+
tags ${tagFragment()}
|
|
35
|
+
categories ${categoryFragment()}
|
|
36
|
+
pageType ${resourceTypeFragment()}
|
|
37
|
+
}
|
|
38
|
+
pageChange {
|
|
39
|
+
version
|
|
40
|
+
title
|
|
41
|
+
description
|
|
42
|
+
operator
|
|
43
|
+
operatorMeta
|
|
44
|
+
source
|
|
45
|
+
insertedAt
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
`;
|
|
50
|
+
|
|
51
|
+
const MiniPagesDocument = gql`
|
|
52
|
+
query ($input: PagesInput!) {
|
|
53
|
+
miniPages(input: $input) {
|
|
54
|
+
list {
|
|
55
|
+
id
|
|
56
|
+
slug
|
|
57
|
+
title
|
|
58
|
+
visibility
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
`;
|
|
63
|
+
|
|
64
|
+
export { PageByIdDocument, PageChangePreviewDocument, MiniPagesDocument };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { gql } from "../../graphql";
|
|
2
|
+
import { tagFragment, paginationFragment } from "./common";
|
|
3
|
+
|
|
4
|
+
const TagsDocument = gql`
|
|
5
|
+
query Tags($input: TagsInput!) {
|
|
6
|
+
tags(input: $input) {
|
|
7
|
+
list ${tagFragment()}
|
|
8
|
+
pagination ${paginationFragment()}
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
`;
|
|
12
|
+
|
|
13
|
+
export { TagsDocument };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import DxpModel from "./DxpModel";
|
|
2
|
+
import { ArticleBySlugDocument, ArticlesDocument } from "./documents";
|
|
3
|
+
|
|
4
|
+
export default class Articles extends DxpModel {
|
|
5
|
+
async find(locale, slug, opts = {}) {
|
|
6
|
+
const response = await this.fetch(
|
|
7
|
+
`article-${locale}-${slug}`,
|
|
8
|
+
async () =>
|
|
9
|
+
await this.client.query(
|
|
10
|
+
ArticleBySlugDocument,
|
|
11
|
+
{
|
|
12
|
+
input: {
|
|
13
|
+
locale,
|
|
14
|
+
slug,
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
opts
|
|
18
|
+
),
|
|
19
|
+
opts
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
return response?.article;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
async list(locale, input = {}, opts = {}) {
|
|
26
|
+
const response = await this.fetch(
|
|
27
|
+
`articles-${locale}-${JSON.stringify(input)}`,
|
|
28
|
+
async () =>
|
|
29
|
+
await this.client.query(
|
|
30
|
+
ArticlesDocument,
|
|
31
|
+
this.formatPaginationInInput(locale, input),
|
|
32
|
+
opts
|
|
33
|
+
)
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
return response?.articles;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import DxpClient from "./DxpClient";
|
|
2
|
+
import Pages from "./Pages";
|
|
3
|
+
import Articles from "./Articles";
|
|
4
|
+
import Events from "./Events";
|
|
5
|
+
import Settings from "./Settings";
|
|
6
|
+
import Tags from "./Tags";
|
|
7
|
+
import Redirects from "./Redirects";
|
|
8
|
+
|
|
9
|
+
export default class Dxp {
|
|
10
|
+
constructor(getConfig, cache) {
|
|
11
|
+
this.client = new DxpClient(getConfig);
|
|
12
|
+
this.pages = new Pages(this.client, cache);
|
|
13
|
+
this.articles = new Articles(this.client, cache);
|
|
14
|
+
this.events = new Events(this.client, cache);
|
|
15
|
+
this.setttings = new Settings(this.client, cache);
|
|
16
|
+
this.tags = new Tags(this.client, cache);
|
|
17
|
+
this.redirects = new Redirects(this.client, cache);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { gql, request } from "graphql-request";
|
|
2
|
+
|
|
3
|
+
export default class DxpClient {
|
|
4
|
+
constructor(getConfig) {
|
|
5
|
+
this.getConfig = getConfig;
|
|
6
|
+
this.gql = gql;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
_gqlRequest(url, query, variables = {}, headers = {}) {
|
|
10
|
+
return request({
|
|
11
|
+
url,
|
|
12
|
+
document: query,
|
|
13
|
+
variables: variables,
|
|
14
|
+
requestHeaders: headers,
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
async query(query, variables = {}, opts = {}) {
|
|
19
|
+
if (opts.withProxy) {
|
|
20
|
+
// TODO: Maybe the endpoint can be configurable?
|
|
21
|
+
return fetch("/api/data", {
|
|
22
|
+
method: "POST",
|
|
23
|
+
headers: {
|
|
24
|
+
"content-type": "application/json",
|
|
25
|
+
},
|
|
26
|
+
body: JSON.stringify({ query, variables }),
|
|
27
|
+
}).then((r) => r.json());
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return this._gqlRequest(
|
|
31
|
+
`${this.getConfig().cloud.gateway_url}/dispatch`,
|
|
32
|
+
query,
|
|
33
|
+
variables,
|
|
34
|
+
{
|
|
35
|
+
"x-raketa-project": this.getConfig().cloud.gateway_project,
|
|
36
|
+
"x-raketa-service": this.getConfig().cloud.dxp_service_public,
|
|
37
|
+
}
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export default class DxpModel {
|
|
2
|
+
constructor(client, cache) {
|
|
3
|
+
this.client = client;
|
|
4
|
+
this.cache = cache;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
async fetch(cacheKey, fetcher, opts = {}) {
|
|
8
|
+
if (opts.withCache && this.cache) {
|
|
9
|
+
return this.cache.fetch(cacheKey, fetcher);
|
|
10
|
+
} else {
|
|
11
|
+
return fetcher();
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
coercePageNumber(maybeNum) {
|
|
16
|
+
const parsed = Number.parseInt(maybeNum, 10);
|
|
17
|
+
|
|
18
|
+
if (Number.isNaN(parsed)) {
|
|
19
|
+
return 1;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
if (parsed <= 0) {
|
|
23
|
+
return 1;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return parsed;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
formatPaginationInInput(locale, input) {
|
|
30
|
+
if (input?.pagination?.page) {
|
|
31
|
+
return {
|
|
32
|
+
input: Object.assign({}, input, {
|
|
33
|
+
pagination: {
|
|
34
|
+
page: this.coercePageNumber(input.pagination?.page || 1),
|
|
35
|
+
pageSize: input.pagination?.pageSize || 12,
|
|
36
|
+
},
|
|
37
|
+
locale,
|
|
38
|
+
}),
|
|
39
|
+
};
|
|
40
|
+
} else {
|
|
41
|
+
return { input: { ...input, locale } };
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import DxpModel from "./DxpModel";
|
|
2
|
+
import { EventBySlugDocument, EventsDocument } from "./documents";
|
|
3
|
+
|
|
4
|
+
export default class Events extends DxpModel {
|
|
5
|
+
async find(locale, slug, opts = {}) {
|
|
6
|
+
const response = await this.fetch(
|
|
7
|
+
`event-${locale}-${slug}`,
|
|
8
|
+
async () =>
|
|
9
|
+
await this.client.query(
|
|
10
|
+
EventBySlugDocument,
|
|
11
|
+
{
|
|
12
|
+
input: {
|
|
13
|
+
locale,
|
|
14
|
+
slug,
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
opts
|
|
18
|
+
),
|
|
19
|
+
opts
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
return response?.event;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
async list(locale, input = {}, opts = {}) {
|
|
26
|
+
const response = await this.fetch(
|
|
27
|
+
`events-${locale}-${JSON.stringify(input)}`,
|
|
28
|
+
async () =>
|
|
29
|
+
await this.client.query(
|
|
30
|
+
EventsDocument,
|
|
31
|
+
this.formatPaginationInInput(locale, input),
|
|
32
|
+
opts
|
|
33
|
+
)
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
return response?.events;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import DxpModel from "./DxpModel";
|
|
2
|
+
import { PageBySlugDocument, PagesDocument } from "./documents";
|
|
3
|
+
|
|
4
|
+
export default class Pages extends DxpModel {
|
|
5
|
+
async find(locale, slug, opts = {}) {
|
|
6
|
+
const response = await this.fetch(
|
|
7
|
+
`page-${locale}-${slug}`,
|
|
8
|
+
async () =>
|
|
9
|
+
await this.client.query(
|
|
10
|
+
PageBySlugDocument,
|
|
11
|
+
{
|
|
12
|
+
input: {
|
|
13
|
+
locale,
|
|
14
|
+
slug,
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
opts
|
|
18
|
+
),
|
|
19
|
+
opts
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
return response?.page;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
async list(locale, input = {}, opts = {}) {
|
|
26
|
+
const response = await this.fetch(
|
|
27
|
+
`pages-${locale}-${JSON.stringify(input)}`,
|
|
28
|
+
async () =>
|
|
29
|
+
await this.client.query(
|
|
30
|
+
PagesDocument,
|
|
31
|
+
this.formatPaginationInInput(locale, input),
|
|
32
|
+
opts
|
|
33
|
+
)
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
return response?.pages;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import DxpModel from "./DxpModel";
|
|
2
|
+
import { RedirectDocument } from "./documents";
|
|
3
|
+
|
|
4
|
+
export default class Redirects extends DxpModel {
|
|
5
|
+
async find(url, opts = {}) {
|
|
6
|
+
const response = await this.fetch(
|
|
7
|
+
`redirect-${url}`,
|
|
8
|
+
async () =>
|
|
9
|
+
await this.client.query(
|
|
10
|
+
RedirectDocument,
|
|
11
|
+
{
|
|
12
|
+
input: {
|
|
13
|
+
url,
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
opts
|
|
17
|
+
),
|
|
18
|
+
opts
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
return response?.redirect;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import DxpModel from "./DxpModel";
|
|
2
|
+
import { SettingDocument } from "./documents";
|
|
3
|
+
|
|
4
|
+
export default class Settings extends DxpModel {
|
|
5
|
+
async find(locale, opts = {}) {
|
|
6
|
+
const response = await this.fetch(
|
|
7
|
+
`website-settings-${locale}`,
|
|
8
|
+
async () =>
|
|
9
|
+
await this.client.query(
|
|
10
|
+
SettingDocument,
|
|
11
|
+
{
|
|
12
|
+
locale,
|
|
13
|
+
},
|
|
14
|
+
opts
|
|
15
|
+
),
|
|
16
|
+
opts
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
return response?.setting;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import DxpModel from "./DxpModel";
|
|
2
|
+
import { TagBySlugDocument } from "./documents";
|
|
3
|
+
|
|
4
|
+
export default class Tags extends DxpModel {
|
|
5
|
+
async find(locale, slug, opts = {}) {
|
|
6
|
+
const response = await this.fetch(
|
|
7
|
+
`tag-${locale}-${slug}`,
|
|
8
|
+
async () =>
|
|
9
|
+
await this.client.query(
|
|
10
|
+
TagBySlugDocument,
|
|
11
|
+
{
|
|
12
|
+
input: {
|
|
13
|
+
locale,
|
|
14
|
+
slug,
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
opts
|
|
18
|
+
),
|
|
19
|
+
opts
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
return response?.tag;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
import { gql } from "../graphql";
|
|
2
|
+
|
|
3
|
+
function tagFragment() {
|
|
4
|
+
return gql`
|
|
5
|
+
{
|
|
6
|
+
id
|
|
7
|
+
name
|
|
8
|
+
slug
|
|
9
|
+
}
|
|
10
|
+
`;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function revisionFragment() {
|
|
14
|
+
return gql`
|
|
15
|
+
{
|
|
16
|
+
id
|
|
17
|
+
title
|
|
18
|
+
slug
|
|
19
|
+
settings
|
|
20
|
+
widgets
|
|
21
|
+
visibility
|
|
22
|
+
}
|
|
23
|
+
`;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function paginationFragment() {
|
|
27
|
+
return gql`
|
|
28
|
+
{
|
|
29
|
+
currentPage
|
|
30
|
+
pagesCount
|
|
31
|
+
entriesCount
|
|
32
|
+
pageSize
|
|
33
|
+
}
|
|
34
|
+
`;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function resourceTypeFragment() {
|
|
38
|
+
return gql`
|
|
39
|
+
{
|
|
40
|
+
id
|
|
41
|
+
slug
|
|
42
|
+
title
|
|
43
|
+
}
|
|
44
|
+
`;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function categoryFragment() {
|
|
48
|
+
return gql`
|
|
49
|
+
{
|
|
50
|
+
type
|
|
51
|
+
slug
|
|
52
|
+
name
|
|
53
|
+
settings
|
|
54
|
+
}
|
|
55
|
+
`;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const CategoriesDocument = gql`
|
|
59
|
+
query Categories($input: CategoriesInput!) {
|
|
60
|
+
categories(input: $input) {
|
|
61
|
+
list ${categoryFragment()}
|
|
62
|
+
pagination ${paginationFragment()}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
`;
|
|
66
|
+
|
|
67
|
+
const ArticlesDocument = gql`
|
|
68
|
+
query Articles($input: ArticlesInput!) {
|
|
69
|
+
articles(input: $input) {
|
|
70
|
+
list {
|
|
71
|
+
id
|
|
72
|
+
slug
|
|
73
|
+
title
|
|
74
|
+
widgets
|
|
75
|
+
settings
|
|
76
|
+
publishAt
|
|
77
|
+
visibility
|
|
78
|
+
tags ${tagFragment()}
|
|
79
|
+
categories ${categoryFragment()}
|
|
80
|
+
articleType ${resourceTypeFragment()}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
pagination ${paginationFragment()}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
`;
|
|
87
|
+
|
|
88
|
+
const PageBySlugDocument = gql`
|
|
89
|
+
query PageBySlug($input: SlugInput!) {
|
|
90
|
+
page(input: $input) {
|
|
91
|
+
id
|
|
92
|
+
title
|
|
93
|
+
slug
|
|
94
|
+
settings
|
|
95
|
+
widgets
|
|
96
|
+
websiteSettings
|
|
97
|
+
createdAt
|
|
98
|
+
updatedAt
|
|
99
|
+
visibility
|
|
100
|
+
translations
|
|
101
|
+
pageType ${resourceTypeFragment()}
|
|
102
|
+
categories ${categoryFragment()}
|
|
103
|
+
tags ${tagFragment()}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
`;
|
|
107
|
+
|
|
108
|
+
const PageRevisionPreviewDocument = gql`
|
|
109
|
+
query ($input: RevisionPreviewInput!) {
|
|
110
|
+
pageRevisionPreview(input: $input) {
|
|
111
|
+
page {
|
|
112
|
+
id
|
|
113
|
+
title
|
|
114
|
+
slug
|
|
115
|
+
settings
|
|
116
|
+
widgets
|
|
117
|
+
websiteSettings
|
|
118
|
+
createdAt
|
|
119
|
+
updatedAt
|
|
120
|
+
visibility
|
|
121
|
+
translations
|
|
122
|
+
pageType ${resourceTypeFragment()}
|
|
123
|
+
categories ${categoryFragment()}
|
|
124
|
+
tags ${tagFragment()}
|
|
125
|
+
}
|
|
126
|
+
revision ${revisionFragment()}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
`;
|
|
130
|
+
|
|
131
|
+
const PagesDocument = gql`
|
|
132
|
+
query Pages($input: PagesInput!) {
|
|
133
|
+
pages(input: $input) {
|
|
134
|
+
list {
|
|
135
|
+
id
|
|
136
|
+
slug
|
|
137
|
+
title
|
|
138
|
+
widgets
|
|
139
|
+
settings
|
|
140
|
+
visibility
|
|
141
|
+
pageType ${resourceTypeFragment()}
|
|
142
|
+
categories ${categoryFragment()}
|
|
143
|
+
tags ${tagFragment()}
|
|
144
|
+
}
|
|
145
|
+
pagination ${paginationFragment()}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
`;
|
|
149
|
+
|
|
150
|
+
const ArticleBySlugDocument = gql`
|
|
151
|
+
query ArticleBySlug($input: SlugInput!) {
|
|
152
|
+
article(input: $input) {
|
|
153
|
+
id
|
|
154
|
+
title
|
|
155
|
+
slug
|
|
156
|
+
settings
|
|
157
|
+
widgets
|
|
158
|
+
publishAt
|
|
159
|
+
updatedAt
|
|
160
|
+
websiteSettings
|
|
161
|
+
visibility
|
|
162
|
+
translations
|
|
163
|
+
articleType ${resourceTypeFragment()}
|
|
164
|
+
categories ${categoryFragment()}
|
|
165
|
+
tags ${tagFragment()}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
`;
|
|
169
|
+
|
|
170
|
+
const ArticleRevisionPreviewDocument = gql`
|
|
171
|
+
query ($input: RevisionPreviewInput!) {
|
|
172
|
+
articleRevisionPreview(input: $input) {
|
|
173
|
+
article {
|
|
174
|
+
id
|
|
175
|
+
title
|
|
176
|
+
slug
|
|
177
|
+
settings
|
|
178
|
+
widgets
|
|
179
|
+
publishAt
|
|
180
|
+
websiteSettings
|
|
181
|
+
visibility
|
|
182
|
+
translations
|
|
183
|
+
articleType ${resourceTypeFragment()}
|
|
184
|
+
categories ${categoryFragment()}
|
|
185
|
+
tags ${tagFragment()}
|
|
186
|
+
}
|
|
187
|
+
revision ${revisionFragment()}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
`;
|
|
191
|
+
|
|
192
|
+
const SettingDocument = gql`
|
|
193
|
+
query Setting($locale: String!) {
|
|
194
|
+
setting(locale: $locale) {
|
|
195
|
+
value
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
`;
|
|
199
|
+
|
|
200
|
+
const TagBySlugDocument = gql`
|
|
201
|
+
query TagBySlug($input: SlugInput!) {
|
|
202
|
+
tag(input: $input) {
|
|
203
|
+
name
|
|
204
|
+
slug
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
`;
|
|
208
|
+
|
|
209
|
+
const EventsDocument = gql`
|
|
210
|
+
query Events($input: EventsInput!) {
|
|
211
|
+
events(input: $input) {
|
|
212
|
+
list {
|
|
213
|
+
id
|
|
214
|
+
slug
|
|
215
|
+
title
|
|
216
|
+
widgets
|
|
217
|
+
settings
|
|
218
|
+
publishAt
|
|
219
|
+
startsAt
|
|
220
|
+
endsAt
|
|
221
|
+
visibility
|
|
222
|
+
eventType ${resourceTypeFragment()}
|
|
223
|
+
categories ${categoryFragment()}
|
|
224
|
+
tags ${tagFragment()}
|
|
225
|
+
}
|
|
226
|
+
pagination ${paginationFragment()}
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
`;
|
|
230
|
+
|
|
231
|
+
const EventBySlugDocument = gql`
|
|
232
|
+
query EventBySlug($input: SlugInput!) {
|
|
233
|
+
event(input: $input) {
|
|
234
|
+
id
|
|
235
|
+
title
|
|
236
|
+
slug
|
|
237
|
+
settings
|
|
238
|
+
widgets
|
|
239
|
+
publishAt
|
|
240
|
+
startsAt
|
|
241
|
+
endsAt
|
|
242
|
+
websiteSettings
|
|
243
|
+
visibility
|
|
244
|
+
translations
|
|
245
|
+
eventType ${resourceTypeFragment()}
|
|
246
|
+
categories ${categoryFragment()}
|
|
247
|
+
tags ${tagFragment()}
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
`;
|
|
251
|
+
|
|
252
|
+
const EventRevisionPreviewDocument = gql`
|
|
253
|
+
query ($input: RevisionPreviewInput!) {
|
|
254
|
+
eventRevisionPreview(input: $input) {
|
|
255
|
+
event {
|
|
256
|
+
id
|
|
257
|
+
title
|
|
258
|
+
slug
|
|
259
|
+
settings
|
|
260
|
+
widgets
|
|
261
|
+
publishAt
|
|
262
|
+
websiteSettings
|
|
263
|
+
visibility
|
|
264
|
+
translations
|
|
265
|
+
eventType ${resourceTypeFragment()}
|
|
266
|
+
categories ${categoryFragment()}
|
|
267
|
+
tags ${tagFragment()}
|
|
268
|
+
}
|
|
269
|
+
revision ${revisionFragment()}
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
`;
|
|
273
|
+
|
|
274
|
+
const RedirectDocument = gql`
|
|
275
|
+
query ($input: UrlInput!) {
|
|
276
|
+
redirect(input: $input) {
|
|
277
|
+
id
|
|
278
|
+
url
|
|
279
|
+
destination
|
|
280
|
+
httpResponseCode
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
`;
|
|
284
|
+
|
|
285
|
+
export {
|
|
286
|
+
ArticlesDocument,
|
|
287
|
+
ArticleBySlugDocument,
|
|
288
|
+
ArticleRevisionPreviewDocument,
|
|
289
|
+
PagesDocument,
|
|
290
|
+
PageBySlugDocument,
|
|
291
|
+
PageRevisionPreviewDocument,
|
|
292
|
+
EventsDocument,
|
|
293
|
+
EventBySlugDocument,
|
|
294
|
+
EventRevisionPreviewDocument,
|
|
295
|
+
SettingDocument,
|
|
296
|
+
CategoriesDocument,
|
|
297
|
+
TagBySlugDocument,
|
|
298
|
+
RedirectDocument,
|
|
299
|
+
};
|
package/src/index.js
ADDED