@composable-os/pack-content 0.0.0-stage → 0.1.0-beta.7

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.
@@ -0,0 +1,167 @@
1
+ declare const _default: import("@composable-os/sdk").Extension<{
2
+ readonly id: "content";
3
+ readonly version: "0.2.0";
4
+ readonly contractVersion: 1;
5
+ readonly label: "Content";
6
+ readonly description: string;
7
+ readonly permissions: {
8
+ readonly operations: ["public.list"];
9
+ readonly modules: ["ops"];
10
+ };
11
+ readonly objects: {
12
+ readonly post: {
13
+ readonly label: "Post";
14
+ readonly plural: "Posts";
15
+ readonly icon: "newspaper";
16
+ readonly titleField: "title";
17
+ readonly description: string;
18
+ readonly fields: {
19
+ readonly title: {
20
+ readonly type: "text";
21
+ readonly label: "Title";
22
+ readonly required: true;
23
+ };
24
+ readonly slug: {
25
+ readonly type: "slug";
26
+ readonly label: "Address";
27
+ readonly description: "Where the post is read: /blog/<address>. Made from the title.";
28
+ };
29
+ readonly excerpt: {
30
+ readonly type: "text";
31
+ readonly label: "Excerpt";
32
+ readonly description: "One or two sentences for lists and link previews.";
33
+ };
34
+ readonly body: {
35
+ readonly type: "richText";
36
+ readonly label: "Body";
37
+ };
38
+ readonly cover: {
39
+ readonly type: "image";
40
+ readonly label: "Cover picture";
41
+ };
42
+ readonly author: {
43
+ readonly type: "user";
44
+ readonly label: "Author";
45
+ };
46
+ readonly byline: {
47
+ readonly type: "text";
48
+ readonly label: "Byline";
49
+ readonly description: "Who wrote it, as readers see it: \"Words by Sam Lee\". Left empty, none.";
50
+ };
51
+ readonly category: {
52
+ readonly type: "relation";
53
+ readonly label: "Category";
54
+ readonly to: "content.category";
55
+ };
56
+ readonly date: {
57
+ readonly type: "datetime";
58
+ readonly label: "Date";
59
+ readonly description: "The date readers are shown. Left empty, it is when the post goes live.";
60
+ };
61
+ readonly seoTitle: {
62
+ readonly type: "text";
63
+ readonly label: "Search title";
64
+ };
65
+ readonly seoDescription: {
66
+ readonly type: "text";
67
+ readonly label: "Search description";
68
+ };
69
+ readonly seoImage: {
70
+ readonly type: "image";
71
+ readonly label: "Share picture";
72
+ };
73
+ readonly noindex: {
74
+ readonly type: "boolean";
75
+ readonly label: "Hide from search engines";
76
+ readonly description: "Asks search engines not to list the post's page.";
77
+ };
78
+ };
79
+ readonly indexes: readonly [readonly ["category"], readonly ["date"]];
80
+ readonly publishable: {
81
+ readonly content: readonly ["title", "excerpt", "body", "cover", "author", "byline", "category", "date", "seoTitle", "seoDescription", "seoImage", "noindex"];
82
+ readonly slug: "slug";
83
+ readonly date: "date";
84
+ };
85
+ readonly public: {
86
+ readonly read: readonly ["title", "slug", "excerpt", "body", "cover", "byline", "category", "date", "publishedAt", "seoTitle", "seoDescription", "seoImage", "noindex"];
87
+ };
88
+ };
89
+ readonly category: {
90
+ readonly label: "Category";
91
+ readonly plural: "Categories";
92
+ readonly icon: "tags";
93
+ readonly titleField: "name";
94
+ readonly navigation: "settings";
95
+ readonly fields: {
96
+ readonly name: {
97
+ readonly type: "text";
98
+ readonly label: "Name";
99
+ readonly required: true;
100
+ };
101
+ readonly slug: {
102
+ readonly type: "slug";
103
+ readonly label: "Address";
104
+ };
105
+ };
106
+ readonly public: {
107
+ readonly read: readonly ["name", "slug"];
108
+ };
109
+ };
110
+ };
111
+ readonly views: {
112
+ readonly drafts: {
113
+ readonly label: "Drafts";
114
+ readonly object: "content.post";
115
+ readonly filter: {
116
+ readonly field: "publishState";
117
+ readonly op: "eq";
118
+ readonly value: "draft";
119
+ };
120
+ readonly sort: {
121
+ readonly field: "updatedAt";
122
+ readonly direction: "desc";
123
+ };
124
+ readonly columns: ["title", "category", "author", "updatedAt"];
125
+ };
126
+ readonly scheduled: {
127
+ readonly label: "Scheduled";
128
+ readonly object: "content.post";
129
+ readonly filter: {
130
+ readonly field: "publishState";
131
+ readonly op: "eq";
132
+ readonly value: "scheduled";
133
+ };
134
+ readonly sort: {
135
+ readonly field: "publishAt";
136
+ readonly direction: "asc";
137
+ };
138
+ readonly columns: ["title", "category", "author", "publishAt"];
139
+ };
140
+ readonly published: {
141
+ readonly label: "Published";
142
+ readonly object: "content.post";
143
+ readonly filter: {
144
+ readonly field: "publishState";
145
+ readonly op: "eq";
146
+ readonly value: "published";
147
+ };
148
+ readonly sort: {
149
+ readonly field: "date";
150
+ readonly direction: "desc";
151
+ };
152
+ readonly columns: ["title", "category", "date", "publishedAt", "publishedVersion"];
153
+ };
154
+ };
155
+ readonly tools: {
156
+ readonly categories: import("@composable-os/sdk").ToolSpec<import("zod").ZodObject<{
157
+ limit: import("zod").ZodDefault<import("zod").ZodNumber>;
158
+ }, import("zod/v4/core").$strip>, import("zod").ZodObject<{
159
+ categories: import("zod").ZodArray<import("zod").ZodObject<{
160
+ id: import("zod").ZodString;
161
+ name: import("zod").ZodNullable<import("zod").ZodString>;
162
+ slug: import("zod").ZodNullable<import("zod").ZodString>;
163
+ }, import("zod/v4/core").$strip>>;
164
+ }, import("zod/v4/core").$strip>>;
165
+ };
166
+ }>;
167
+ export default _default;
package/dist/index.js ADDED
@@ -0,0 +1,149 @@
1
+ // Content (stage 28, step 6): blog posts and their categories, which staff write and the public
2
+ // reads. Any product can turn it on (`packs` in its product.ts).
3
+ //
4
+ // Everything that is a rule is the host's, declared here as behaviours (ADR 0404):
5
+ // - a post is `publishable` (ADRs 0446, 0441): staff and the assistant edit its working copy;
6
+ // a person with the publish permission publishes it, now or at a time; its versions are kept;
7
+ // - the public reads only its published version, by its slug, with only the fields
8
+ // `public.read` lists (ADR 0442): `content.get` and `content.list`, which the hooks call;
9
+ // - its body is `richText` (ADR 0440) and its cover an `image` (ADR 0444): structured data,
10
+ // never HTML, and a picture the public is served only while a published post shows it.
11
+ // The pack adds no rule of its own. Its one tool lists the categories for a site's menu.
12
+ import { defineExtension } from "@composable-os/sdk";
13
+ import { categories } from "./tools.js";
14
+ export default defineExtension({
15
+ id: "content",
16
+ version: "0.2.0",
17
+ contractVersion: 1,
18
+ label: "Content",
19
+ description: "Blog posts and their categories: staff write and schedule them, a person publishes them, " +
20
+ "and the public reads what was published, on the web and in the app.",
21
+ permissions: {
22
+ // public.list: the categories the public may read, for the categories tool.
23
+ operations: ["public.list"],
24
+ modules: ["ops"],
25
+ },
26
+ objects: {
27
+ post: {
28
+ label: "Post",
29
+ plural: "Posts",
30
+ icon: "newspaper",
31
+ titleField: "title",
32
+ description: "A blog post. Its working copy is what staff edit; the public reads the version last " +
33
+ "published.",
34
+ fields: {
35
+ title: { type: "text", label: "Title", required: true },
36
+ slug: {
37
+ type: "slug",
38
+ label: "Address",
39
+ description: "Where the post is read: /blog/<address>. Made from the title.",
40
+ },
41
+ excerpt: {
42
+ type: "text",
43
+ label: "Excerpt",
44
+ description: "One or two sentences for lists and link previews.",
45
+ },
46
+ body: { type: "richText", label: "Body" },
47
+ cover: { type: "image", label: "Cover picture" },
48
+ author: { type: "user", label: "Author" },
49
+ // What readers see as who wrote it (ADR 0470): plain text, because a post's author is a
50
+ // staff account, which the public never reads.
51
+ byline: {
52
+ type: "text",
53
+ label: "Byline",
54
+ description: 'Who wrote it, as readers see it: "Words by Sam Lee". Left empty, none.',
55
+ },
56
+ category: { type: "relation", label: "Category", to: "content.category" },
57
+ date: {
58
+ type: "datetime",
59
+ label: "Date",
60
+ description: "The date readers are shown. Left empty, it is when the post goes live.",
61
+ },
62
+ // What search engines and link previews show (ADR 0470). Each is optional: left empty,
63
+ // the page uses the title, the excerpt and the cover.
64
+ seoTitle: { type: "text", label: "Search title" },
65
+ seoDescription: { type: "text", label: "Search description" },
66
+ seoImage: { type: "image", label: "Share picture" },
67
+ noindex: {
68
+ type: "boolean",
69
+ label: "Hide from search engines",
70
+ description: "Asks search engines not to list the post's page.",
71
+ },
72
+ },
73
+ indexes: [["category"], ["date"]],
74
+ publishable: {
75
+ content: [
76
+ "title",
77
+ "excerpt",
78
+ "body",
79
+ "cover",
80
+ "author",
81
+ "byline",
82
+ "category",
83
+ "date",
84
+ "seoTitle",
85
+ "seoDescription",
86
+ "seoImage",
87
+ "noindex",
88
+ ],
89
+ slug: "slug",
90
+ date: "date",
91
+ },
92
+ // The author is a staff account, which the public does not read; a post shows its date.
93
+ public: {
94
+ read: [
95
+ "title",
96
+ "slug",
97
+ "excerpt",
98
+ "body",
99
+ "cover",
100
+ "byline",
101
+ "category",
102
+ "date",
103
+ "publishedAt",
104
+ "seoTitle",
105
+ "seoDescription",
106
+ "seoImage",
107
+ "noindex",
108
+ ],
109
+ },
110
+ },
111
+ category: {
112
+ label: "Category",
113
+ plural: "Categories",
114
+ icon: "tags",
115
+ titleField: "name",
116
+ navigation: "settings",
117
+ fields: {
118
+ name: { type: "text", label: "Name", required: true },
119
+ slug: { type: "slug", label: "Address" },
120
+ },
121
+ // Every live category is public: a site's menu and a post's label.
122
+ public: { read: ["name", "slug"] },
123
+ },
124
+ },
125
+ views: {
126
+ drafts: {
127
+ label: "Drafts",
128
+ object: "content.post",
129
+ filter: { field: "publishState", op: "eq", value: "draft" },
130
+ sort: { field: "updatedAt", direction: "desc" },
131
+ columns: ["title", "category", "author", "updatedAt"],
132
+ },
133
+ scheduled: {
134
+ label: "Scheduled",
135
+ object: "content.post",
136
+ filter: { field: "publishState", op: "eq", value: "scheduled" },
137
+ sort: { field: "publishAt", direction: "asc" },
138
+ columns: ["title", "category", "author", "publishAt"],
139
+ },
140
+ published: {
141
+ label: "Published",
142
+ object: "content.post",
143
+ filter: { field: "publishState", op: "eq", value: "published" },
144
+ sort: { field: "date", direction: "desc" },
145
+ columns: ["title", "category", "date", "publishedAt", "publishedVersion"],
146
+ },
147
+ },
148
+ tools: { categories },
149
+ });
@@ -0,0 +1,11 @@
1
+ import { z } from "@composable-os/sdk";
2
+ export declare const CATEGORY = "content.category";
3
+ export declare const categories: import("@composable-os/sdk").ToolSpec<z.ZodObject<{
4
+ limit: z.ZodDefault<z.ZodNumber>;
5
+ }, z.core.$strip>, z.ZodObject<{
6
+ categories: z.ZodArray<z.ZodObject<{
7
+ id: z.ZodString;
8
+ name: z.ZodNullable<z.ZodString>;
9
+ slug: z.ZodNullable<z.ZodString>;
10
+ }, z.core.$strip>>;
11
+ }, z.core.$strip>>;
package/dist/tools.js ADDED
@@ -0,0 +1,30 @@
1
+ // The Content pack's tools (stage 28, step 6). Posts need none: the public reads them with the
2
+ // host's `content.get` and `content.list`, which serve published versions only. This one lists
3
+ // the categories for a site's menu, through `public.list`, so the seam decides what is shown.
4
+ import { defineTool, z } from "@composable-os/sdk";
5
+ export const CATEGORY = "content.category";
6
+ const text = (value) => (typeof value === "string" ? value : null);
7
+ export const categories = defineTool({
8
+ description: "Every category of posts, by name: its id, name and address (slug), for a site's menu or " +
9
+ "a post's label. Read-only.",
10
+ input: z.object({ limit: z.number().int().min(1).max(200).default(100) }),
11
+ output: z.object({
12
+ categories: z.array(z.object({ id: z.string(), name: z.string().nullable(), slug: z.string().nullable() })),
13
+ }),
14
+ risk: "read",
15
+ audiences: ["staff", "customer", "public"],
16
+ async handler(input, ctx) {
17
+ const page = await ctx.ops.call("public.list", {
18
+ object: CATEGORY,
19
+ sort: { field: "name", direction: "asc" },
20
+ limit: input.limit,
21
+ });
22
+ return {
23
+ categories: page.items.map((item) => ({
24
+ id: item.id,
25
+ name: text(item.values.name),
26
+ slug: text(item.values.slug),
27
+ })),
28
+ };
29
+ },
30
+ });
package/package.json CHANGED
@@ -1,6 +1,38 @@
1
1
  {
2
2
  "name": "@composable-os/pack-content",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0-beta.7",
4
+ "license": "FSL-1.1-ALv2",
5
+ "type": "module",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/timoconnellaus/composable-os.git"
9
+ },
10
+ "homepage": "https://composableos.dev",
11
+ "publishConfig": {
12
+ "access": "public",
13
+ "provenance": true
14
+ },
15
+ "description": "Content: blog posts and categories, written by staff, published by a person, read by the public as structured rich text on the web and in the app (stage 28). Installed in every deployment of a product that lists it. Bundled as source into cos-runner.",
16
+ "exports": {
17
+ ".": {
18
+ "types": "./dist/index.d.ts",
19
+ "default": "./dist/index.js"
20
+ },
21
+ "./client": {
22
+ "types": "./dist/client/index.d.ts",
23
+ "default": "./dist/client/index.js"
24
+ }
25
+ },
26
+ "files": [
27
+ "dist"
28
+ ],
29
+ "composableOs": {
30
+ "optional": true,
31
+ "label": "Content",
32
+ "description": "Blog posts staff write, schedule and publish, read by the public on your site and in your app."
33
+ },
34
+ "dependencies": {
35
+ "@composable-os/client": "0.1.0-beta.7",
36
+ "@composable-os/sdk": "0.1.0-beta.7"
37
+ }
38
+ }
package/README.md DELETED
@@ -1,3 +0,0 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.