@oblax/cms 0.0.0-stage → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cms-module.d.ts +57 -0
- package/dist/cms-module.d.ts.map +1 -0
- package/dist/cms-module.js +56 -0
- package/dist/cms-module.js.map +1 -0
- package/dist/content-types.d.ts +36 -0
- package/dist/content-types.d.ts.map +1 -0
- package/dist/content-types.js +69 -0
- package/dist/content-types.js.map +1 -0
- package/dist/entries.d.ts +84 -0
- package/dist/entries.d.ts.map +1 -0
- package/dist/entries.js +170 -0
- package/dist/entries.js.map +1 -0
- package/dist/index.d.ts +42 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +46 -0
- package/dist/index.js.map +1 -0
- package/dist/navigations.d.ts +49 -0
- package/dist/navigations.d.ts.map +1 -0
- package/dist/navigations.js +79 -0
- package/dist/navigations.js.map +1 -0
- package/dist/public.d.ts +57 -0
- package/dist/public.d.ts.map +1 -0
- package/dist/public.js +106 -0
- package/dist/public.js.map +1 -0
- package/dist/redirects.d.ts +31 -0
- package/dist/redirects.d.ts.map +1 -0
- package/dist/redirects.js +51 -0
- package/dist/redirects.js.map +1 -0
- package/dist/references.d.ts +18 -0
- package/dist/references.d.ts.map +1 -0
- package/dist/references.js +20 -0
- package/dist/references.js.map +1 -0
- package/dist/sections.d.ts +32 -0
- package/dist/sections.d.ts.map +1 -0
- package/dist/sections.js +51 -0
- package/dist/sections.js.map +1 -0
- package/dist/settings.d.ts +22 -0
- package/dist/settings.d.ts.map +1 -0
- package/dist/settings.js +28 -0
- package/dist/settings.js.map +1 -0
- package/dist/terms.d.ts +40 -0
- package/dist/terms.d.ts.map +1 -0
- package/dist/terms.js +74 -0
- package/dist/terms.js.map +1 -0
- package/dist/types.d.ts +789 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/vocabularies.d.ts +32 -0
- package/dist/vocabularies.d.ts.map +1 -0
- package/dist/vocabularies.js +45 -0
- package/dist/vocabularies.js.map +1 -0
- package/package.json +48 -3
- package/README.md +0 -3
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { OblaxContext } from '@oblax/core';
|
|
2
|
+
import type { CmsList, CodeParams, CreateNavigationParams, GetNavigationParams, ListNavigationVersionsParams, Navigation, NavigationVersion, RestoreNavigationParams, UpdateNavigationParams } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Manages navigations (menus). They're live as soon as they're saved, and
|
|
5
|
+
* every save keeps a version. Frontends read them through `cms.public`.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* const nav = await oblax.cms.navigations.create({
|
|
10
|
+
* code: 'main',
|
|
11
|
+
* name: 'Main menu',
|
|
12
|
+
* group: 'web',
|
|
13
|
+
* items: [
|
|
14
|
+
* { kind: 'page', target: 'entry-id' },
|
|
15
|
+
* { kind: 'external', target: 'https://example.com', label: { en: 'Docs' }, new_tab: true },
|
|
16
|
+
* ],
|
|
17
|
+
* })
|
|
18
|
+
*
|
|
19
|
+
* // A save replaces the navigation whole: send every setting back
|
|
20
|
+
* await oblax.cms.navigations.update({
|
|
21
|
+
* code: 'main',
|
|
22
|
+
* modified: nav._modified!,
|
|
23
|
+
* name: nav.name,
|
|
24
|
+
* group: nav.group,
|
|
25
|
+
* locale: nav.locale,
|
|
26
|
+
* itemFields: nav.item_fields,
|
|
27
|
+
* missingTranslation: nav.missing_translation,
|
|
28
|
+
* items: [...nav.items, { kind: 'section', target: 'section-id' }],
|
|
29
|
+
* })
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export declare class NavigationsSubmodule {
|
|
33
|
+
private readonly ctx;
|
|
34
|
+
constructor(ctx: OblaxContext);
|
|
35
|
+
list(): Promise<CmsList<Navigation>>;
|
|
36
|
+
/** Returns a navigation, each item with why readers don't see it (`problem`) in `locale`. */
|
|
37
|
+
get(params: GetNavigationParams): Promise<Navigation>;
|
|
38
|
+
/** Creates a navigation; items without an id get one. */
|
|
39
|
+
create(params: CreateNavigationParams): Promise<Navigation>;
|
|
40
|
+
/** Replaces the navigation whole (send every setting), puts it live and keeps a version. */
|
|
41
|
+
update(params: UpdateNavigationParams): Promise<Navigation>;
|
|
42
|
+
/** Deletes a navigation; frontends asking for it get a 404. */
|
|
43
|
+
delete(params: CodeParams): Promise<void>;
|
|
44
|
+
/** Lists the navigation's saved versions, newest first, without their content. */
|
|
45
|
+
listVersions(params: ListNavigationVersionsParams): Promise<CmsList<NavigationVersion>>;
|
|
46
|
+
/** Saves a version of the navigation again. */
|
|
47
|
+
restore(params: RestoreNavigationParams): Promise<Navigation>;
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=navigations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"navigations.d.ts","sourceRoot":"","sources":["../src/navigations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE/C,OAAO,KAAK,EACV,OAAO,EACP,UAAU,EACV,sBAAsB,EACtB,mBAAmB,EACnB,4BAA4B,EAC5B,UAAU,EAEV,iBAAiB,EACjB,uBAAuB,EACvB,sBAAsB,EACvB,MAAM,YAAY,CAAA;AAanB;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,qBAAa,oBAAoB;IACnB,OAAO,CAAC,QAAQ,CAAC,GAAG;gBAAH,GAAG,EAAE,YAAY;IAExC,IAAI,IAAI,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IAI1C,6FAA6F;IACvF,GAAG,CAAC,MAAM,EAAE,mBAAmB,GAAG,OAAO,CAAC,UAAU,CAAC;IAM3D,yDAAyD;IACnD,MAAM,CAAC,MAAM,EAAE,sBAAsB,GAAG,OAAO,CAAC,UAAU,CAAC;IAIjE,4FAA4F;IACtF,MAAM,CAAC,MAAM,EAAE,sBAAsB,GAAG,OAAO,CAAC,UAAU,CAAC;IAOjE,+DAA+D;IACzD,MAAM,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;IAI/C,kFAAkF;IAC5E,YAAY,CAAC,MAAM,EAAE,4BAA4B,GAAG,OAAO,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC;IAM7F,+CAA+C;IACzC,OAAO,CAAC,MAAM,EAAE,uBAAuB,GAAG,OAAO,CAAC,UAAU,CAAC;CAMpE"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { buildQuery as query, pathSegment as seg } from '@oblax/core';
|
|
2
|
+
function toApi(p) {
|
|
3
|
+
return {
|
|
4
|
+
name: p.name,
|
|
5
|
+
group: p.group,
|
|
6
|
+
locale: p.locale,
|
|
7
|
+
item_fields: p.itemFields,
|
|
8
|
+
items: p.items,
|
|
9
|
+
missing_translation: p.missingTranslation,
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Manages navigations (menus). They're live as soon as they're saved, and
|
|
14
|
+
* every save keeps a version. Frontends read them through `cms.public`.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* const nav = await oblax.cms.navigations.create({
|
|
19
|
+
* code: 'main',
|
|
20
|
+
* name: 'Main menu',
|
|
21
|
+
* group: 'web',
|
|
22
|
+
* items: [
|
|
23
|
+
* { kind: 'page', target: 'entry-id' },
|
|
24
|
+
* { kind: 'external', target: 'https://example.com', label: { en: 'Docs' }, new_tab: true },
|
|
25
|
+
* ],
|
|
26
|
+
* })
|
|
27
|
+
*
|
|
28
|
+
* // A save replaces the navigation whole: send every setting back
|
|
29
|
+
* await oblax.cms.navigations.update({
|
|
30
|
+
* code: 'main',
|
|
31
|
+
* modified: nav._modified!,
|
|
32
|
+
* name: nav.name,
|
|
33
|
+
* group: nav.group,
|
|
34
|
+
* locale: nav.locale,
|
|
35
|
+
* itemFields: nav.item_fields,
|
|
36
|
+
* missingTranslation: nav.missing_translation,
|
|
37
|
+
* items: [...nav.items, { kind: 'section', target: 'section-id' }],
|
|
38
|
+
* })
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
export class NavigationsSubmodule {
|
|
42
|
+
constructor(ctx) {
|
|
43
|
+
this.ctx = ctx;
|
|
44
|
+
}
|
|
45
|
+
async list() {
|
|
46
|
+
return this.ctx.http.get('/cms/navigations');
|
|
47
|
+
}
|
|
48
|
+
/** Returns a navigation, each item with why readers don't see it (`problem`) in `locale`. */
|
|
49
|
+
async get(params) {
|
|
50
|
+
return this.ctx.http.get(`/cms/navigations/${seg(params.code)}${query({ locale: params.locale })}`);
|
|
51
|
+
}
|
|
52
|
+
/** Creates a navigation; items without an id get one. */
|
|
53
|
+
async create(params) {
|
|
54
|
+
return this.ctx.http.post('/cms/navigations', { ...toApi(params), code: params.code });
|
|
55
|
+
}
|
|
56
|
+
/** Replaces the navigation whole (send every setting), puts it live and keeps a version. */
|
|
57
|
+
async update(params) {
|
|
58
|
+
return this.ctx.http.put(`/cms/navigations/${seg(params.code)}`, {
|
|
59
|
+
...toApi(params),
|
|
60
|
+
_modified: params.modified,
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
/** Deletes a navigation; frontends asking for it get a 404. */
|
|
64
|
+
async delete(params) {
|
|
65
|
+
return this.ctx.http.delete(`/cms/navigations/${seg(params.code)}`);
|
|
66
|
+
}
|
|
67
|
+
/** Lists the navigation's saved versions, newest first, without their content. */
|
|
68
|
+
async listVersions(params) {
|
|
69
|
+
return this.ctx.http.get(`/cms/navigations/${seg(params.code)}/versions${query({ limit: params.limit })}`);
|
|
70
|
+
}
|
|
71
|
+
/** Saves a version of the navigation again. */
|
|
72
|
+
async restore(params) {
|
|
73
|
+
return this.ctx.http.post(`/cms/navigations/${seg(params.code)}:restore`, {
|
|
74
|
+
version_id: params.versionId,
|
|
75
|
+
_modified: params.modified,
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79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,CAAC;IAED,4FAA4F;IAC5F,KAAK,CAAC,MAAM,CAAC,MAA8B;QACzC,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAa,oBAAoB,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,EAAE;YAC3E,GAAG,KAAK,CAAC,MAAM,CAAC;YAChB,SAAS,EAAE,MAAM,CAAC,QAAQ;SAC3B,CAAC,CAAA;IACJ,CAAC;IAED,+DAA+D;IAC/D,KAAK,CAAC,MAAM,CAAC,MAAkB;QAC7B,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAO,oBAAoB,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IAC3E,CAAC;IAED,kFAAkF;IAClF,KAAK,CAAC,YAAY,CAAC,MAAoC;QACrD,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CACtB,oBAAoB,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,YAAY,KAAK,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC,EAAE,CACjF,CAAA;IACH,CAAC;IAED,+CAA+C;IAC/C,KAAK,CAAC,OAAO,CAAC,MAA+B;QAC3C,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAa,oBAAoB,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,EAAE;YACpF,UAAU,EAAE,MAAM,CAAC,SAAS;YAC5B,SAAS,EAAG,MAAM,CAAC,QAAQ;SAC5B,CAAC,CAAA;IACJ,CAAC;CACF"}
|
package/dist/public.d.ts
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { OblaxContext } from '@oblax/core';
|
|
2
|
+
import type { CmsConfig, PublicEntriesParams, PublicEntry, PublicEntryParams, PublicNavigation, PublicNavigationParams, PublicNavigationsParams, PublicPage, PublicRoute, PublicRoutesParams, PublicTerm, PublicTermParams, PublicTermsParams, Resolved, ResolveParams } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Reads live content the way a website or app shows it: what lives at a
|
|
5
|
+
* path, entry lists, terms and navigations. With a preview token from
|
|
6
|
+
* `entries.preview()`, reads return the working copy instead.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* // Render whatever lives at the requested path
|
|
11
|
+
* const page = await oblax.cms.public.resolve({ path: '/blog/2026/hello', locale: 'en' })
|
|
12
|
+
* if (page.kind === 'redirect') redirect(page.status!, page.location!)
|
|
13
|
+
*
|
|
14
|
+
* // Blog index
|
|
15
|
+
* const posts = await oblax.cms.public.entries({ section: 'blog', locale: 'en', limit: 10 })
|
|
16
|
+
*
|
|
17
|
+
* // Menus for the web frontend
|
|
18
|
+
* const { items } = await oblax.cms.public.navigations({ group: 'web', locale: 'en' })
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export declare class PublicSubmodule {
|
|
22
|
+
private readonly ctx;
|
|
23
|
+
private readonly config;
|
|
24
|
+
constructor(ctx: OblaxContext, config: CmsConfig);
|
|
25
|
+
private options;
|
|
26
|
+
/**
|
|
27
|
+
* Says what lives at a path: an entry, section or term, a redirect (with
|
|
28
|
+
* `status` and `location`), or `gone`. Nothing there is a 404.
|
|
29
|
+
*/
|
|
30
|
+
resolve(params: ResolveParams): Promise<Resolved>;
|
|
31
|
+
/** Lists a locale's live paths, for sitemaps and static builds. */
|
|
32
|
+
routes(params?: PublicRoutesParams): Promise<PublicPage<PublicRoute>>;
|
|
33
|
+
/**
|
|
34
|
+
* Lists live entries without their bodies. A section sorts and pages its
|
|
35
|
+
* articles its own way; other lists are newest first.
|
|
36
|
+
*/
|
|
37
|
+
entries(params?: PublicEntriesParams): Promise<PublicPage<PublicEntry>>;
|
|
38
|
+
/** Returns a live entry, or its translation in `locale`. */
|
|
39
|
+
entry(params: PublicEntryParams): Promise<PublicEntry>;
|
|
40
|
+
/**
|
|
41
|
+
* Lists a vocabulary's terms in a locale: a page at a time (parents first,
|
|
42
|
+
* siblings by position), or with `tree: true` all at once, nested.
|
|
43
|
+
*/
|
|
44
|
+
terms(params: PublicTermsParams): Promise<PublicPage<PublicTerm>>;
|
|
45
|
+
/** Returns a term in a locale. An alias returns the term it's merged into. */
|
|
46
|
+
term(params: PublicTermParams): Promise<PublicTerm>;
|
|
47
|
+
/** Returns a frontend's navigations, built for the locale and the caller. */
|
|
48
|
+
navigations(params: PublicNavigationsParams): Promise<{
|
|
49
|
+
items: PublicNavigation[];
|
|
50
|
+
}>;
|
|
51
|
+
/**
|
|
52
|
+
* Returns a navigation built for the locale and the caller: items for
|
|
53
|
+
* another audience are left out, and `depth` cuts the tree.
|
|
54
|
+
*/
|
|
55
|
+
navigation(params: PublicNavigationParams): Promise<PublicNavigation>;
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=public.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"public.d.ts","sourceRoot":"","sources":["../src/public.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAkB,MAAM,aAAa,CAAA;AAE/D,OAAO,KAAK,EACV,SAAS,EACT,mBAAmB,EACnB,WAAW,EACX,iBAAiB,EACjB,gBAAgB,EAChB,sBAAsB,EACtB,uBAAuB,EACvB,UAAU,EACV,WAAW,EACX,kBAAkB,EAClB,UAAU,EACV,gBAAgB,EAChB,iBAAiB,EACjB,QAAQ,EACR,aAAa,EACd,MAAM,YAAY,CAAA;AAKnB;;;;;;;;;;;;;;;;;GAiBG;AACH,qBAAa,eAAe;IAExB,OAAO,CAAC,QAAQ,CAAC,GAAG;IACpB,OAAO,CAAC,QAAQ,CAAC,MAAM;gBADN,GAAG,EAAE,YAAY,EACjB,MAAM,EAAE,SAAS;IAGpC,OAAO,CAAC,OAAO;IAMf;;;OAGG;IACG,OAAO,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,QAAQ,CAAC;IAUvD,mEAAmE;IAC7D,MAAM,CAAC,MAAM,GAAE,kBAAuB,GAAG,OAAO,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;IAK/E;;;OAGG;IACG,OAAO,CAAC,MAAM,GAAE,mBAAwB,GAAG,OAAO,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;IAkBjF,4DAA4D;IACtD,KAAK,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,WAAW,CAAC;IAQ5D;;;OAGG;IACG,KAAK,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;IAcvE,8EAA8E;IACxE,IAAI,CAAC,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAAC,UAAU,CAAC;IAMzD,6EAA6E;IACvE,WAAW,CAAC,MAAM,EAAE,uBAAuB,GAAG,OAAO,CAAC;QAAE,KAAK,EAAE,gBAAgB,EAAE,CAAA;KAAE,CAAC;IAK1F;;;OAGG;IACG,UAAU,CAAC,MAAM,EAAE,sBAAsB,GAAG,OAAO,CAAC,gBAAgB,CAAC;CAI5E"}
|
package/dist/public.js
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { filterPairs, buildQuery as query, pathSegment as seg } from '@oblax/core';
|
|
2
|
+
/** Header that makes file URLs in public reads absolute. */
|
|
3
|
+
const FILES_BASE_HEADER = 'X-Oblax-Files-Base';
|
|
4
|
+
/**
|
|
5
|
+
* Reads live content the way a website or app shows it: what lives at a
|
|
6
|
+
* path, entry lists, terms and navigations. With a preview token from
|
|
7
|
+
* `entries.preview()`, reads return the working copy instead.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* // Render whatever lives at the requested path
|
|
12
|
+
* const page = await oblax.cms.public.resolve({ path: '/blog/2026/hello', locale: 'en' })
|
|
13
|
+
* if (page.kind === 'redirect') redirect(page.status!, page.location!)
|
|
14
|
+
*
|
|
15
|
+
* // Blog index
|
|
16
|
+
* const posts = await oblax.cms.public.entries({ section: 'blog', locale: 'en', limit: 10 })
|
|
17
|
+
*
|
|
18
|
+
* // Menus for the web frontend
|
|
19
|
+
* const { items } = await oblax.cms.public.navigations({ group: 'web', locale: 'en' })
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export class PublicSubmodule {
|
|
23
|
+
constructor(ctx, config) {
|
|
24
|
+
this.ctx = ctx;
|
|
25
|
+
this.config = config;
|
|
26
|
+
}
|
|
27
|
+
options() {
|
|
28
|
+
return this.config.filesBase
|
|
29
|
+
? { headers: { [FILES_BASE_HEADER]: this.config.filesBase } }
|
|
30
|
+
: undefined;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Says what lives at a path: an entry, section or term, a redirect (with
|
|
34
|
+
* `status` and `location`), or `gone`. Nothing there is a 404.
|
|
35
|
+
*/
|
|
36
|
+
async resolve(params) {
|
|
37
|
+
const qs = query({
|
|
38
|
+
path: params.path,
|
|
39
|
+
locale: params.locale,
|
|
40
|
+
full: params.full,
|
|
41
|
+
preview: params.preview,
|
|
42
|
+
});
|
|
43
|
+
return this.ctx.http.get(`/cms/public/resolve${qs}`, this.options());
|
|
44
|
+
}
|
|
45
|
+
/** Lists a locale's live paths, for sitemaps and static builds. */
|
|
46
|
+
async routes(params = {}) {
|
|
47
|
+
const qs = query({ locale: params.locale, cursor: params.cursor, limit: params.limit });
|
|
48
|
+
return this.ctx.http.get(`/cms/public/routes${qs}`);
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Lists live entries without their bodies. A section sorts and pages its
|
|
52
|
+
* articles its own way; other lists are newest first.
|
|
53
|
+
*/
|
|
54
|
+
async entries(params = {}) {
|
|
55
|
+
const qs = query({
|
|
56
|
+
type: params.type,
|
|
57
|
+
section: params.section,
|
|
58
|
+
term: params.term,
|
|
59
|
+
direct: params.direct,
|
|
60
|
+
locale: params.locale,
|
|
61
|
+
full: params.full,
|
|
62
|
+
preview: params.preview,
|
|
63
|
+
cursor: params.cursor,
|
|
64
|
+
limit: params.limit,
|
|
65
|
+
}, filterPairs(params.filters));
|
|
66
|
+
return this.ctx.http.get(`/cms/public/entries${qs}`, this.options());
|
|
67
|
+
}
|
|
68
|
+
/** Returns a live entry, or its translation in `locale`. */
|
|
69
|
+
async entry(params) {
|
|
70
|
+
const qs = query({ locale: params.locale, full: params.full, preview: params.preview });
|
|
71
|
+
return this.ctx.http.get(`/cms/public/entries/${seg(params.id)}${qs}`, this.options());
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Lists a vocabulary's terms in a locale: a page at a time (parents first,
|
|
75
|
+
* siblings by position), or with `tree: true` all at once, nested.
|
|
76
|
+
*/
|
|
77
|
+
async terms(params) {
|
|
78
|
+
const qs = query({
|
|
79
|
+
locale: params.locale,
|
|
80
|
+
parent: params.parent,
|
|
81
|
+
tree: params.tree,
|
|
82
|
+
counts: params.counts,
|
|
83
|
+
cursor: params.cursor,
|
|
84
|
+
limit: params.limit,
|
|
85
|
+
});
|
|
86
|
+
return this.ctx.http.get(`/cms/public/vocabularies/${seg(params.vocabulary)}/terms${qs}`);
|
|
87
|
+
}
|
|
88
|
+
/** Returns a term in a locale. An alias returns the term it's merged into. */
|
|
89
|
+
async term(params) {
|
|
90
|
+
return this.ctx.http.get(`/cms/public/terms/${seg(params.id)}${query({ locale: params.locale })}`);
|
|
91
|
+
}
|
|
92
|
+
/** Returns a frontend's navigations, built for the locale and the caller. */
|
|
93
|
+
async navigations(params) {
|
|
94
|
+
const qs = query({ group: params.group, locale: params.locale, depth: params.depth });
|
|
95
|
+
return this.ctx.http.get(`/cms/public/navigations${qs}`);
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Returns a navigation built for the locale and the caller: items for
|
|
99
|
+
* another audience are left out, and `depth` cuts the tree.
|
|
100
|
+
*/
|
|
101
|
+
async navigation(params) {
|
|
102
|
+
const qs = query({ locale: params.locale, depth: params.depth });
|
|
103
|
+
return this.ctx.http.get(`/cms/public/navigations/${seg(params.code)}${qs}`);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
//# sourceMappingURL=public.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"public.js","sourceRoot":"","sources":["../src/public.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,UAAU,IAAI,KAAK,EAAE,WAAW,IAAI,GAAG,EAAE,MAAM,aAAa,CAAA;AAmBlF,4DAA4D;AAC5D,MAAM,iBAAiB,GAAG,oBAAoB,CAAA;AAE9C;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,OAAO,eAAe;IAC1B,YACmB,GAAiB,EACjB,MAAiB;QADjB,QAAG,GAAH,GAAG,CAAc;QACjB,WAAM,GAAN,MAAM,CAAW;IACjC,CAAC;IAEI,OAAO;QACb,OAAO,IAAI,CAAC,MAAM,CAAC,SAAS;YAC1B,CAAC,CAAC,EAAE,OAAO,EAAE,EAAE,CAAC,iBAAiB,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,EAAE;YAC7D,CAAC,CAAC,SAAS,CAAA;IACf,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,OAAO,CAAC,MAAqB;QACjC,MAAM,EAAE,GAAG,KAAK,CAAC;YACf,IAAI,EAAK,MAAM,CAAC,IAAI;YACpB,MAAM,EAAG,MAAM,CAAC,MAAM;YACtB,IAAI,EAAK,MAAM,CAAC,IAAI;YACpB,OAAO,EAAE,MAAM,CAAC,OAAO;SACxB,CAAC,CAAA;QACF,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAW,sBAAsB,EAAE,EAAE,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC,CAAA;IAChF,CAAC;IAED,mEAAmE;IACnE,KAAK,CAAC,MAAM,CAAC,SAA6B,EAAE;QAC1C,MAAM,EAAE,GAAG,KAAK,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE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GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC,CAAA;IAChG,CAAC;CACF"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { OblaxContext } from '@oblax/core';
|
|
2
|
+
import type { CmsList, CreateRedirectParams, IdParams, ListRedirectsParams, Redirect, UpdateRedirectParams } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Manages redirects. The CMS adds automatic ones when content moves; these
|
|
5
|
+
* routes manage both kinds and add manual ones.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* await oblax.cms.redirects.create({ from: '/old', toKind: 'path', to: '/new', status: 301 })
|
|
10
|
+
*
|
|
11
|
+
* const { data } = await oblax.cms.redirects.list({
|
|
12
|
+
* filters: [{ field: 'source', op: 'eq', value: 'manual' }],
|
|
13
|
+
* })
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export declare class RedirectsSubmodule {
|
|
17
|
+
private readonly ctx;
|
|
18
|
+
constructor(ctx: OblaxContext);
|
|
19
|
+
/** Lists redirects, newest first. Filter on `locale`, `source`, `to_kind`, ... */
|
|
20
|
+
list(params?: ListRedirectsParams): Promise<CmsList<Redirect>>;
|
|
21
|
+
get(params: IdParams): Promise<Redirect>;
|
|
22
|
+
/**
|
|
23
|
+
* Adds a manual redirect. A chain is stored as one hop, a loop is refused,
|
|
24
|
+
* and a path that has content can't be redirected.
|
|
25
|
+
*/
|
|
26
|
+
create(params: CreateRedirectParams): Promise<Redirect>;
|
|
27
|
+
/** Replaces a redirect whole (send every field); it's checked as a new one is. */
|
|
28
|
+
update(params: UpdateRedirectParams): Promise<Redirect>;
|
|
29
|
+
delete(params: IdParams): Promise<void>;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=redirects.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"redirects.d.ts","sourceRoot":"","sources":["../src/redirects.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE/C,OAAO,KAAK,EACV,OAAO,EACP,oBAAoB,EACpB,QAAQ,EACR,mBAAmB,EACnB,QAAQ,EAER,oBAAoB,EACrB,MAAM,YAAY,CAAA;AAanB;;;;;;;;;;;;GAYG;AACH,qBAAa,kBAAkB;IACjB,OAAO,CAAC,QAAQ,CAAC,GAAG;gBAAH,GAAG,EAAE,YAAY;IAE9C,kFAAkF;IAC5E,IAAI,CAAC,MAAM,GAAE,mBAAwB,GAAG,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IAIlE,GAAG,CAAC,MAAM,EAAE,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;IAI9C;;;OAGG;IACG,MAAM,CAAC,MAAM,EAAE,oBAAoB,GAAG,OAAO,CAAC,QAAQ,CAAC;IAI7D,kFAAkF;IAC5E,MAAM,CAAC,MAAM,EAAE,oBAAoB,GAAG,OAAO,CAAC,QAAQ,CAAC;IAIvD,MAAM,CAAC,MAAM,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;CAG9C"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { listPairs, buildQuery as query, pathSegment as seg } from '@oblax/core';
|
|
2
|
+
function toApi(p) {
|
|
3
|
+
return {
|
|
4
|
+
locale: p.locale ?? '',
|
|
5
|
+
from: p.from,
|
|
6
|
+
to_kind: p.toKind,
|
|
7
|
+
to: p.to,
|
|
8
|
+
status: p.status,
|
|
9
|
+
note: p.note,
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Manages redirects. The CMS adds automatic ones when content moves; these
|
|
14
|
+
* routes manage both kinds and add manual ones.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* await oblax.cms.redirects.create({ from: '/old', toKind: 'path', to: '/new', status: 301 })
|
|
19
|
+
*
|
|
20
|
+
* const { data } = await oblax.cms.redirects.list({
|
|
21
|
+
* filters: [{ field: 'source', op: 'eq', value: 'manual' }],
|
|
22
|
+
* })
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export class RedirectsSubmodule {
|
|
26
|
+
constructor(ctx) {
|
|
27
|
+
this.ctx = ctx;
|
|
28
|
+
}
|
|
29
|
+
/** Lists redirects, newest first. Filter on `locale`, `source`, `to_kind`, ... */
|
|
30
|
+
async list(params = {}) {
|
|
31
|
+
return this.ctx.http.get(`/cms/redirects${query({}, listPairs(params))}`);
|
|
32
|
+
}
|
|
33
|
+
async get(params) {
|
|
34
|
+
return this.ctx.http.get(`/cms/redirects/${seg(params.id)}`);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Adds a manual redirect. A chain is stored as one hop, a loop is refused,
|
|
38
|
+
* and a path that has content can't be redirected.
|
|
39
|
+
*/
|
|
40
|
+
async create(params) {
|
|
41
|
+
return this.ctx.http.post('/cms/redirects', toApi(params));
|
|
42
|
+
}
|
|
43
|
+
/** Replaces a redirect whole (send every field); it's checked as a new one is. */
|
|
44
|
+
async update(params) {
|
|
45
|
+
return this.ctx.http.put(`/cms/redirects/${seg(params.id)}`, toApi(params));
|
|
46
|
+
}
|
|
47
|
+
async delete(params) {
|
|
48
|
+
return this.ctx.http.delete(`/cms/redirects/${seg(params.id)}`);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=redirects.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"redirects.js","sourceRoot":"","sources":["../src/redirects.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,UAAU,IAAI,KAAK,EAAE,WAAW,IAAI,GAAG,EAAE,MAAM,aAAa,CAAA;AAWhF,SAAS,KAAK,CAAC,CAAgB;IAC7B,OAAO;QACL,MAAM,EAAG,CAAC,CAAC,MAAM,IAAI,EAAE;QACvB,IAAI,EAAK,CAAC,CAAC,IAAI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
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { OblaxContext } from '@oblax/core';
|
|
2
|
+
import type { CmsList, ListReferencesParams, ReferenceUse } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Finds the entries that point at a record (a file, entry, term or author),
|
|
5
|
+
* e.g. before deleting it.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* const { data } = await oblax.cms.references.list({ kind: 'file', id: 'file-id' })
|
|
10
|
+
* ```
|
|
11
|
+
*/
|
|
12
|
+
export declare class ReferencesSubmodule {
|
|
13
|
+
private readonly ctx;
|
|
14
|
+
constructor(ctx: OblaxContext);
|
|
15
|
+
/** Lists the entry copies that point at the record, working and live copies apart. */
|
|
16
|
+
list(params: ListReferencesParams): Promise<CmsList<ReferenceUse>>;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=references.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"references.d.ts","sourceRoot":"","sources":["../src/references.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE/C,OAAO,KAAK,EAAE,OAAO,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAE7E;;;;;;;;GAQG;AACH,qBAAa,mBAAmB;IAClB,OAAO,CAAC,QAAQ,CAAC,GAAG;gBAAH,GAAG,EAAE,YAAY;IAE9C,sFAAsF;IAChF,IAAI,CAAC,MAAM,EAAE,oBAAoB,GAAG,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;CAKzE"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { buildQuery as query } from '@oblax/core';
|
|
2
|
+
/**
|
|
3
|
+
* Finds the entries that point at a record (a file, entry, term or author),
|
|
4
|
+
* e.g. before deleting it.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```typescript
|
|
8
|
+
* const { data } = await oblax.cms.references.list({ kind: 'file', id: 'file-id' })
|
|
9
|
+
* ```
|
|
10
|
+
*/
|
|
11
|
+
export class ReferencesSubmodule {
|
|
12
|
+
constructor(ctx) {
|
|
13
|
+
this.ctx = ctx;
|
|
14
|
+
}
|
|
15
|
+
/** Lists the entry copies that point at the record, working and live copies apart. */
|
|
16
|
+
async list(params) {
|
|
17
|
+
return this.ctx.http.get(`/cms/references${query({ kind: params.kind, id: params.id })}`);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=references.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"references.js","sourceRoot":"","sources":["../src/references.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,IAAI,KAAK,EAAE,MAAM,aAAa,CAAA;AAGjD;;;;;;;;GAQG;AACH,MAAM,OAAO,mBAAmB;IAC9B,YAA6B,GAAiB;QAAjB,QAAG,GAAH,GAAG,CAAc;IAAG,CAAC;IAElD,sFAAsF;IACtF,KAAK,CAAC,IAAI,CAAC,MAA4B;QACrC,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CACtB,kBAAkB,KAAK,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE,CAAC,EAAE,CAChE,CAAA;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { OblaxContext } from '@oblax/core';
|
|
2
|
+
import type { CmsList, CodeParams, CreateSectionParams, Section, UpdateSectionParams } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Manages sections: where articles live (`/blog`, `/news`) and how their
|
|
5
|
+
* paths are built.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* await oblax.cms.sections.create({
|
|
10
|
+
* code: 'blog',
|
|
11
|
+
* name: { en: 'Blog' },
|
|
12
|
+
* basePaths: { en: '/blog' },
|
|
13
|
+
* pattern: '{yyyy}/{slug}',
|
|
14
|
+
* })
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export declare class SectionsSubmodule {
|
|
18
|
+
private readonly ctx;
|
|
19
|
+
constructor(ctx: OblaxContext);
|
|
20
|
+
list(): Promise<CmsList<Section>>;
|
|
21
|
+
get(params: CodeParams): Promise<Section>;
|
|
22
|
+
/** Creates a section; left out, articles go at `<base path>/<slug>`, newest first, 20 a page. */
|
|
23
|
+
create(params: CreateSectionParams): Promise<Section>;
|
|
24
|
+
/**
|
|
25
|
+
* Updates a section. Names and base paths given replace the old ones whole.
|
|
26
|
+
* New base paths or a new pattern move the section's articles.
|
|
27
|
+
*/
|
|
28
|
+
update(params: UpdateSectionParams): Promise<Section>;
|
|
29
|
+
/** Deletes a section without articles that no type lists. */
|
|
30
|
+
delete(params: CodeParams): Promise<void>;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=sections.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sections.d.ts","sourceRoot":"","sources":["../src/sections.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE/C,OAAO,KAAK,EACV,OAAO,EACP,UAAU,EACV,mBAAmB,EACnB,OAAO,EAEP,mBAAmB,EACpB,MAAM,YAAY,CAAA;AAYnB;;;;;;;;;;;;;GAaG;AACH,qBAAa,iBAAiB;IAChB,OAAO,CAAC,QAAQ,CAAC,GAAG;gBAAH,GAAG,EAAE,YAAY;IAExC,IAAI,IAAI,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IAIjC,GAAG,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC;IAI/C,iGAAiG;IAC3F,MAAM,CAAC,MAAM,EAAE,mBAAmB,GAAG,OAAO,CAAC,OAAO,CAAC;IAI3D;;;OAGG;IACG,MAAM,CAAC,MAAM,EAAE,mBAAmB,GAAG,OAAO,CAAC,OAAO,CAAC;IAI3D,6DAA6D;IACvD,MAAM,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;CAGhD"}
|
package/dist/sections.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { pathSegment as seg } from '@oblax/core';
|
|
2
|
+
function toApi(p) {
|
|
3
|
+
return {
|
|
4
|
+
name: p.name,
|
|
5
|
+
base_paths: p.basePaths,
|
|
6
|
+
pattern: p.pattern,
|
|
7
|
+
default_sort: p.defaultSort,
|
|
8
|
+
page_size: p.pageSize,
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Manages sections: where articles live (`/blog`, `/news`) and how their
|
|
13
|
+
* paths are built.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* await oblax.cms.sections.create({
|
|
18
|
+
* code: 'blog',
|
|
19
|
+
* name: { en: 'Blog' },
|
|
20
|
+
* basePaths: { en: '/blog' },
|
|
21
|
+
* pattern: '{yyyy}/{slug}',
|
|
22
|
+
* })
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export class SectionsSubmodule {
|
|
26
|
+
constructor(ctx) {
|
|
27
|
+
this.ctx = ctx;
|
|
28
|
+
}
|
|
29
|
+
async list() {
|
|
30
|
+
return this.ctx.http.get('/cms/sections');
|
|
31
|
+
}
|
|
32
|
+
async get(params) {
|
|
33
|
+
return this.ctx.http.get(`/cms/sections/${seg(params.code)}`);
|
|
34
|
+
}
|
|
35
|
+
/** Creates a section; left out, articles go at `<base path>/<slug>`, newest first, 20 a page. */
|
|
36
|
+
async create(params) {
|
|
37
|
+
return this.ctx.http.post('/cms/sections', { ...toApi(params), code: params.code });
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Updates a section. Names and base paths given replace the old ones whole.
|
|
41
|
+
* New base paths or a new pattern move the section's articles.
|
|
42
|
+
*/
|
|
43
|
+
async update(params) {
|
|
44
|
+
return this.ctx.http.put(`/cms/sections/${seg(params.code)}`, toApi(params));
|
|
45
|
+
}
|
|
46
|
+
/** Deletes a section without articles that no type lists. */
|
|
47
|
+
async delete(params) {
|
|
48
|
+
return this.ctx.http.delete(`/cms/sections/${seg(params.code)}`);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=sections.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sections.js","sourceRoot":"","sources":["../src/sections.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,IAAI,GAAG,EAAE,MAAM,aAAa,CAAA;AAUhD,SAAS,KAAK,CAAC,CAAe;IAC5B,OAAO;QACL,IAAI,EAAU,CAAC,CAAC,IAAI;QACpB,UAAU,EAAI,CAAC,CAAC,SAAS;QACzB,OAAO,EAAO,CAAC,CAAC,OAAO;QACvB,YAAY,EAAE,CAAC,CAAC,WAAW;QAC3B,SAAS,EAAK,CAAC,CAAC,QAAQ;KACzB,CAAA;AACH,CAAC;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,OAAO,iBAAiB;IAC5B,YAA6B,GAAiB;QAAjB,QAAG,GAAH,GAAG,CAAc;IAAG,CAAC;IAElD,KAAK,CAAC,IAAI;QACR,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAmB,eAAe,CAAC,CAAA;IAC7D,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,MAAkB;QAC1B,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAU,iBAAiB,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IACxE,CAAC;IAED,iGAAiG;IACjG,KAAK,CAAC,MAAM,CAAC,MAA2B;QACtC,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAU,eAAe,EAAE,EAAE,GAAG,KAAK,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC,CAAA;IAC9F,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,MAAM,CAAC,MAA2B;QACtC,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAU,iBAAiB,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,CAAA;IACvF,CAAC;IAED,6DAA6D;IAC7D,KAAK,CAAC,MAAM,CAAC,MAAkB;QAC7B,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAO,iBAAiB,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IACxE,CAAC;CACF"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { OblaxContext } from '@oblax/core';
|
|
2
|
+
import type { CmsSettings, UpdateSettingsParams } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* The project's CMS settings: each locale's home page and the paths the
|
|
5
|
+
* frontends keep for themselves.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* await oblax.cms.settings.update({
|
|
10
|
+
* homePages: { en: 'entry-id' },
|
|
11
|
+
* reservedPaths: ['/api', '/account'],
|
|
12
|
+
* })
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
export declare class SettingsSubmodule {
|
|
16
|
+
private readonly ctx;
|
|
17
|
+
constructor(ctx: OblaxContext);
|
|
18
|
+
get(): Promise<CmsSettings>;
|
|
19
|
+
/** Replaces the settings whole. */
|
|
20
|
+
update(params: UpdateSettingsParams): Promise<CmsSettings>;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=settings.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"settings.d.ts","sourceRoot":"","sources":["../src/settings.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC/C,OAAO,KAAK,EAAE,WAAW,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAA;AAEnE;;;;;;;;;;;GAWG;AACH,qBAAa,iBAAiB;IAChB,OAAO,CAAC,QAAQ,CAAC,GAAG;gBAAH,GAAG,EAAE,YAAY;IAExC,GAAG,IAAI,OAAO,CAAC,WAAW,CAAC;IAIjC,mCAAmC;IAC7B,MAAM,CAAC,MAAM,EAAE,oBAAoB,GAAG,OAAO,CAAC,WAAW,CAAC;CAMjE"}
|
package/dist/settings.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The project's CMS settings: each locale's home page and the paths the
|
|
3
|
+
* frontends keep for themselves.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```typescript
|
|
7
|
+
* await oblax.cms.settings.update({
|
|
8
|
+
* homePages: { en: 'entry-id' },
|
|
9
|
+
* reservedPaths: ['/api', '/account'],
|
|
10
|
+
* })
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
export class SettingsSubmodule {
|
|
14
|
+
constructor(ctx) {
|
|
15
|
+
this.ctx = ctx;
|
|
16
|
+
}
|
|
17
|
+
async get() {
|
|
18
|
+
return this.ctx.http.get('/cms/settings');
|
|
19
|
+
}
|
|
20
|
+
/** Replaces the settings whole. */
|
|
21
|
+
async update(params) {
|
|
22
|
+
return this.ctx.http.put('/cms/settings', {
|
|
23
|
+
home_pages: params.homePages,
|
|
24
|
+
reserved_paths: params.reservedPaths,
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=settings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"settings.js","sourceRoot":"","sources":["../src/settings.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;GAWG;AACH,MAAM,OAAO,iBAAiB;IAC5B,YAA6B,GAAiB;QAAjB,QAAG,GAAH,GAAG,CAAc;IAAG,CAAC;IAElD,KAAK,CAAC,GAAG;QACP,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAc,eAAe,CAAC,CAAA;IACxD,CAAC;IAED,mCAAmC;IACnC,KAAK,CAAC,MAAM,CAAC,MAA4B;QACvC,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAc,eAAe,EAAE;YACrD,UAAU,EAAM,MAAM,CAAC,SAAS;YAChC,cAAc,EAAE,MAAM,CAAC,aAAa;SACrC,CAAC,CAAA;IACJ,CAAC;CACF"}
|
package/dist/terms.d.ts
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { OblaxContext } from '@oblax/core';
|
|
2
|
+
import type { CmsCursorList, CreateTermParams, IdParams, ListTermsParams, MergeTermParams, MoveTermParams, Term, UpdateTermParams } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Manages a vocabulary's terms. New terms are live at once.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```typescript
|
|
8
|
+
* const go = await oblax.cms.terms.create({
|
|
9
|
+
* vocabulary: 'tags',
|
|
10
|
+
* labels: { en: { name: 'Go' } },
|
|
11
|
+
* })
|
|
12
|
+
*
|
|
13
|
+
* // Page through a vocabulary
|
|
14
|
+
* let page = await oblax.cms.terms.list({ vocabulary: 'tags', limit: 100 })
|
|
15
|
+
* while (page.next) {
|
|
16
|
+
* page = await oblax.cms.terms.list({ vocabulary: 'tags', limit: 100, after: page.next })
|
|
17
|
+
* }
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export declare class TermsSubmodule {
|
|
21
|
+
private readonly ctx;
|
|
22
|
+
constructor(ctx: OblaxContext);
|
|
23
|
+
/** Lists a page of a vocabulary's terms by id, aliases left out. */
|
|
24
|
+
list(params: ListTermsParams): Promise<CmsCursorList<Term>>;
|
|
25
|
+
get(params: IdParams): Promise<Term>;
|
|
26
|
+
/** Adds a term; slugs are made from the names when left out. */
|
|
27
|
+
create(params: CreateTermParams): Promise<Term>;
|
|
28
|
+
/**
|
|
29
|
+
* Updates a term. Labels and fields given replace the old ones whole. New
|
|
30
|
+
* slugs move its URLs, with redirects from the old ones.
|
|
31
|
+
*/
|
|
32
|
+
update(params: UpdateTermParams): Promise<Term>;
|
|
33
|
+
/** Deletes a term without children, and its aliases. Entries lose it on their next save. */
|
|
34
|
+
delete(params: IdParams): Promise<void>;
|
|
35
|
+
/** Puts a term under another one (or at the root) at a position; descendants move with it. */
|
|
36
|
+
move(params: MoveTermParams): Promise<Term>;
|
|
37
|
+
/** Makes a term an alias of another one in its vocabulary; its URLs redirect there. */
|
|
38
|
+
merge(params: MergeTermParams): Promise<Term>;
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=terms.d.ts.map
|