Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .changeset/38372-starter-help-articles.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
'@objectstack/example-starter': patch
'create-objectstack': patch
---

feat(example-starter, create-objectstack): help articles in the Starter app and the blank template

Clause-②: no
Metadata-protocol: none

The Starter app and the project `npm create objectstack` scaffolds now start with help articles: an Article object (`biz_article` in the Starter, `<namespace>_article` in a new project) with a title, a Markdown body, a category (How-to, FAQ, Reference) and a status (Draft by default, Published), a grid of every article, an Articles entry in the menu between Contacts and Tasks, and four sample articles of generic office help (setting up a laptop, a Wi-Fi and printing FAQ, a meeting rooms reference, and a draft on sharing files). Each sample body opens with the article's title as a `#` heading, then one `##` section per topic. The Starter labels the articles in English and Simplified Chinese; a new project's labels are the English ones in its source. A new project also gains `src/data/`, the sample rows seeded on each boot, listed by name in `data` in `objectstack.config.ts`. Neither app declares a knowledge source.
18 changes: 12 additions & 6 deletions examples/app-starter/README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,29 @@
# @objectstack/example-starter — Starter app

A small, complete app an organization installs and then makes its own:
companies, the people at them, and the platform's tasks and notes in one menu.
companies, the people at them, help articles, and the platform's tasks and
notes in one menu.

- `src/objects/` — `biz_company` (name, type, industry, website, phone,
address) and `biz_contact` (name, company, job title, influence, email,
phone). A contact is a person outside the organization, never a user.
- `src/views/` — a grid and a board for each object. The create and edit form
is each object's `fieldGroups`; the company's record page lists its contacts.
- `src/apps/` — the menu: companies, contacts, tasks (`sys_task`), notes
`biz_article` (title, Markdown body, category, status) holds help articles:
how-tos, common questions and reference pages.
- `src/views/` — a grid and a board for companies and for contacts, a grid of
articles. The create and edit form is each object's `fieldGroups`; the
company's record page lists its contacts.
- `src/apps/` — the menu: companies, contacts, articles, tasks (`sys_task`), notes
(`sys_note`), and the overview dashboard. Tasks and notes are platform
objects every environment carries; this package declares no copy of them.
- `src/datasets/`, `src/dashboards/` — one overview dashboard.
- `src/data/` — five sample companies and six sample contacts.
- `src/data/` — five sample companies, six sample contacts, and four help
articles (setting up a laptop, a Wi-Fi and printing FAQ, a meeting rooms
reference, and a draft on sharing files).
- `src/translations/` — English and Simplified Chinese.

The API names carry the `biz_` namespace, so a tenant can install this
starter beside a CRM package without a name clash. Uninstalling the package
removes companies and contacts; tasks and notes stay.
removes companies, contacts and articles; tasks and notes stay.

## How to run

Expand Down
11 changes: 6 additions & 5 deletions examples/app-starter/objectstack.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@ import * as translations from './src/translations/index.js';
import { StarterSeedData } from './src/data/index.js';

/**
* Starter app — companies and the people at them, with the platform's tasks
* and notes in the same menu.
* Starter app — companies and the people at them, and help articles, with the
* platform's tasks and notes in the same menu.
*
* A small, complete app an organization installs and then makes its own: two
* objects (`biz_company`, `biz_contact`), a grid and a board for each,
* the company's contacts on its record page, sample rows, and one dashboard.
* A small, complete app an organization installs and then makes its own:
* companies and contacts (`biz_company`, `biz_contact`) with a grid and a
* board for each and the company's contacts on its record page, help articles
* (`biz_article`) with a grid, sample rows, and one dashboard.
* Tasks and notes are not part of the package: the menu points at the
* platform's `sys_task` and `sys_note`, so they stay when the package goes.
*/
Expand Down
5 changes: 3 additions & 2 deletions examples/app-starter/src/apps/starter.app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import { App } from '@objectstack/spec/ui';

