@cntrl-site/sdk 1.22.19 → 1.22.20

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.
@@ -8,7 +8,7 @@ export declare class Client {
8
8
  private url;
9
9
  constructor(APIUrl: string, fetchImpl?: FetchImpl);
10
10
  private static getPageMeta;
11
- getPageData(pageSlug: string): Promise<CntrlPageData>;
11
+ getPageData(pageSlug: string, buildMode?: 'default' | 'self-hosted'): Promise<CntrlPageData>;
12
12
  getProjectPagesPaths(): Promise<string[]>;
13
13
  getLayouts(): Promise<Layout[]>;
14
14
  private fetchProject;
@@ -39,12 +39,12 @@ class Client {
39
39
  favicon: (_e = projectMeta.favicon) !== null && _e !== void 0 ? _e : ''
40
40
  } : projectMeta;
41
41
  }
42
- getPageData(pageSlug) {
43
- return __awaiter(this, void 0, void 0, function* () {
42
+ getPageData(pageSlug_1) {
43
+ return __awaiter(this, arguments, void 0, function* (pageSlug, buildMode = 'default') {
44
44
  try {
45
- const project = yield this.fetchProject();
45
+ const project = yield this.fetchProject(buildMode);
46
46
  const articleId = this.findArticleIdByPageSlug(pageSlug, project.pages);
47
- const { article, keyframes } = yield this.fetchArticle(articleId);
47
+ const { article, keyframes } = yield this.fetchArticle(articleId, buildMode);
48
48
  const page = project.pages.find(page => page.slug === pageSlug);
49
49
  const meta = Client.getPageMeta(project.meta, page === null || page === void 0 ? void 0 : page.meta);
50
50
  return {
@@ -82,9 +82,9 @@ class Client {
82
82
  });
83
83
  }
84
84
  fetchProject() {
85
- return __awaiter(this, void 0, void 0, function* () {
85
+ return __awaiter(this, arguments, void 0, function* (buildMode = 'default') {
86
86
  const { username: projectId, password: apiKey, origin } = this.url;
87
- const url = new url_1.URL(`/projects/${projectId}`, origin);
87
+ const url = new url_1.URL(`/projects/${projectId}?buildMode=${buildMode}`, origin);
88
88
  const response = yield this.fetchImpl(url.href, {
89
89
  headers: {
90
90
  Authorization: `Bearer ${apiKey}`
@@ -98,10 +98,10 @@ class Client {
98
98
  return project;
99
99
  });
100
100
  }
101
- fetchArticle(articleId) {
102
- return __awaiter(this, void 0, void 0, function* () {
101
+ fetchArticle(articleId_1) {
102
+ return __awaiter(this, arguments, void 0, function* (articleId, buildMode = 'default') {
103
103
  const { username: projectId, password: apiKey, origin } = this.url;
104
- const url = new url_1.URL(`/projects/${projectId}/articles/${articleId}`, origin);
104
+ const url = new url_1.URL(`/projects/${projectId}/articles/${articleId}?buildMode=${buildMode}`, origin);
105
105
  const response = yield this.fetchImpl(url.href, {
106
106
  headers: {
107
107
  Authorization: `Bearer ${apiKey}`
package/dist/index.js CHANGED
@@ -627,7 +627,7 @@ const ProjectSchema = zod.z.object({
627
627
  files: zod.z.array(
628
628
  zod.z.object({
629
629
  type: zod.z.nativeEnum(FontFileTypes),
630
- url: zod.z.string().url()
630
+ url: zod.z.string()
631
631
  })
632
632
  )
633
633
  }))
@@ -785,11 +785,11 @@ class Client {
785
785
  favicon: projectMeta.favicon ?? ""
786
786
  } : projectMeta;
787
787
  }
788
- async getPageData(pageSlug) {
788
+ async getPageData(pageSlug, buildMode = "default") {
789
789
  try {
790
- const project = await this.fetchProject();
790
+ const project = await this.fetchProject(buildMode);
791
791
  const articleId = this.findArticleIdByPageSlug(pageSlug, project.pages);
792
- const { article, keyframes } = await this.fetchArticle(articleId);
792
+ const { article, keyframes } = await this.fetchArticle(articleId, buildMode);
793
793
  const page = project.pages.find((page2) => page2.slug === pageSlug);
794
794
  const meta = Client.getPageMeta(project.meta, page == null ? void 0 : page.meta);
795
795
  return {
@@ -818,9 +818,9 @@ class Client {
818
818
  throw e;
819
819
  }
820
820
  }
821
- async fetchProject() {
821
+ async fetchProject(buildMode = "default") {
822
822
  const { username: projectId, password: apiKey, origin } = this.url;
823
- const url$1 = new url.URL(`/projects/${projectId}`, origin);
823
+ const url$1 = new url.URL(`/projects/${projectId}?buildMode=${buildMode}`, origin);
824
824
  const response = await this.fetchImpl(url$1.href, {
825
825
  headers: {
826
826
  Authorization: `Bearer ${apiKey}`
@@ -833,9 +833,9 @@ class Client {
833
833
  const project = ProjectSchema.parse(data);
834
834
  return project;
835
835
  }
836
- async fetchArticle(articleId) {
836
+ async fetchArticle(articleId, buildMode = "default") {
837
837
  const { username: projectId, password: apiKey, origin } = this.url;
838
- const url$1 = new url.URL(`/projects/${projectId}/articles/${articleId}`, origin);
838
+ const url$1 = new url.URL(`/projects/${projectId}/articles/${articleId}?buildMode=${buildMode}`, origin);
839
839
  const response = await this.fetchImpl(url$1.href, {
840
840
  headers: {
841
841
  Authorization: `Bearer ${apiKey}`
package/dist/index.mjs CHANGED
@@ -608,7 +608,7 @@ const ProjectSchema = z.object({
608
608
  files: z.array(
609
609
  z.object({
610
610
  type: z.nativeEnum(FontFileTypes),
611
- url: z.string().url()
611
+ url: z.string()
612
612
  })
613
613
  )
614
614
  }))
@@ -766,11 +766,11 @@ class Client {
766
766
  favicon: projectMeta.favicon ?? ""
767
767
  } : projectMeta;
768
768
  }
769
- async getPageData(pageSlug) {
769
+ async getPageData(pageSlug, buildMode = "default") {
770
770
  try {
771
- const project = await this.fetchProject();
771
+ const project = await this.fetchProject(buildMode);
772
772
  const articleId = this.findArticleIdByPageSlug(pageSlug, project.pages);
773
- const { article, keyframes } = await this.fetchArticle(articleId);
773
+ const { article, keyframes } = await this.fetchArticle(articleId, buildMode);
774
774
  const page = project.pages.find((page2) => page2.slug === pageSlug);
775
775
  const meta = Client.getPageMeta(project.meta, page == null ? void 0 : page.meta);
776
776
  return {
@@ -799,9 +799,9 @@ class Client {
799
799
  throw e;
800
800
  }
801
801
  }
802
- async fetchProject() {
802
+ async fetchProject(buildMode = "default") {
803
803
  const { username: projectId, password: apiKey, origin } = this.url;
804
- const url = new URL(`/projects/${projectId}`, origin);
804
+ const url = new URL(`/projects/${projectId}?buildMode=${buildMode}`, origin);
805
805
  const response = await this.fetchImpl(url.href, {
806
806
  headers: {
807
807
  Authorization: `Bearer ${apiKey}`
@@ -814,9 +814,9 @@ class Client {
814
814
  const project = ProjectSchema.parse(data);
815
815
  return project;
816
816
  }
817
- async fetchArticle(articleId) {
817
+ async fetchArticle(articleId, buildMode = "default") {
818
818
  const { username: projectId, password: apiKey, origin } = this.url;
819
- const url = new URL(`/projects/${projectId}/articles/${articleId}`, origin);
819
+ const url = new URL(`/projects/${projectId}/articles/${articleId}?buildMode=${buildMode}`, origin);
820
820
  const response = await this.fetchImpl(url.href, {
821
821
  headers: {
822
822
  Authorization: `Bearer ${apiKey}`
@@ -41,7 +41,7 @@ exports.ProjectSchema = zod_1.z.object({
41
41
  weight: zod_1.z.number(),
42
42
  files: zod_1.z.array(zod_1.z.object({
43
43
  type: zod_1.z.nativeEnum(Fonts_1.FontFileTypes),
44
- url: zod_1.z.string().url()
44
+ url: zod_1.z.string()
45
45
  }))
46
46
  }))
47
47
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cntrl-site/sdk",
3
- "version": "1.22.19",
3
+ "version": "1.22.20",
4
4
  "description": "Generic SDK for use in public websites.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",