@webiny/website-builder-sdk 0.0.0-unstable.fdd9228b5d → 6.0.0-alpha.2
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/ContentSdk.d.ts +11 -5
- package/ContentSdk.js +18 -2
- package/ContentSdk.js.map +1 -1
- package/IRedirects.d.ts +5 -0
- package/IRedirects.js +3 -0
- package/IRedirects.js.map +1 -0
- package/NullSdk.d.ts +2 -1
- package/NullSdk.js +3 -0
- package/NullSdk.js.map +1 -1
- package/dataProviders/DefaultDataProvider.d.ts +1 -0
- package/dataProviders/DefaultDataProvider.js +8 -0
- package/dataProviders/DefaultDataProvider.js.map +1 -1
- package/dataProviders/GET_ACTIVE_REDIRECTS.d.ts +1 -0
- package/dataProviders/GET_ACTIVE_REDIRECTS.js +21 -0
- package/dataProviders/GET_ACTIVE_REDIRECTS.js.map +1 -0
- package/dataProviders/NullDataProvider.d.ts +2 -1
- package/dataProviders/NullDataProvider.js +3 -0
- package/dataProviders/NullDataProvider.js.map +1 -1
- package/dataProviders/RedirectsProvider.d.ts +11 -0
- package/dataProviders/RedirectsProvider.js +33 -0
- package/dataProviders/RedirectsProvider.js.map +1 -0
- package/package.json +4 -4
- package/types.d.ts +6 -0
- package/types.js.map +1 -1
package/ContentSdk.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import type { Component, IContentSdk, PublicPage, ResolvedComponent } from "./types";
|
|
1
|
+
import type { Component, IContentSdk, PublicPage, PublicRedirect, ResolvedComponent } from "./types";
|
|
2
2
|
import { LiveSdk } from "./LiveSdk.js";
|
|
3
3
|
import { EditingSdk } from "./EditingSdk.js";
|
|
4
|
-
import type
|
|
4
|
+
import { type ResolveElementParams } from "./ComponentResolver";
|
|
5
5
|
import type { WebsiteBuilderThemeInput } from "./types/WebsiteBuilderTheme.js";
|
|
6
|
+
import type { IRedirects } from "./IRedirects";
|
|
6
7
|
export type ApiConfig = {
|
|
7
8
|
apiKey: string;
|
|
8
9
|
apiHost: string;
|
|
@@ -12,15 +13,18 @@ export type ContentSDKConfig = ApiConfig & {
|
|
|
12
13
|
preview?: boolean;
|
|
13
14
|
theme?: WebsiteBuilderThemeInput;
|
|
14
15
|
};
|
|
15
|
-
declare class InternalContentSdk implements IContentSdk {
|
|
16
|
+
declare class InternalContentSdk implements IContentSdk, IRedirects {
|
|
16
17
|
private activeSdk;
|
|
17
18
|
private editingSdk;
|
|
18
|
-
|
|
19
|
+
private redirectsProvider;
|
|
20
|
+
constructor(redirectsProvider: IRedirects, liveSdk: LiveSdk, editingSdk?: EditingSdk);
|
|
19
21
|
getEditingSdk(): EditingSdk | undefined;
|
|
20
22
|
getPage(path: string): Promise<PublicPage | null>;
|
|
21
23
|
listPages(): Promise<PublicPage[]>;
|
|
24
|
+
getAllRedirects(): Promise<Map<string, PublicRedirect>>;
|
|
25
|
+
getRedirectByPath(path: string): Promise<PublicRedirect | undefined>;
|
|
22
26
|
}
|
|
23
|
-
export declare class ContentSdk implements IContentSdk {
|
|
27
|
+
export declare class ContentSdk implements IContentSdk, IRedirects {
|
|
24
28
|
protected sdk?: InternalContentSdk;
|
|
25
29
|
private isPreview;
|
|
26
30
|
private lastConfig;
|
|
@@ -28,6 +32,8 @@ export declare class ContentSdk implements IContentSdk {
|
|
|
28
32
|
getEditingSdk(): EditingSdk | undefined;
|
|
29
33
|
getPage(path: string): Promise<PublicPage | null>;
|
|
30
34
|
listPages(): Promise<PublicPage[]>;
|
|
35
|
+
getAllRedirects(): Promise<Map<string, PublicRedirect>>;
|
|
36
|
+
getRedirectByPath(path: string): Promise<PublicRedirect | undefined>;
|
|
31
37
|
registerComponent(blueprint: Component): void;
|
|
32
38
|
resolveElement(params: ResolveElementParams): ResolvedComponent[] | null;
|
|
33
39
|
isEditing(): boolean;
|
package/ContentSdk.js
CHANGED
|
@@ -8,8 +8,10 @@ import { ApiClient } from "./dataProviders/ApiClient";
|
|
|
8
8
|
import { DefaultDataProvider } from "./dataProviders/DefaultDataProvider";
|
|
9
9
|
import { Theme } from "./Theme.js";
|
|
10
10
|
import { viewportManager } from "./ViewportManager.js";
|
|
11
|
+
import { RedirectsProvider } from "./dataProviders/RedirectsProvider";
|
|
11
12
|
class InternalContentSdk {
|
|
12
|
-
constructor(liveSdk, editingSdk) {
|
|
13
|
+
constructor(redirectsProvider, liveSdk, editingSdk) {
|
|
14
|
+
this.redirectsProvider = redirectsProvider;
|
|
13
15
|
this.activeSdk = editingSdk ?? liveSdk;
|
|
14
16
|
this.editingSdk = editingSdk;
|
|
15
17
|
}
|
|
@@ -22,6 +24,12 @@ class InternalContentSdk {
|
|
|
22
24
|
listPages() {
|
|
23
25
|
return this.activeSdk.listPages();
|
|
24
26
|
}
|
|
27
|
+
getAllRedirects() {
|
|
28
|
+
return this.redirectsProvider.getAllRedirects();
|
|
29
|
+
}
|
|
30
|
+
getRedirectByPath(path) {
|
|
31
|
+
return this.redirectsProvider.getRedirectByPath(path);
|
|
32
|
+
}
|
|
25
33
|
}
|
|
26
34
|
export class ContentSdk {
|
|
27
35
|
isPreview = false;
|
|
@@ -48,7 +56,7 @@ export class ContentSdk {
|
|
|
48
56
|
if (environment.isEditing()) {
|
|
49
57
|
editingSdk = new EditingSdk(liveSdk, theme);
|
|
50
58
|
}
|
|
51
|
-
this.sdk = new InternalContentSdk(liveSdk, editingSdk);
|
|
59
|
+
this.sdk = new InternalContentSdk(new RedirectsProvider(apiClient), liveSdk, editingSdk);
|
|
52
60
|
if (typeof afterInit === "function") {
|
|
53
61
|
afterInit();
|
|
54
62
|
}
|
|
@@ -65,6 +73,14 @@ export class ContentSdk {
|
|
|
65
73
|
this.assertInitialized();
|
|
66
74
|
return this.sdk.listPages();
|
|
67
75
|
}
|
|
76
|
+
async getAllRedirects() {
|
|
77
|
+
this.assertInitialized();
|
|
78
|
+
return this.sdk.getAllRedirects();
|
|
79
|
+
}
|
|
80
|
+
getRedirectByPath(path) {
|
|
81
|
+
this.assertInitialized();
|
|
82
|
+
return this.sdk.getRedirectByPath(path);
|
|
83
|
+
}
|
|
68
84
|
registerComponent(blueprint) {
|
|
69
85
|
this.assertInitialized();
|
|
70
86
|
componentRegistry.register(blueprint);
|
package/ContentSdk.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["environment","LiveSdk","EditingSdk","ComponentResolver","PreviewSdk","componentRegistry","ApiClient","DefaultDataProvider","Theme","viewportManager","InternalContentSdk","constructor","liveSdk","editingSdk","activeSdk","getEditingSdk","getPage","path","listPages","ContentSdk","isPreview","init","config","afterInit","configHash","JSON","stringify","lastConfig","apiClient","apiHost","apiKey","apiTenant","dataProvider","preview","isEditing","theme","from","isClient","setBreakpoints","breakpoints","sdk","assertInitialized","registerComponent","blueprint","register","resolveElement","params","resolve","isPreviewing","Error","contentSdk"],"sources":["ContentSdk.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"names":["environment","LiveSdk","EditingSdk","ComponentResolver","PreviewSdk","componentRegistry","ApiClient","DefaultDataProvider","Theme","viewportManager","RedirectsProvider","InternalContentSdk","constructor","redirectsProvider","liveSdk","editingSdk","activeSdk","getEditingSdk","getPage","path","listPages","getAllRedirects","getRedirectByPath","ContentSdk","isPreview","init","config","afterInit","configHash","JSON","stringify","lastConfig","apiClient","apiHost","apiKey","apiTenant","dataProvider","preview","isEditing","theme","from","isClient","setBreakpoints","breakpoints","sdk","assertInitialized","registerComponent","blueprint","register","resolveElement","params","resolve","isPreviewing","Error","contentSdk"],"sources":["ContentSdk.ts"],"sourcesContent":["import type {\n Component,\n IContentSdk,\n PublicPage,\n PublicRedirect,\n ResolvedComponent\n} from \"~/types\";\nimport { environment } from \"./Environment.js\";\nimport { LiveSdk } from \"./LiveSdk.js\";\nimport { EditingSdk } from \"./EditingSdk.js\";\nimport { ComponentResolver, type ResolveElementParams } from \"~/ComponentResolver\";\nimport { PreviewSdk } from \"./PreviewSdk.js\";\nimport { componentRegistry } from \"~/ComponentRegistry\";\nimport { ApiClient } from \"~/dataProviders/ApiClient\";\nimport { DefaultDataProvider } from \"~/dataProviders/DefaultDataProvider\";\nimport type { WebsiteBuilderThemeInput } from \"./types/WebsiteBuilderTheme.js\";\nimport { Theme } from \"./Theme.js\";\nimport { viewportManager } from \"./ViewportManager.js\";\nimport type { IRedirects } from \"~/IRedirects\";\nimport { RedirectsProvider } from \"~/dataProviders/RedirectsProvider\";\n\nexport type ApiConfig = {\n apiKey: string;\n apiHost: string;\n apiTenant: string;\n};\n\nexport type ContentSDKConfig = ApiConfig & {\n preview?: boolean;\n theme?: WebsiteBuilderThemeInput;\n};\n\nclass InternalContentSdk implements IContentSdk, IRedirects {\n private activeSdk: IContentSdk;\n private editingSdk: EditingSdk | undefined;\n private redirectsProvider: IRedirects;\n\n constructor(redirectsProvider: IRedirects, liveSdk: LiveSdk, editingSdk?: EditingSdk) {\n this.redirectsProvider = redirectsProvider;\n this.activeSdk = editingSdk ?? liveSdk;\n this.editingSdk = editingSdk;\n }\n\n getEditingSdk() {\n return this.editingSdk;\n }\n\n async getPage(path: string): Promise<PublicPage | null> {\n return this.activeSdk.getPage(path);\n }\n\n listPages(): Promise<PublicPage[]> {\n return this.activeSdk.listPages();\n }\n\n getAllRedirects(): Promise<Map<string, PublicRedirect>> {\n return this.redirectsProvider.getAllRedirects();\n }\n\n getRedirectByPath(path: string): Promise<PublicRedirect | undefined> {\n return this.redirectsProvider.getRedirectByPath(path);\n }\n}\n\nexport class ContentSdk implements IContentSdk, IRedirects {\n protected sdk?: InternalContentSdk;\n private isPreview = false;\n private lastConfig: any;\n\n public init(config: ContentSDKConfig, afterInit?: () => void): void {\n const configHash = JSON.stringify(config);\n if (this.lastConfig && this.lastConfig === configHash) {\n return;\n }\n\n this.lastConfig = configHash;\n const apiClient = new ApiClient(config.apiHost, config.apiKey, config.apiTenant);\n\n const dataProvider = new DefaultDataProvider({ apiClient });\n\n let liveSdk: IContentSdk = new LiveSdk(dataProvider);\n\n if (config.preview && !environment.isEditing()) {\n this.isPreview = true;\n liveSdk = new PreviewSdk(dataProvider, liveSdk);\n }\n\n const theme = Theme.from(config.theme ?? {});\n\n if (environment.isClient()) {\n viewportManager.setBreakpoints(theme.breakpoints);\n }\n\n let editingSdk;\n if (environment.isEditing()) {\n editingSdk = new EditingSdk(liveSdk, theme);\n }\n\n this.sdk = new InternalContentSdk(\n new RedirectsProvider(apiClient),\n liveSdk as LiveSdk,\n editingSdk\n );\n\n if (typeof afterInit === \"function\") {\n afterInit();\n }\n }\n\n public getEditingSdk() {\n this.assertInitialized();\n return this.sdk.getEditingSdk();\n }\n\n public getPage(path: string) {\n this.assertInitialized();\n return this.sdk.getPage(path);\n }\n\n public listPages() {\n this.assertInitialized();\n return this.sdk.listPages();\n }\n\n public async getAllRedirects() {\n this.assertInitialized();\n return this.sdk.getAllRedirects();\n }\n\n getRedirectByPath(path: string): Promise<PublicRedirect | undefined> {\n this.assertInitialized();\n return this.sdk.getRedirectByPath(path);\n }\n\n registerComponent(blueprint: Component): void {\n this.assertInitialized();\n componentRegistry.register(blueprint);\n }\n\n resolveElement(params: ResolveElementParams): ResolvedComponent[] | null {\n this.assertInitialized();\n return new ComponentResolver(componentRegistry).resolve(params);\n }\n\n isEditing() {\n return environment.isEditing();\n }\n\n isPreviewing() {\n return this.isPreview;\n }\n\n private assertInitialized(): asserts this is this & {\n sdk: IContentSdk;\n } {\n if (!this.sdk) {\n throw new Error(`ContentSdk has not been initialized!`);\n }\n }\n}\n\nexport const contentSdk = new ContentSdk();\n"],"mappings":"AAOA,SAASA,WAAW;AACpB,SAASC,OAAO;AAChB,SAASC,UAAU;AACnB,SAASC,iBAAiB;AAC1B,SAASC,UAAU;AACnB,SAASC,iBAAiB;AAC1B,SAASC,SAAS;AAClB,SAASC,mBAAmB;AAE5B,SAASC,KAAK;AACd,SAASC,eAAe;AAExB,SAASC,iBAAiB;AAa1B,MAAMC,kBAAkB,CAAoC;EAKxDC,WAAWA,CAACC,iBAA6B,EAAEC,OAAgB,EAAEC,UAAuB,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IAAY,EAAuC;IACjE,IAAI,CAAC0B,iBAAiB,CAAC,CAAC;IACxB,OAAO,IAAI,CAACD,GAAG,CAACtB,iBAAiB,CAACH,IAAI,CAAC;EAC3C;EAEA2B,iBAAiBA,CAACC,SAAoB,EAAQ;IAC1C,IAAI,CAACF,iBAAiB,CAAC,CAAC;IACxBxC,iBAAiB,CAAC2C,QAAQ,CAACD,SAAS,CAAC;EACzC;EAEAE,cAAcA,CAACC,MAA4B,EAA8B;IACrE,IAAI,CAACL,iBAAiB,CAAC,CAAC;IACxB,OAAO,IAAI1C,iBAAiB,CAACE,iBAAiB,CAAC,CAAC8C,OAAO,CAACD,MAAM,CAAC;EACnE;EAEAZ,SAASA,CAAA,EAAG;IACR,OAAOtC,WAAW,CAACsC,SAAS,CAAC,CAAC;EAClC;EAEAc,YAAYA,CAAA,EAAG;IACX,OAAO,IAAI,CAAC5B,SAAS;EACzB;EAEQqB,iBAAiBA,CAAA,EAEvB;IACE,IAAI,CAAC,IAAI,CAACD,GAAG,EAAE;MACX,MAAM,IAAIS,KAAK,CAAC,sCAAsC,CAAC;IAC3D;EACJ;AACJ;AAEA,OAAO,MAAMC,UAAU,GAAG,IAAI/B,UAAU,CAAC,CAAC","ignoreList":[]}
|
package/IRedirects.d.ts
ADDED
package/IRedirects.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["IRedirects.ts"],"sourcesContent":["import type { PublicRedirect } from \"~/types\";\n\nexport interface IRedirects {\n getAllRedirects(): Promise<Map<string, PublicRedirect>>;\n getRedirectByPath(path: string): Promise<PublicRedirect | undefined>;\n}\n"],"mappings":"","ignoreList":[]}
|
package/NullSdk.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import type { IContentSdk, Page, ResolvedComponent } from "./types";
|
|
1
|
+
import type { IContentSdk, Page, PublicRedirect, ResolvedComponent } from "./types";
|
|
2
2
|
export declare class NullSdk implements IContentSdk {
|
|
3
3
|
getPage(): Promise<Page | null>;
|
|
4
4
|
listPages(): Promise<Page[]>;
|
|
5
|
+
listRedirects(): Promise<PublicRedirect[]>;
|
|
5
6
|
registerComponent(): void;
|
|
6
7
|
resolveElement(): ResolvedComponent[] | null;
|
|
7
8
|
}
|
package/NullSdk.js
CHANGED
package/NullSdk.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["NullSdk","getPage","listPages","Promise","resolve","registerComponent","resolveElement"],"sources":["NullSdk.ts"],"sourcesContent":["import type { IContentSdk, Page, ResolvedComponent } from \"./types\";\n\nexport class NullSdk implements IContentSdk {\n async getPage(): Promise<Page | null> {\n return null;\n }\n\n listPages(): Promise<Page[]> {\n return Promise.resolve([]);\n }\n\n registerComponent(): void {}\n\n resolveElement(): ResolvedComponent[] | null {\n return null;\n }\n}\n"],"mappings":"AAEA,OAAO,MAAMA,OAAO,CAAwB;EACxC,MAAMC,OAAOA,CAAA,EAAyB;IAClC,OAAO,IAAI;EACf;EAEAC,SAASA,CAAA,EAAoB;IACzB,OAAOC,OAAO,CAACC,OAAO,CAAC,EAAE,CAAC;EAC9B;EAEAC,iBAAiBA,CAAA,EAAS,CAAC;EAE3BC,cAAcA,CAAA,EAA+B;IACzC,OAAO,IAAI;EACf;AACJ","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["NullSdk","getPage","listPages","Promise","resolve","listRedirects","registerComponent","resolveElement"],"sources":["NullSdk.ts"],"sourcesContent":["import type { IContentSdk, Page, PublicRedirect, ResolvedComponent } from \"./types\";\n\nexport class NullSdk implements IContentSdk {\n async getPage(): Promise<Page | null> {\n return null;\n }\n\n listPages(): Promise<Page[]> {\n return Promise.resolve([]);\n }\n\n listRedirects(): Promise<PublicRedirect[]> {\n return Promise.resolve([]);\n }\n\n registerComponent(): void {}\n\n resolveElement(): ResolvedComponent[] | null {\n return null;\n }\n}\n"],"mappings":"AAEA,OAAO,MAAMA,OAAO,CAAwB;EACxC,MAAMC,OAAOA,CAAA,EAAyB;IAClC,OAAO,IAAI;EACf;EAEAC,SAASA,CAAA,EAAoB;IACzB,OAAOC,OAAO,CAACC,OAAO,CAAC,EAAE,CAAC;EAC9B;EAEAC,aAAaA,CAAA,EAA8B;IACvC,OAAOF,OAAO,CAACC,OAAO,CAAC,EAAE,CAAC;EAC9B;EAEAE,iBAAiBA,CAAA,EAAS,CAAC;EAE3BC,cAAcA,CAAA,EAA+B;IACzC,OAAO,IAAI;EACf;AACJ","ignoreList":[]}
|
|
@@ -12,6 +12,7 @@ export class DefaultDataProvider {
|
|
|
12
12
|
path
|
|
13
13
|
}
|
|
14
14
|
});
|
|
15
|
+
this.checkForErrors(`getPageByPath:${path}`, result.websiteBuilder.getPageByPath);
|
|
15
16
|
return result.websiteBuilder.getPageByPath.data;
|
|
16
17
|
}
|
|
17
18
|
async getPageById(id) {
|
|
@@ -21,6 +22,7 @@ export class DefaultDataProvider {
|
|
|
21
22
|
id
|
|
22
23
|
}
|
|
23
24
|
});
|
|
25
|
+
this.checkForErrors("getPageById", result.websiteBuilder.getPageById);
|
|
24
26
|
return result.websiteBuilder.getPageById.data;
|
|
25
27
|
}
|
|
26
28
|
async listPages() {
|
|
@@ -32,8 +34,14 @@ export class DefaultDataProvider {
|
|
|
32
34
|
}
|
|
33
35
|
}
|
|
34
36
|
});
|
|
37
|
+
this.checkForErrors("listPages", result.websiteBuilder.listPages);
|
|
35
38
|
return result.websiteBuilder.listPages.data ?? [];
|
|
36
39
|
}
|
|
40
|
+
checkForErrors(action, data) {
|
|
41
|
+
if (data.error) {
|
|
42
|
+
console.error(`Could not execute "${action}". Reason: ${data.error.message}`);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
37
45
|
}
|
|
38
46
|
|
|
39
47
|
//# sourceMappingURL=DefaultDataProvider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["GET_PAGE_BY_PATH","GET_PAGE_BY_ID","LIST_PUBLISHED_PAGES","DefaultDataProvider","constructor","config","getPageByPath","path","result","apiClient","query","variables","websiteBuilder","data","getPageById","id","listPages","where","published"],"sources":["DefaultDataProvider.ts"],"sourcesContent":["import type { IDataProvider, PublicPage } from \"~/types.js\";\nimport type { ApiClient } from \"~/dataProviders/ApiClient\";\nimport { GET_PAGE_BY_PATH } from \"./GET_PAGE_BY_PATH\";\nimport { GET_PAGE_BY_ID } from \"./GET_PAGE_BY_ID\";\nimport { LIST_PUBLISHED_PAGES } from \"./LIST_PUBLISHED_PAGES\";\n\ninterface DefaultDataProviderConfig {\n apiClient: ApiClient;\n}\n\nexport class DefaultDataProvider implements IDataProvider {\n private config: DefaultDataProviderConfig;\n\n constructor(config: DefaultDataProviderConfig) {\n this.config = config;\n }\n\n public async getPageByPath(path: string): Promise<PublicPage | null> {\n const result = await this.config.apiClient.query({\n query: GET_PAGE_BY_PATH,\n variables: {\n path\n }\n });\n\n return result.websiteBuilder.getPageByPath.data;\n }\n\n public async getPageById(id: string): Promise<PublicPage | null> {\n const result = await this.config.apiClient.query({\n query: GET_PAGE_BY_ID,\n variables: {\n id\n }\n });\n\n return result.websiteBuilder.getPageById.data;\n }\n\n public async listPages() {\n const result = await this.config.apiClient.query({\n query: LIST_PUBLISHED_PAGES,\n variables: {\n where: {\n published: true\n }\n }\n });\n\n return result.websiteBuilder.listPages.data ?? [];\n }\n}\n"],"mappings":"AAEA,SAASA,gBAAgB;AACzB,SAASC,cAAc;AACvB,SAASC,oBAAoB;AAM7B,OAAO,MAAMC,mBAAmB,CAA0B;EAGtDC,WAAWA,CAACC,MAAiC,EAAE;IAC3C,IAAI,CAACA,MAAM,GAAGA,MAAM;EACxB;EAEA,MAAaC,aAAaA,CAACC,IAAY,EAA8B;IACjE,MAAMC,MAAM,GAAG,MAAM,IAAI,CAACH,MAAM,CAACI,SAAS,CAACC,KAAK,CAAC;MAC7CA,KAAK,EAAEV,gBAAgB;MACvBW,SAAS,EAAE;QACPJ;MACJ;IACJ,CAAC,CAAC;IAEF,
|
|
1
|
+
{"version":3,"names":["GET_PAGE_BY_PATH","GET_PAGE_BY_ID","LIST_PUBLISHED_PAGES","DefaultDataProvider","constructor","config","getPageByPath","path","result","apiClient","query","variables","checkForErrors","websiteBuilder","data","getPageById","id","listPages","where","published","action","error","console","message"],"sources":["DefaultDataProvider.ts"],"sourcesContent":["import type { IDataProvider, PublicPage } from \"~/types.js\";\nimport type { ApiClient } from \"~/dataProviders/ApiClient\";\nimport { GET_PAGE_BY_PATH } from \"./GET_PAGE_BY_PATH\";\nimport { GET_PAGE_BY_ID } from \"./GET_PAGE_BY_ID\";\nimport { LIST_PUBLISHED_PAGES } from \"./LIST_PUBLISHED_PAGES\";\n\ninterface DefaultDataProviderConfig {\n apiClient: ApiClient;\n}\n\nexport class DefaultDataProvider implements IDataProvider {\n private config: DefaultDataProviderConfig;\n\n constructor(config: DefaultDataProviderConfig) {\n this.config = config;\n }\n\n public async getPageByPath(path: string): Promise<PublicPage | null> {\n const result = await this.config.apiClient.query({\n query: GET_PAGE_BY_PATH,\n variables: {\n path\n }\n });\n\n this.checkForErrors(`getPageByPath:${path}`, result.websiteBuilder.getPageByPath);\n\n return result.websiteBuilder.getPageByPath.data;\n }\n\n public async getPageById(id: string): Promise<PublicPage | null> {\n const result = await this.config.apiClient.query({\n query: GET_PAGE_BY_ID,\n variables: {\n id\n }\n });\n\n this.checkForErrors(\"getPageById\", result.websiteBuilder.getPageById);\n\n return result.websiteBuilder.getPageById.data;\n }\n\n public async listPages() {\n const result = await this.config.apiClient.query({\n query: LIST_PUBLISHED_PAGES,\n variables: {\n where: {\n published: true\n }\n }\n });\n\n this.checkForErrors(\"listPages\", result.websiteBuilder.listPages);\n\n return result.websiteBuilder.listPages.data ?? [];\n }\n\n private checkForErrors(action: string, data: any) {\n if (data.error) {\n console.error(`Could not execute \"${action}\". Reason: ${data.error.message}`);\n }\n }\n}\n"],"mappings":"AAEA,SAASA,gBAAgB;AACzB,SAASC,cAAc;AACvB,SAASC,oBAAoB;AAM7B,OAAO,MAAMC,mBAAmB,CAA0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,KAAK,EAAE;MACZC,OAAO,CAACD,KAAK,CAAC,sBAAsBD,MAAM,cAAcN,IAAI,CAACO,KAAK,CAACE,OAAO,EAAE,CAAC;IACjF;EACJ;AACJ","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const GET_ACTIVE_REDIRECTS = "\n query GetActiveRedirects {\n websiteBuilder {\n getActiveRedirects {\n data {\n id\n from\n to\n permanent\n }\n error {\n code\n message\n data\n }\n }\n }\n }\n";
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export const GET_ACTIVE_REDIRECTS = /* GraphQL*/`
|
|
2
|
+
query GetActiveRedirects {
|
|
3
|
+
websiteBuilder {
|
|
4
|
+
getActiveRedirects {
|
|
5
|
+
data {
|
|
6
|
+
id
|
|
7
|
+
from
|
|
8
|
+
to
|
|
9
|
+
permanent
|
|
10
|
+
}
|
|
11
|
+
error {
|
|
12
|
+
code
|
|
13
|
+
message
|
|
14
|
+
data
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
`;
|
|
20
|
+
|
|
21
|
+
//# sourceMappingURL=GET_ACTIVE_REDIRECTS.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["GET_ACTIVE_REDIRECTS"],"sources":["GET_ACTIVE_REDIRECTS.ts"],"sourcesContent":["export const GET_ACTIVE_REDIRECTS = /* GraphQL*/ `\n query GetActiveRedirects {\n websiteBuilder {\n getActiveRedirects {\n data {\n id\n from\n to\n permanent\n }\n error {\n code\n message\n data\n }\n }\n }\n }\n`;\n"],"mappings":"AAAA,OAAO,MAAMA,oBAAoB,GAAG,YAAa;AACjD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC","ignoreList":[]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import type { IDataProvider, Page } from "../types.js";
|
|
1
|
+
import type { IDataProvider, Page, PublicRedirect } from "../types.js";
|
|
2
2
|
export declare class NullDataProvider implements IDataProvider {
|
|
3
3
|
getPageById(): Promise<Page | null>;
|
|
4
4
|
getPageByPath(): Promise<Page | null>;
|
|
5
5
|
listPages(): Promise<never[]>;
|
|
6
|
+
listRedirects(): Promise<PublicRedirect[]>;
|
|
6
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["NullDataProvider","getPageById","Promise","resolve","getPageByPath","listPages"],"sources":["NullDataProvider.ts"],"sourcesContent":["import type { IDataProvider, Page } from \"~/types.js\";\n\nexport class NullDataProvider implements IDataProvider {\n getPageById(): Promise<Page | null> {\n return Promise.resolve(null);\n }\n\n getPageByPath(): Promise<Page | null> {\n return Promise.resolve(null);\n }\n\n public async listPages() {\n return [];\n }\n}\n"],"mappings":"AAEA,OAAO,MAAMA,gBAAgB,CAA0B;EACnDC,WAAWA,CAAA,EAAyB;IAChC,OAAOC,OAAO,CAACC,OAAO,CAAC,IAAI,CAAC;EAChC;EAEAC,aAAaA,CAAA,EAAyB;IAClC,OAAOF,OAAO,CAACC,OAAO,CAAC,IAAI,CAAC;EAChC;EAEA,MAAaE,SAASA,CAAA,EAAG;IACrB,OAAO,EAAE;EACb;AACJ","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["NullDataProvider","getPageById","Promise","resolve","getPageByPath","listPages","listRedirects"],"sources":["NullDataProvider.ts"],"sourcesContent":["import type { IDataProvider, Page, PublicRedirect } from \"~/types.js\";\n\nexport class NullDataProvider implements IDataProvider {\n getPageById(): Promise<Page | null> {\n return Promise.resolve(null);\n }\n\n getPageByPath(): Promise<Page | null> {\n return Promise.resolve(null);\n }\n\n public async listPages() {\n return [];\n }\n\n listRedirects(): Promise<PublicRedirect[]> {\n return Promise.resolve([]);\n }\n}\n"],"mappings":"AAEA,OAAO,MAAMA,gBAAgB,CAA0B;EACnDC,WAAWA,CAAA,EAAyB;IAChC,OAAOC,OAAO,CAACC,OAAO,CAAC,IAAI,CAAC;EAChC;EAEAC,aAAaA,CAAA,EAAyB;IAClC,OAAOF,OAAO,CAACC,OAAO,CAAC,IAAI,CAAC;EAChC;EAEA,MAAaE,SAASA,CAAA,EAAG;IACrB,OAAO,EAAE;EACb;EAEAC,aAAaA,CAAA,EAA8B;IACvC,OAAOJ,OAAO,CAACC,OAAO,CAAC,EAAE,CAAC;EAC9B;AACJ","ignoreList":[]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ApiClient } from "./ApiClient";
|
|
2
|
+
import type { IRedirects } from "../IRedirects";
|
|
3
|
+
import type { PublicRedirect } from "../types";
|
|
4
|
+
export declare class RedirectsProvider implements IRedirects {
|
|
5
|
+
private redirectsCache;
|
|
6
|
+
private apiClient;
|
|
7
|
+
constructor(apiClient: ApiClient);
|
|
8
|
+
getRedirectByPath(path: string): Promise<PublicRedirect | undefined>;
|
|
9
|
+
getAllRedirects(): Promise<Map<string, PublicRedirect>>;
|
|
10
|
+
private populateCache;
|
|
11
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { GET_ACTIVE_REDIRECTS } from "./GET_ACTIVE_REDIRECTS";
|
|
2
|
+
export class RedirectsProvider {
|
|
3
|
+
redirectsCache = undefined;
|
|
4
|
+
constructor(apiClient) {
|
|
5
|
+
this.apiClient = apiClient;
|
|
6
|
+
}
|
|
7
|
+
async getRedirectByPath(path) {
|
|
8
|
+
await this.populateCache();
|
|
9
|
+
if (!this.redirectsCache) {
|
|
10
|
+
return undefined;
|
|
11
|
+
}
|
|
12
|
+
return this.redirectsCache.get(path);
|
|
13
|
+
}
|
|
14
|
+
async getAllRedirects() {
|
|
15
|
+
await this.populateCache();
|
|
16
|
+
return this.redirectsCache ?? new Map();
|
|
17
|
+
}
|
|
18
|
+
async populateCache() {
|
|
19
|
+
console.time("Populating redirects cache from API");
|
|
20
|
+
const result = await this.apiClient.query({
|
|
21
|
+
query: GET_ACTIVE_REDIRECTS,
|
|
22
|
+
variables: {}
|
|
23
|
+
});
|
|
24
|
+
const redirects = result.websiteBuilder.getActiveRedirects.data ?? [];
|
|
25
|
+
this.redirectsCache = new Map();
|
|
26
|
+
for (const redirect of redirects) {
|
|
27
|
+
this.redirectsCache.set(redirect.from, redirect);
|
|
28
|
+
}
|
|
29
|
+
console.timeEnd("Populating redirects cache from API");
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
//# sourceMappingURL=RedirectsProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["GET_ACTIVE_REDIRECTS","RedirectsProvider","redirectsCache","undefined","constructor","apiClient","getRedirectByPath","path","populateCache","get","getAllRedirects","Map","console","time","result","query","variables","redirects","websiteBuilder","getActiveRedirects","data","redirect","set","from","timeEnd"],"sources":["RedirectsProvider.ts"],"sourcesContent":["import type { ApiClient } from \"./ApiClient\";\nimport type { IRedirects } from \"~/IRedirects\";\nimport type { PublicRedirect } from \"~/types\";\nimport { GET_ACTIVE_REDIRECTS } from \"~/dataProviders/GET_ACTIVE_REDIRECTS\";\n\nexport class RedirectsProvider implements IRedirects {\n private redirectsCache: Map<string, PublicRedirect> | undefined = undefined;\n private apiClient: ApiClient;\n\n constructor(apiClient: ApiClient) {\n this.apiClient = apiClient;\n }\n\n async getRedirectByPath(path: string): Promise<PublicRedirect | undefined> {\n await this.populateCache();\n\n if (!this.redirectsCache) {\n return undefined;\n }\n\n return this.redirectsCache.get(path);\n }\n\n async getAllRedirects(): Promise<Map<string, PublicRedirect>> {\n await this.populateCache();\n return this.redirectsCache ?? new Map();\n }\n\n private async populateCache() {\n console.time(\"Populating redirects cache from API\");\n const result = await this.apiClient.query({\n query: GET_ACTIVE_REDIRECTS,\n variables: {}\n });\n\n const redirects: PublicRedirect[] = result.websiteBuilder.getActiveRedirects.data ?? [];\n\n this.redirectsCache = new Map();\n for (const redirect of redirects) {\n this.redirectsCache.set(redirect.from, redirect);\n }\n console.timeEnd(\"Populating redirects cache from API\");\n }\n}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+
"version": "6.0.0-alpha.2",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
"@types/deep-equal": "1.0.4",
|
|
32
32
|
"@types/is-hotkey": "0.1.10",
|
|
33
33
|
"@types/micromatch": "4.0.9",
|
|
34
|
-
"@webiny/cli": "
|
|
35
|
-
"@webiny/project-utils": "
|
|
34
|
+
"@webiny/cli": "6.0.0-alpha.2",
|
|
35
|
+
"@webiny/project-utils": "6.0.0-alpha.2",
|
|
36
36
|
"typescript": "5.3.3"
|
|
37
37
|
},
|
|
38
38
|
"publishConfig": {
|
|
@@ -50,5 +50,5 @@
|
|
|
50
50
|
]
|
|
51
51
|
}
|
|
52
52
|
},
|
|
53
|
-
"gitHead": "
|
|
53
|
+
"gitHead": "7c9e8fbfd62a57ece5f880dbad6c864636b0355e"
|
|
54
54
|
}
|
package/types.d.ts
CHANGED
|
@@ -126,6 +126,12 @@ export type Document = {
|
|
|
126
126
|
elements: ElementMap;
|
|
127
127
|
};
|
|
128
128
|
export type PublicPage = Pick<Page, "id" | "version" | "properties" | "bindings" | "elements" | "state">;
|
|
129
|
+
export type PublicRedirect = {
|
|
130
|
+
id: string;
|
|
131
|
+
from: string;
|
|
132
|
+
to: string;
|
|
133
|
+
permanent: boolean;
|
|
134
|
+
};
|
|
129
135
|
export type EditorPage = EditorDocument & Pick<Page, "properties" | "status" | "location">;
|
|
130
136
|
export type EditorDocument = Document & {
|
|
131
137
|
metadata: Record<string, any>;
|
package/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type * as CSS from \"csstype\";\nimport type { BindingsApi } from \"~/BindingsApi\";\nimport type { ShorthandCssProperties } from \"./types/ShorthandCssProperties\";\nexport type { WebsiteBuilderTheme, Breakpoint } from \"./types/WebsiteBuilderTheme\";\n\ninterface CSSProperties extends CSS.Properties<string | number> {}\n\nexport type ElementMap = Record<string, DocumentElement>;\n\nexport type DocumentState = Record<string, any>;\n\nexport type InputValueBinding<T = any> = ValueBinding<T> & {\n id: string;\n type: string;\n translatable?: boolean;\n list?: boolean;\n};\n\nexport type StyleValueBinding<T = any> = ValueBinding<T>;\n\nexport type ValueBinding<T = any> = {\n static?: T;\n expression?: string;\n};\n\nexport type RepeatValueBinding = {\n expression: string;\n};\n\nexport type CssProperties = Omit<CSSProperties, ShorthandCssProperties>;\n\nexport type DocumentElementStyleBindings = Partial<{\n [K in keyof CssProperties]: StyleValueBinding<CssProperties[K]>;\n}>;\n\nexport type DocumentElementInputBindings = {\n [inputName: string]: InputValueBinding;\n};\n\nexport type DocumentElementBindings = {\n $repeat?: RepeatValueBinding;\n inputs?: DocumentElementInputBindings;\n styles?: DocumentElementStyleBindings;\n metadata?: Record<string, any>;\n overrides?: {\n [key: string]: {\n inputs?: DocumentElementInputBindings;\n styles?: DocumentElementStyleBindings;\n };\n };\n};\n\nexport type DocumentBindings = {\n [elementId: string]: DocumentElementBindings;\n};\n\nexport type ResolvedComponent<TComponent = any> = {\n component: TComponent;\n inputs: Record<string, any>;\n manifest: ComponentManifest;\n styles: SerializableCSSStyleDeclaration;\n};\n\nexport type ResolvedElement = {\n id: string;\n inputs: Record<string, any>;\n styles: SerializableCSSStyleDeclaration;\n};\n\nexport type Component = {\n component: any;\n manifest: ComponentManifest;\n};\n\nexport type ComponentGroupItem = {\n // Name of the component.\n name: string;\n // Optionally, define an exact element to insert.\n item?: DocumentElementTemplate;\n};\n\nexport type SerializedComponentGroup = ComponentGroup & {\n filter?: string;\n};\n\nexport type ComponentGroupFilterContext = {\n document: EditorDocument;\n};\n\nexport type ComponentGroup = {\n name: string;\n label: string;\n description?: string;\n filter?: (component: ComponentManifest, context: ComponentGroupFilterContext) => boolean;\n};\n\nexport type ResponsiveStyles = {\n [key: string]: SerializableCSSStyleDeclaration;\n};\n\nexport type ComponentManifest = {\n name: string;\n group?: string;\n label?: string;\n image?: string;\n inputs?: ComponentInput[];\n canDrag?: boolean;\n canDelete?: boolean;\n acceptsChildren?: boolean;\n hideFromToolbar?: boolean;\n hideStyleSettings?: string[];\n autoApplyStyles?: boolean;\n tags?: string[];\n defaults?: {\n inputs?: Record<string, any>;\n styles?: SerializableCSSStyleDeclaration;\n overrides?: {\n [breakpoint: string]: {\n inputs?: Record<string, any>;\n styles?: SerializableCSSStyleDeclaration;\n };\n };\n };\n};\n\nexport type DocumentElementTemplate = Omit<DocumentElement, \"id\">;\n\nexport type ElementComponent = {\n name: string;\n};\n\nexport type DocumentElement = {\n type: \"Webiny/Element\";\n id: string;\n component: ElementComponent;\n parent?: {\n id: string;\n slot: string;\n };\n styles?: ResponsiveStyles;\n};\n\nexport type SerializableCSSStyleDeclaration = {\n [K in keyof CssProperties]?: CssProperties[K];\n};\n\nexport type Document = {\n id: string;\n state: DocumentState;\n version: number;\n properties: Record<string, any>;\n bindings: DocumentBindings;\n elements: ElementMap;\n};\n\nexport type PublicPage = Pick<\n Page,\n \"id\" | \"version\" | \"properties\" | \"bindings\" | \"elements\" | \"state\"\n>;\n\nexport type EditorPage = EditorDocument & Pick<Page, \"properties\" | \"status\" | \"location\">;\n\nexport type EditorDocument = Document & {\n metadata: Record<string, any>;\n};\n\nexport type Page = Document & {\n id: string;\n status: string;\n version: number;\n location: {\n folderId: string;\n };\n properties: {\n title: string;\n snippet: string;\n /*image: {\n id: string;\n name: string;\n size: number;\n mimeType: string;\n src: string;\n };*/\n path: string;\n tags: string[];\n seo: {\n title: string;\n description: string;\n metaTags: Array<{ name: string; content: string }>;\n };\n social: {\n title: string;\n description: string;\n /*image: {\n id: string;\n name: string;\n size: number;\n mimeType: string;\n src: string;\n };*/\n metaTags: Array<{ property: string; content: string }>;\n };\n };\n};\n\nexport type Box = {\n depth: number;\n parentId: string;\n parentSlot: string;\n parentIndex: number;\n width: number;\n height: number;\n top: number;\n left: number;\n};\n\nexport type ElementBoxData = Box & {\n type: \"element\";\n};\n\nexport type ElementSlotBoxData = Box & {\n type: \"element-slot\";\n};\n\nexport type BoxData = ElementBoxData | ElementSlotBoxData;\n\nexport type EditorViewportInfo = PreviewViewportInfo & {\n top: number;\n left: number;\n};\n\nexport type PreviewViewportInfo = {\n width: number;\n height: number;\n scrollX: number;\n scrollY: number;\n};\n\nexport type BoxesData = Record<string, BoxData>;\n\nexport type EditorViewportData = {\n boxes: BoxesData;\n viewport: EditorViewportInfo;\n};\n\nexport type PreviewViewportData = {\n boxes: BoxesData;\n viewport: PreviewViewportInfo;\n};\n\nexport type ApiOptions = Record<string, any>;\n\nexport type GetPageOptions = ApiOptions;\nexport type ListPagesOptions = ApiOptions;\n\nexport interface IDataProvider {\n getPageByPath(path: string, options?: GetPageOptions): Promise<PublicPage | null>;\n getPageById(id: string, options?: GetPageOptions): Promise<PublicPage | null>;\n listPages(options?: ListPagesOptions): Promise<PublicPage[]>;\n}\n\nexport interface IEnvironment {\n isClient(): boolean;\n isServer(): boolean;\n isPreview(): boolean;\n}\n\nexport interface IContentSdk {\n getPage(path: string): Promise<PublicPage | null>;\n listPages(options?: ListPagesOptions): Promise<PublicPage[]>;\n}\n\n// Input types\n\n// inputTypes.ts\nexport type BaseInput<T = any> = {\n name: string;\n type: string;\n onChange?: (\n bindings: ReturnType<BindingsApi[\"getPublicApi\"]>,\n context: { breakpoint: string }\n ) => void;\n label?: string;\n description?: string;\n helperText?: string;\n defaultValue?: T;\n responsive?: boolean;\n required?: boolean;\n hideFromUi?: boolean;\n renderer?: string;\n list?: boolean;\n translatable?: boolean;\n};\n\n// Discriminated union per input type\nexport type TextInput = BaseInput<string> & {\n type: \"text\";\n};\n\nexport type SlotInput = BaseInput<any> & {\n type: \"slot\";\n components?: string[];\n};\n\nexport type TagsInput = BaseInput<string[]> & {\n type: \"text\";\n};\n\nexport type LongTextInput = BaseInput<string> & {\n type: \"longText\";\n};\n\nexport type NumberInput = BaseInput<number> & {\n type: \"number\";\n minValue?: number;\n};\n\nexport type BooleanInput = BaseInput<boolean> & {\n type: \"boolean\";\n};\n\nexport type ColorInput = BaseInput<string> & {\n type: \"color\";\n};\n\nexport type FileInput = BaseInput<string> & {\n type: \"file\";\n allowedFileTypes: string[];\n};\n\nexport type DateTimeInput = BaseInput<string> & {\n type: \"datetime\";\n};\n\nexport type LexicalInput = BaseInput<string> & {\n type: \"lexical\";\n};\n\nexport type SelectInput = BaseInput<string> & {\n type: \"select\";\n options: { label: string; value: string }[];\n showResetAction?: boolean;\n};\n\nexport type RadioInput = BaseInput<string> & {\n type: \"radio\";\n options: { label: string; value: string }[];\n};\n\nexport type ObjectInput = BaseInput<Record<string, any>> & {\n type: \"object\";\n fields: ComponentInput[];\n};\n\nexport type CustomInput = BaseInput<any> & {\n type: string;\n fields: ComponentInput[];\n};\n\n// Union of all input types\nexport type ComponentInput =\n | TextInput\n | LongTextInput\n | NumberInput\n | BooleanInput\n | ColorInput\n | FileInput\n | DateTimeInput\n | LexicalInput\n | SelectInput\n | RadioInput\n | TagsInput\n | ObjectInput\n | SlotInput\n | CustomInput;\n"],"mappings":"","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type * as CSS from \"csstype\";\nimport type { BindingsApi } from \"~/BindingsApi\";\nimport type { ShorthandCssProperties } from \"./types/ShorthandCssProperties\";\nexport type { WebsiteBuilderTheme, Breakpoint } from \"./types/WebsiteBuilderTheme\";\n\ninterface CSSProperties extends CSS.Properties<string | number> {}\n\nexport type ElementMap = Record<string, DocumentElement>;\n\nexport type DocumentState = Record<string, any>;\n\nexport type InputValueBinding<T = any> = ValueBinding<T> & {\n id: string;\n type: string;\n translatable?: boolean;\n list?: boolean;\n};\n\nexport type StyleValueBinding<T = any> = ValueBinding<T>;\n\nexport type ValueBinding<T = any> = {\n static?: T;\n expression?: string;\n};\n\nexport type RepeatValueBinding = {\n expression: string;\n};\n\nexport type CssProperties = Omit<CSSProperties, ShorthandCssProperties>;\n\nexport type DocumentElementStyleBindings = Partial<{\n [K in keyof CssProperties]: StyleValueBinding<CssProperties[K]>;\n}>;\n\nexport type DocumentElementInputBindings = {\n [inputName: string]: InputValueBinding;\n};\n\nexport type DocumentElementBindings = {\n $repeat?: RepeatValueBinding;\n inputs?: DocumentElementInputBindings;\n styles?: DocumentElementStyleBindings;\n metadata?: Record<string, any>;\n overrides?: {\n [key: string]: {\n inputs?: DocumentElementInputBindings;\n styles?: DocumentElementStyleBindings;\n };\n };\n};\n\nexport type DocumentBindings = {\n [elementId: string]: DocumentElementBindings;\n};\n\nexport type ResolvedComponent<TComponent = any> = {\n component: TComponent;\n inputs: Record<string, any>;\n manifest: ComponentManifest;\n styles: SerializableCSSStyleDeclaration;\n};\n\nexport type ResolvedElement = {\n id: string;\n inputs: Record<string, any>;\n styles: SerializableCSSStyleDeclaration;\n};\n\nexport type Component = {\n component: any;\n manifest: ComponentManifest;\n};\n\nexport type ComponentGroupItem = {\n // Name of the component.\n name: string;\n // Optionally, define an exact element to insert.\n item?: DocumentElementTemplate;\n};\n\nexport type SerializedComponentGroup = ComponentGroup & {\n filter?: string;\n};\n\nexport type ComponentGroupFilterContext = {\n document: EditorDocument;\n};\n\nexport type ComponentGroup = {\n name: string;\n label: string;\n description?: string;\n filter?: (component: ComponentManifest, context: ComponentGroupFilterContext) => boolean;\n};\n\nexport type ResponsiveStyles = {\n [key: string]: SerializableCSSStyleDeclaration;\n};\n\nexport type ComponentManifest = {\n name: string;\n group?: string;\n label?: string;\n image?: string;\n inputs?: ComponentInput[];\n canDrag?: boolean;\n canDelete?: boolean;\n acceptsChildren?: boolean;\n hideFromToolbar?: boolean;\n hideStyleSettings?: string[];\n autoApplyStyles?: boolean;\n tags?: string[];\n defaults?: {\n inputs?: Record<string, any>;\n styles?: SerializableCSSStyleDeclaration;\n overrides?: {\n [breakpoint: string]: {\n inputs?: Record<string, any>;\n styles?: SerializableCSSStyleDeclaration;\n };\n };\n };\n};\n\nexport type DocumentElementTemplate = Omit<DocumentElement, \"id\">;\n\nexport type ElementComponent = {\n name: string;\n};\n\nexport type DocumentElement = {\n type: \"Webiny/Element\";\n id: string;\n component: ElementComponent;\n parent?: {\n id: string;\n slot: string;\n };\n styles?: ResponsiveStyles;\n};\n\nexport type SerializableCSSStyleDeclaration = {\n [K in keyof CssProperties]?: CssProperties[K];\n};\n\nexport type Document = {\n id: string;\n state: DocumentState;\n version: number;\n properties: Record<string, any>;\n bindings: DocumentBindings;\n elements: ElementMap;\n};\n\nexport type PublicPage = Pick<\n Page,\n \"id\" | \"version\" | \"properties\" | \"bindings\" | \"elements\" | \"state\"\n>;\n\nexport type PublicRedirect = {\n id: string;\n from: string;\n to: string;\n permanent: boolean;\n};\n\nexport type EditorPage = EditorDocument & Pick<Page, \"properties\" | \"status\" | \"location\">;\n\nexport type EditorDocument = Document & {\n metadata: Record<string, any>;\n};\n\nexport type Page = Document & {\n id: string;\n status: string;\n version: number;\n location: {\n folderId: string;\n };\n properties: {\n title: string;\n snippet: string;\n /*image: {\n id: string;\n name: string;\n size: number;\n mimeType: string;\n src: string;\n };*/\n path: string;\n tags: string[];\n seo: {\n title: string;\n description: string;\n metaTags: Array<{ name: string; content: string }>;\n };\n social: {\n title: string;\n description: string;\n /*image: {\n id: string;\n name: string;\n size: number;\n mimeType: string;\n src: string;\n };*/\n metaTags: Array<{ property: string; content: string }>;\n };\n };\n};\n\nexport type Box = {\n depth: number;\n parentId: string;\n parentSlot: string;\n parentIndex: number;\n width: number;\n height: number;\n top: number;\n left: number;\n};\n\nexport type ElementBoxData = Box & {\n type: \"element\";\n};\n\nexport type ElementSlotBoxData = Box & {\n type: \"element-slot\";\n};\n\nexport type BoxData = ElementBoxData | ElementSlotBoxData;\n\nexport type EditorViewportInfo = PreviewViewportInfo & {\n top: number;\n left: number;\n};\n\nexport type PreviewViewportInfo = {\n width: number;\n height: number;\n scrollX: number;\n scrollY: number;\n};\n\nexport type BoxesData = Record<string, BoxData>;\n\nexport type EditorViewportData = {\n boxes: BoxesData;\n viewport: EditorViewportInfo;\n};\n\nexport type PreviewViewportData = {\n boxes: BoxesData;\n viewport: PreviewViewportInfo;\n};\n\nexport type ApiOptions = Record<string, any>;\n\nexport type GetPageOptions = ApiOptions;\nexport type ListPagesOptions = ApiOptions;\n\nexport interface IDataProvider {\n getPageByPath(path: string, options?: GetPageOptions): Promise<PublicPage | null>;\n getPageById(id: string, options?: GetPageOptions): Promise<PublicPage | null>;\n listPages(options?: ListPagesOptions): Promise<PublicPage[]>;\n}\n\nexport interface IEnvironment {\n isClient(): boolean;\n isServer(): boolean;\n isPreview(): boolean;\n}\n\nexport interface IContentSdk {\n getPage(path: string): Promise<PublicPage | null>;\n listPages(options?: ListPagesOptions): Promise<PublicPage[]>;\n}\n\n// Input types\n\n// inputTypes.ts\nexport type BaseInput<T = any> = {\n name: string;\n type: string;\n onChange?: (\n bindings: ReturnType<BindingsApi[\"getPublicApi\"]>,\n context: { breakpoint: string }\n ) => void;\n label?: string;\n description?: string;\n helperText?: string;\n defaultValue?: T;\n responsive?: boolean;\n required?: boolean;\n hideFromUi?: boolean;\n renderer?: string;\n list?: boolean;\n translatable?: boolean;\n};\n\n// Discriminated union per input type\nexport type TextInput = BaseInput<string> & {\n type: \"text\";\n};\n\nexport type SlotInput = BaseInput<any> & {\n type: \"slot\";\n components?: string[];\n};\n\nexport type TagsInput = BaseInput<string[]> & {\n type: \"text\";\n};\n\nexport type LongTextInput = BaseInput<string> & {\n type: \"longText\";\n};\n\nexport type NumberInput = BaseInput<number> & {\n type: \"number\";\n minValue?: number;\n};\n\nexport type BooleanInput = BaseInput<boolean> & {\n type: \"boolean\";\n};\n\nexport type ColorInput = BaseInput<string> & {\n type: \"color\";\n};\n\nexport type FileInput = BaseInput<string> & {\n type: \"file\";\n allowedFileTypes: string[];\n};\n\nexport type DateTimeInput = BaseInput<string> & {\n type: \"datetime\";\n};\n\nexport type LexicalInput = BaseInput<string> & {\n type: \"lexical\";\n};\n\nexport type SelectInput = BaseInput<string> & {\n type: \"select\";\n options: { label: string; value: string }[];\n showResetAction?: boolean;\n};\n\nexport type RadioInput = BaseInput<string> & {\n type: \"radio\";\n options: { label: string; value: string }[];\n};\n\nexport type ObjectInput = BaseInput<Record<string, any>> & {\n type: \"object\";\n fields: ComponentInput[];\n};\n\nexport type CustomInput = BaseInput<any> & {\n type: string;\n fields: ComponentInput[];\n};\n\n// Union of all input types\nexport type ComponentInput =\n | TextInput\n | LongTextInput\n | NumberInput\n | BooleanInput\n | ColorInput\n | FileInput\n | DateTimeInput\n | LexicalInput\n | SelectInput\n | RadioInput\n | TagsInput\n | ObjectInput\n | SlotInput\n | CustomInput;\n"],"mappings":"","ignoreList":[]}
|