/**
* The starter's menu: the package's companies and contacts, then the
* platform's tasks and notes, then the overview dashboard.
* The starter's menu: the package's companies, contacts and help articles,
* then the platform's tasks and notes, then the overview dashboard.
*
* Tasks and notes are the platform objects `sys_task` and `sys_note`, which
* every environment carries; the package declares no copy of them, so
Expand All @@ -22,6 +22,7 @@ export const StarterApp = App.create({
navigation: [
{ id: 'nav_companies', type: 'object', objectName: 'biz_company', icon: 'building-2' },
{ id: 'nav_contacts', type: 'object', objectName: 'biz_contact', icon: 'contact' },
{ id: 'nav_articles', type: 'object', objectName: 'biz_article', icon: 'book-open' },
// `requiresObject` names the object again because `defineStack` refuses a
// menu entry for an object the stack does not declare unless the entry
// says the object comes from elsewhere — here, the platform.
Expand Down
125 changes: 125 additions & 0 deletions examples/app-starter/src/data/articles.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.

// Sample help articles, generic office help rather than policy text. Business
// data like the companies and contacts (`index.ts`): no `mode`, so a replay
// inserts a missing article and leaves an existing one as the organization
// left it.
//
// Each `body` is Markdown in one shape, readable section by section: the
// title as a `#` heading, then 3 to 6 `##` sections, each with its own text
// and under 800 characters with its heading; the reference article carries a
// table followed by a one-line note. `test/help-articles-38372.test.ts` holds
// every article to that shape, and the blank template in create-objectstack
// carries the same seed (its parity test compares the two).

import { defineSeed } from '@objectstack/spec/data';
import { Article } from '../objects/article.object.js';

export const articles = defineSeed(Article, {
externalId: 'title',
records: [
{
title: 'Set up your new laptop',
category: 'how_to',
status: 'published',
body: `# Set up your new laptop

## Before you start

Have your work email address and the temporary password from your welcome message at hand. Plug the laptop into power: the first start installs updates and can take up to half an hour.

## Sign in for the first time

Choose your language and keyboard, join the office Wi-Fi, then sign in with your work email and the temporary password. You are asked to choose a new password straight away; pick one you have not used anywhere else.

## Install the apps you need

Open the company app store from the start menu. Email, calendar, chat and the office suite install on their own; anything your team uses on top of that is listed under your department. Ask your manager if an app you need is missing.

## Turn on backup

Sign in to the file storage app and let it back up your Desktop and Documents folders. Files saved there follow you to a new laptop and can be restored if this one is lost.

## Get help

If something does not work, write to the IT help desk with the laptop's name, which is on the sticker underneath, and a screenshot of any error.`,
},
{
title: 'Wi-Fi and printing FAQ',
category: 'faq',
status: 'published',
body: `# Wi-Fi and printing FAQ

## How do I join the office Wi-Fi?

Pick the network named Office and sign in with your work email and password. Guests use the Office-Guest network; its password is on the card at reception and changes every Monday.

## Why does the Wi-Fi keep dropping?

Most drops happen when a laptop moves between floors. Turn Wi-Fi off and on again, and forget any old office network your laptop still remembers. If it keeps happening at one desk, tell the help desk which desk it is.

## How do I add a printer?

Open the printer settings, choose Add printer and pick the one whose name matches the label on the machine. Printers are named by floor, so the second-floor printer starts with F2.

## Why is my print job stuck?

A job usually waits because the printer is out of paper or needs a release at the machine. Tap your badge on the printer to release your jobs. Jobs that are not released within a day are deleted.

## Can I print from my phone?

Yes. Email the file from your work account to the print address shown on the printer's screen, then release it with your badge as usual.`,
},
{
title: 'Meeting rooms reference',
category: 'reference',
status: 'published',
body: `# Meeting rooms reference

## Rooms at a glance

| Room | Floor | Seats | Equipment |
| --- | --- | --- | --- |
| Harbor | 1 | 4 | Screen |
| Summit | 2 | 8 | Screen, video bar, whiteboard |
| Grove | 2 | 12 | Projector, video bar |
| Atrium | 3 | 20 | Projector, microphones |

Seat counts are for seated meetings; a short stand-up fits a few more people.

## Booking a room

Book rooms from your calendar by adding the room as a guest. A booking longer than two hours, or one that repeats every week, needs a reason in the invitation so others know whether to ask for the room.

## Video calls

Rooms with a video bar join a call from the calendar invitation: press Join on the room's touch panel. In other rooms, connect your laptop to the screen with the cable on the table.

## Leaving the room

End the meeting on time, wipe the whiteboard, and take your cups with you. If you finish early, release the room from your calendar so someone else can use it.`,
},
{
title: 'Share files with your team',
category: 'how_to',
status: 'draft',
body: `# Share files with your team

## Pick the right place

Keep files your whole team works on in the team's shared folder, not in your own. A file in a shared folder stays with the team when someone leaves or changes roles.

## Share a file or folder

Right-click the file in the file storage app, choose Share, and add people by name or add the whole team. Each person gets an email with a link.

## Choose who can edit

Give edit access to the people who will change the file and view access to everyone else. Links that anyone can open are turned off for files that hold customer details.

## Stop sharing

Open Share again and remove a person, or change their access to view only. Review who has access to a folder when a project ends.`,
},
],
});
9 changes: 5 additions & 4 deletions examples/app-starter/src/data/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
import { defineSeed } from '@objectstack/spec/data';
import { Company } from '../objects/company.object.js';
import { Contact } from '../objects/contact.object.js';
import { articles } from './articles.js';

// Sample data, so the menu, the boards and the dashboard have something to
// show on first open. Business data: no `mode`, so a replay (each boot, an
// install or upgrade) inserts a missing row and leaves an existing one as the
// organization left it. Delete the rows, or the whole package, when they are
// show on first open; the help articles are in `articles.ts`. Business data:
// no `mode`, so a replay (each boot, an install or upgrade) inserts a missing
// row and leaves an existing one as the organization left it. Delete the rows, or the whole package, when they are
// no longer wanted.

const companies = defineSeed(Company, {
Expand All @@ -33,4 +34,4 @@ const contacts = defineSeed(Contact, {
],
});

export const StarterSeedData = [companies, contacts];
export const StarterSeedData = [companies, contacts, articles];
57 changes: 57 additions & 0 deletions examples/app-starter/src/objects/article.object.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.

import { ObjectSchema, Field } from '@objectstack/spec/data';

/**
* A help article — a how-to guide, an answer to a common question, or a
* reference page — written in Markdown.
*
* `body` opens with the article's title as a `#` heading, then one `##`
* section per topic, each with its own text: the seed articles in
* `src/data/articles.ts` are written that way. A draft stays a draft until
* someone sets it to Published.
*/
export const Article = ObjectSchema.create({
name: 'biz_article',
// Shared inside the organization, as the companies and contacts are.
sharingModel: 'public_read_write',
label: 'Article',
pluralLabel: 'Articles',
icon: 'book-open',
color: 'amber',
description: 'A help article: a how-to guide, a common question, or a reference page.',
nameField: 'title',
highlightFields: ['category', 'status', 'owner_id'],

fields: {
title: Field.text({
label: 'Title',
required: true,
searchable: true,
maxLength: 200,
}),
body: Field.markdown({
label: 'Body',
}),
category: Field.select({
label: 'Category',
options: [
{ label: 'How-to', value: 'how_to', color: '#3B82F6' },
{ label: 'FAQ', value: 'faq', color: '#10B981' },
{ label: 'Reference', value: 'reference', color: '#8B5CF6' },
],
}),
status: Field.select({
label: 'Status',
options: [
{ label: 'Draft', value: 'draft', color: '#6B7280', default: true },
{ label: 'Published', value: 'published', color: '#10B981' },
],
}),
},

// The one Details section of the record page and of the create and edit form.
fieldGroups: [
{ key: 'basic', label: 'Article', fields: ['title', 'category', 'status', 'body'] },
],
});
1 change: 1 addition & 0 deletions examples/app-starter/src/objects/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.

