@mx-space/byline-api-client 0.1.0 → 0.1.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/README.md CHANGED
@@ -23,8 +23,12 @@ const byline = createClient({
23
23
 
24
24
  const { data: posts, meta } = await byline.posts.list({ size: 20 })
25
25
  const { data: post } = await byline.posts.getBySlug('product', 'hello-world')
26
+ const { data: same } = await byline.posts.getBySlugOnly('hello-world')
26
27
  ```
27
28
 
29
+ `getBySlugOnly` reads a post by its slug alone (`GET /posts/slug/:slug`, one request);
30
+ old slugs resolve to the current post.
31
+
28
32
  `endpoint` is the server's API prefix (`/api/v{version}` in production). Every method
29
33
  resolves to `{ data, meta? }`, mirroring the server envelope. Responses are converted
30
34
  from the snake_case wire format to camelCase, except free-form subtrees (post `meta`,
@@ -134,7 +138,7 @@ invite to that user too (`invite.userId`).
134
138
 
135
139
  | Resource | Methods |
136
140
  | ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- |
137
- | `posts` | `list`, `get`, `getBySlug`, `getPath`, `findBySlug`, `latest`, `create`, `revise`, `update`, `setPublished`, `delete` |
141
+ | `posts` | `list`, `get`, `getBySlug`, `getBySlugOnly`, `getPath`, `findBySlug`, `latest`, `create`, `revise`, `update`, `setPublished`, `delete` |
138
142
  | `authors` | `list`, `listAll`, `get` |
139
143
  | `drafts` | `list`, `get`, `context`, `create`, `update`, `delete` |
140
144
  | `publishJobs` | `create`, `run` (create and wait) |
@@ -167,13 +171,9 @@ export const loadBlogIndex = async (locale: string, page = 1) => {
167
171
  return { posts, pagination: meta?.pagination }
168
172
  }
169
173
 
170
- export const loadBlogPost = async (
171
- locale: string,
172
- category: string,
173
- slug: string,
174
- ) => {
174
+ export const loadBlogPost = async (locale: string, slug: string) => {
175
175
  try {
176
- const { data: post, meta } = await byline.posts.getBySlug(category, slug, {
176
+ const { data: post, meta } = await byline.posts.getBySlugOnly(slug, {
177
177
  lang: locale,
178
178
  })
179
179
  return { post, seo: post.seo, translation: meta?.translation }
package/dist/index.cjs CHANGED
@@ -219,6 +219,15 @@ var DynamicComponentsResource = class {
219
219
  preserve: CATALOG_PRESERVE
220
220
  });
221
221
  }
222
+ update(id, input) {
223
+ return this.http.request("PATCH", `/dynamic-components/${encodeURIComponent(id)}`, {
224
+ body: input,
225
+ preserve: CATALOG_PRESERVE
226
+ });
227
+ }
228
+ remove(id) {
229
+ return this.http.request("DELETE", `/dynamic-components/${encodeURIComponent(id)}`, { preserve: CATALOG_PRESERVE });
230
+ }
222
231
  };
223
232
  var FilesResource = class {
224
233
  http;
@@ -331,6 +340,12 @@ var PostsResource = class {
331
340
  preserve: POST_PRESERVE
332
341
  });
333
342
  }
343
+ getBySlugOnly(slug, options = {}) {
344
+ return this.http.request("GET", `/posts/slug/${encodeURIComponent(slug)}`, {
345
+ query: { lang: options.lang ?? this.http.lang },
346
+ preserve: POST_PRESERVE
347
+ });
348
+ }
334
349
  getPath(slug) {
335
350
  return this.http.request("GET", `/posts/get-url/${encodeURIComponent(slug)}`);
336
351
  }
package/dist/index.d.cts CHANGED
@@ -383,12 +383,14 @@ interface TranslationTaskResult {
383
383
  skippedLocked: string[];
384
384
  }
385
385
  interface DynamicComponent {
386
+ id: string;
386
387
  name: string;
387
388
  description: string;
388
389
  url: string;
389
390
  initialHeight: number;
390
391
  propsSchema: Record<string, unknown>;
391
392
  parentUrl?: string;
393
+ previousUrls: string[];
392
394
  }
393
395
  interface DynamicComponentCatalog {
394
396
  version: 1;
@@ -402,6 +404,9 @@ interface RegisterDynamicComponentInput {
402
404
  propsSchema?: Record<string, unknown>;
403
405
  parentUrl?: string;
404
406
  }
407
+ type UpdateDynamicComponentInput = Partial<Omit<RegisterDynamicComponentInput, 'parentUrl'>> & {
408
+ parentUrl?: string | null;
409
+ };
405
410
  type FileType = 'image' | 'file' | 'avatar' | 'icon' | 'video' | 'audio';
406
411
  interface UploadedFile {
407
412
  url: string;
@@ -492,6 +497,8 @@ declare class DynamicComponentsResource {
492
497
  constructor(http: HttpCore);
493
498
  list(): Promise<ApiResponse<DynamicComponentCatalog, Record<string, unknown>>>;
494
499
  register(input: RegisterDynamicComponentInput): Promise<ApiResponse<DynamicComponentCatalog, Record<string, unknown>>>;
500
+ update(id: string, input: UpdateDynamicComponentInput): Promise<ApiResponse<DynamicComponentCatalog, Record<string, unknown>>>;
501
+ remove(id: string): Promise<ApiResponse<DynamicComponentCatalog, Record<string, unknown>>>;
495
502
  }
496
503
  declare class FilesResource {
497
504
  private readonly http;
@@ -571,6 +578,9 @@ declare class PostsResource {
571
578
  getBySlug(categorySlug: string, slug: string, options?: {
572
579
  lang?: string;
573
580
  }): Promise<ApiResponse<Post, PostResponseMeta>>;
581
+ getBySlugOnly(slug: string, options?: {
582
+ lang?: string;
583
+ }): Promise<ApiResponse<Post, PostResponseMeta>>;
574
584
  getPath(slug: string): Promise<ApiResponse<{
575
585
  path: string;
576
586
  }, Record<string, unknown>>>;
@@ -650,4 +660,4 @@ declare class BylineApiError extends Error {
650
660
  }
651
661
  declare const isBylineApiError: (error: unknown, code?: string) => error is BylineApiError;
652
662
  //#endregion
653
- export { type AcceptInviteInput, type AllowLoginResult, type ApiResponse, type ArticleTranslationMeta, type Author, type AuthorListQuery, type AuthorsResource, BylineApiError, BylineClient, type CategoriesResource, type Category, type CategorySummary, type ClientOptions, type ContentDocument, type ContentRevision, type CreateDraftInput, type CreateInviteInput, type CreatePublishJobInput, type CreatedInvite, type DraftBranch, type DraftRefType, type DraftWriteData, type DraftsResource, type DynamicComponent, type DynamicComponentCatalog, type DynamicComponentsResource, type EntryTranslationMeta, type FileType, type FilesResource, HttpCore, type HttpMethod, type InitUserInput, type Invite, type InviteUserInput, type InvitesResource, type LexicalEditorState, type ManualTranslationInput, type PaginatedMeta, type Pagination, type Post, type PostImage, type PostListQuery, type PostPatch, type PostResponseMeta, type PostSaveOptions, type PostSaveResult, type PostSeo, type PostSortKey, type PostWriteInput, type PostsResource, type ProfileOnlyUserInput, type PublicAuthor, type PublicInvite, type PublishAiResource, type PublishAiResourceRequest, type PublishJobsResource, type PublishTaskResult, type QueryValue, type RegisterDynamicComponentInput, type RequestOptions, type RevisionRelation, type RevisionSnapshot, type Task, type TaskRef, type TaskStatus, type TasksResource, type Translation, type TranslationPatch, type TranslationTaskInput, type TranslationTaskResult, type TranslationsResource, type UploadedFile, type UserDetail, type UserListQuery, type UserListStatus, type UserProfileInput, type UsersResource, type VersionContext, type WaitForTaskOptions, camelcaseKeys, createClient, isBylineApiError, toDraftData };
663
+ export { type AcceptInviteInput, type AllowLoginResult, type ApiResponse, type ArticleTranslationMeta, type Author, type AuthorListQuery, type AuthorsResource, BylineApiError, BylineClient, type CategoriesResource, type Category, type CategorySummary, type ClientOptions, type ContentDocument, type ContentRevision, type CreateDraftInput, type CreateInviteInput, type CreatePublishJobInput, type CreatedInvite, type DraftBranch, type DraftRefType, type DraftWriteData, type DraftsResource, type DynamicComponent, type DynamicComponentCatalog, type DynamicComponentsResource, type EntryTranslationMeta, type FileType, type FilesResource, HttpCore, type HttpMethod, type InitUserInput, type Invite, type InviteUserInput, type InvitesResource, type LexicalEditorState, type ManualTranslationInput, type PaginatedMeta, type Pagination, type Post, type PostImage, type PostListQuery, type PostPatch, type PostResponseMeta, type PostSaveOptions, type PostSaveResult, type PostSeo, type PostSortKey, type PostWriteInput, type PostsResource, type ProfileOnlyUserInput, type PublicAuthor, type PublicInvite, type PublishAiResource, type PublishAiResourceRequest, type PublishJobsResource, type PublishTaskResult, type QueryValue, type RegisterDynamicComponentInput, type RequestOptions, type RevisionRelation, type RevisionSnapshot, type Task, type TaskRef, type TaskStatus, type TasksResource, type Translation, type TranslationPatch, type TranslationTaskInput, type TranslationTaskResult, type TranslationsResource, type UpdateDynamicComponentInput, type UploadedFile, type UserDetail, type UserListQuery, type UserListStatus, type UserProfileInput, type UsersResource, type VersionContext, type WaitForTaskOptions, camelcaseKeys, createClient, isBylineApiError, toDraftData };
package/dist/index.d.ts CHANGED
@@ -383,12 +383,14 @@ interface TranslationTaskResult {
383
383
  skippedLocked: string[];
384
384
  }
385
385
  interface DynamicComponent {
386
+ id: string;
386
387
  name: string;
387
388
  description: string;
388
389
  url: string;
389
390
  initialHeight: number;
390
391
  propsSchema: Record<string, unknown>;
391
392
  parentUrl?: string;
393
+ previousUrls: string[];
392
394
  }
393
395
  interface DynamicComponentCatalog {
394
396
  version: 1;
@@ -402,6 +404,9 @@ interface RegisterDynamicComponentInput {
402
404
  propsSchema?: Record<string, unknown>;
403
405
  parentUrl?: string;
404
406
  }
407
+ type UpdateDynamicComponentInput = Partial<Omit<RegisterDynamicComponentInput, 'parentUrl'>> & {
408
+ parentUrl?: string | null;
409
+ };
405
410
  type FileType = 'image' | 'file' | 'avatar' | 'icon' | 'video' | 'audio';
406
411
  interface UploadedFile {
407
412
  url: string;
@@ -492,6 +497,8 @@ declare class DynamicComponentsResource {
492
497
  constructor(http: HttpCore);
493
498
  list(): Promise<ApiResponse<DynamicComponentCatalog, Record<string, unknown>>>;
494
499
  register(input: RegisterDynamicComponentInput): Promise<ApiResponse<DynamicComponentCatalog, Record<string, unknown>>>;
500
+ update(id: string, input: UpdateDynamicComponentInput): Promise<ApiResponse<DynamicComponentCatalog, Record<string, unknown>>>;
501
+ remove(id: string): Promise<ApiResponse<DynamicComponentCatalog, Record<string, unknown>>>;
495
502
  }
496
503
  declare class FilesResource {
497
504
  private readonly http;
@@ -571,6 +578,9 @@ declare class PostsResource {
571
578
  getBySlug(categorySlug: string, slug: string, options?: {
572
579
  lang?: string;
573
580
  }): Promise<ApiResponse<Post, PostResponseMeta>>;
581
+ getBySlugOnly(slug: string, options?: {
582
+ lang?: string;
583
+ }): Promise<ApiResponse<Post, PostResponseMeta>>;
574
584
  getPath(slug: string): Promise<ApiResponse<{
575
585
  path: string;
576
586
  }, Record<string, unknown>>>;
@@ -650,4 +660,4 @@ declare class BylineApiError extends Error {
650
660
  }
651
661
  declare const isBylineApiError: (error: unknown, code?: string) => error is BylineApiError;
652
662
  //#endregion
653
- export { type AcceptInviteInput, type AllowLoginResult, type ApiResponse, type ArticleTranslationMeta, type Author, type AuthorListQuery, type AuthorsResource, BylineApiError, BylineClient, type CategoriesResource, type Category, type CategorySummary, type ClientOptions, type ContentDocument, type ContentRevision, type CreateDraftInput, type CreateInviteInput, type CreatePublishJobInput, type CreatedInvite, type DraftBranch, type DraftRefType, type DraftWriteData, type DraftsResource, type DynamicComponent, type DynamicComponentCatalog, type DynamicComponentsResource, type EntryTranslationMeta, type FileType, type FilesResource, HttpCore, type HttpMethod, type InitUserInput, type Invite, type InviteUserInput, type InvitesResource, type LexicalEditorState, type ManualTranslationInput, type PaginatedMeta, type Pagination, type Post, type PostImage, type PostListQuery, type PostPatch, type PostResponseMeta, type PostSaveOptions, type PostSaveResult, type PostSeo, type PostSortKey, type PostWriteInput, type PostsResource, type ProfileOnlyUserInput, type PublicAuthor, type PublicInvite, type PublishAiResource, type PublishAiResourceRequest, type PublishJobsResource, type PublishTaskResult, type QueryValue, type RegisterDynamicComponentInput, type RequestOptions, type RevisionRelation, type RevisionSnapshot, type Task, type TaskRef, type TaskStatus, type TasksResource, type Translation, type TranslationPatch, type TranslationTaskInput, type TranslationTaskResult, type TranslationsResource, type UploadedFile, type UserDetail, type UserListQuery, type UserListStatus, type UserProfileInput, type UsersResource, type VersionContext, type WaitForTaskOptions, camelcaseKeys, createClient, isBylineApiError, toDraftData };
663
+ export { type AcceptInviteInput, type AllowLoginResult, type ApiResponse, type ArticleTranslationMeta, type Author, type AuthorListQuery, type AuthorsResource, BylineApiError, BylineClient, type CategoriesResource, type Category, type CategorySummary, type ClientOptions, type ContentDocument, type ContentRevision, type CreateDraftInput, type CreateInviteInput, type CreatePublishJobInput, type CreatedInvite, type DraftBranch, type DraftRefType, type DraftWriteData, type DraftsResource, type DynamicComponent, type DynamicComponentCatalog, type DynamicComponentsResource, type EntryTranslationMeta, type FileType, type FilesResource, HttpCore, type HttpMethod, type InitUserInput, type Invite, type InviteUserInput, type InvitesResource, type LexicalEditorState, type ManualTranslationInput, type PaginatedMeta, type Pagination, type Post, type PostImage, type PostListQuery, type PostPatch, type PostResponseMeta, type PostSaveOptions, type PostSaveResult, type PostSeo, type PostSortKey, type PostWriteInput, type PostsResource, type ProfileOnlyUserInput, type PublicAuthor, type PublicInvite, type PublishAiResource, type PublishAiResourceRequest, type PublishJobsResource, type PublishTaskResult, type QueryValue, type RegisterDynamicComponentInput, type RequestOptions, type RevisionRelation, type RevisionSnapshot, type Task, type TaskRef, type TaskStatus, type TasksResource, type Translation, type TranslationPatch, type TranslationTaskInput, type TranslationTaskResult, type TranslationsResource, type UpdateDynamicComponentInput, type UploadedFile, type UserDetail, type UserListQuery, type UserListStatus, type UserProfileInput, type UsersResource, type VersionContext, type WaitForTaskOptions, camelcaseKeys, createClient, isBylineApiError, toDraftData };
package/dist/index.js CHANGED
@@ -218,6 +218,15 @@ var DynamicComponentsResource = class {
218
218
  preserve: CATALOG_PRESERVE
219
219
  });
220
220
  }
221
+ update(id, input) {
222
+ return this.http.request("PATCH", `/dynamic-components/${encodeURIComponent(id)}`, {
223
+ body: input,
224
+ preserve: CATALOG_PRESERVE
225
+ });
226
+ }
227
+ remove(id) {
228
+ return this.http.request("DELETE", `/dynamic-components/${encodeURIComponent(id)}`, { preserve: CATALOG_PRESERVE });
229
+ }
221
230
  };
222
231
  var FilesResource = class {
223
232
  http;
@@ -330,6 +339,12 @@ var PostsResource = class {
330
339
  preserve: POST_PRESERVE
331
340
  });
332
341
  }
342
+ getBySlugOnly(slug, options = {}) {
343
+ return this.http.request("GET", `/posts/slug/${encodeURIComponent(slug)}`, {
344
+ query: { lang: options.lang ?? this.http.lang },
345
+ preserve: POST_PRESERVE
346
+ });
347
+ }
333
348
  getPath(slug) {
334
349
  return this.http.request("GET", `/posts/get-url/${encodeURIComponent(slug)}`);
335
350
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mx-space/byline-api-client",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Typed fetch client for the Byline headless CMS API",
5
5
  "keywords": [
6
6
  "byline",