export { Article } from './article.object.js';
export { Company } from './company.object.js';
export { Contact } from './contact.object.js';
42 changes: 42 additions & 0 deletions examples/app-starter/src/translations/starter.translation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,17 @@ export const StarterTranslationBundle = defineTranslationBundle({
owner_id: { label: 'Owner' },
},
},
biz_article: {
label: 'Article',
pluralLabel: 'Articles',
fields: {
title: { label: 'Title' },
body: { label: 'Body' },
category: { label: 'Category' },
status: { label: 'Status' },
owner_id: { label: 'Owner' },
},
},
},
apps: {
biz_app: {
Expand Down Expand Up @@ -130,6 +141,37 @@ export const StarterTranslationBundle = defineTranslationBundle({
more: { label: '更多' },
},
},
biz_article: {
label: '知识文章',
pluralLabel: '知识文章',
description: '帮助文章:操作指南、常见问题或参考资料。',
fields: {
title: { label: '标题' },
body: { label: '正文' },
category: {
label: '分类',
options: {
how_to: '操作指南',
faq: '常见问题',
reference: '参考资料',
},
},
status: {
label: '状态',
options: {
draft: '草稿',
published: '已发布',
},
},
owner_id: { label: '负责人' },
},
_views: {
all: { label: '全部文章' },
},
_sections: {
basic: { label: '文章' },
},
},
},
apps: {
biz_app: {
Expand Down
36 changes: 36 additions & 0 deletions examples/app-starter/src/views/article.view.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.

import { defineView } from '@objectstack/spec';

/**
* Article list view: a grid of every help article with its category and
* status.
*
* No `form` here: the Console's create and edit form lays a record out by the
* object's `fieldGroups` (`article.object.ts`), and a declared default form is
* not loaded there.
*/
export const ArticleViews = defineView({
list: {
label: 'All Articles',
type: 'grid',
data: { provider: 'object', object: 'biz_article' },
columns: [
{ field: 'title' },
{ field: 'category' },
{ field: 'status' },
],
},
listViews: {
all: {
label: 'All Articles',
type: 'grid',
data: { provider: 'object', object: 'biz_article' },
columns: [
{ field: 'title' },
{ field: 'category' },
{ field: 'status' },
],
},
},
});
1 change: 1 addition & 0 deletions examples/app-starter/src/views/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.

export { ArticleViews } from './article.view.js';
export { CompanyViews } from './company.view.js';
export { ContactViews } from './contact.view.js';
Loading
Loading