From 24cb818056d58c1485396b634bdba338c98d4840 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 28 Nov 2026 23:23:34 +0000 Subject: [PATCH 01/10] refactor(example-starter): rename the Starter's namespace from starter to biz The two objects, the app, the dashboard, the two datasets and their translation keys move from starter_* to biz_*; every reference (lookup, related list, view data.object, menu, dashboard widgets, both locales) follows. The manifest id com.example.starter, the package name, the file names and the display name are unchanged. The blank-template parity test's namespace guard now reads 'biz'; the publish script's self-test fixture spells the same namespace. Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01FEkQ5oQLfL8thb6wtUHnTb --- examples/app-starter/README.md | 6 +++--- examples/app-starter/objectstack.config.ts | 4 ++-- examples/app-starter/src/apps/starter.app.ts | 8 ++++---- .../src/dashboards/overview.dashboard.ts | 14 +++++++------- .../src/datasets/company.dataset.ts | 4 ++-- .../src/datasets/contact.dataset.ts | 4 ++-- .../app-starter/src/objects/company.object.ts | 6 +++--- .../app-starter/src/objects/contact.object.ts | 4 ++-- .../src/translations/starter.translation.ts | 18 +++++++++--------- examples/app-starter/src/views/company.view.ts | 6 +++--- examples/app-starter/src/views/contact.view.ts | 6 +++--- examples/app-starter/test/boot.test.ts | 16 ++++++++-------- .../src/blank-template-starter-parity.test.ts | 8 ++++---- scripts/ci/publish-starter-marketplace.mjs | 4 ++-- 14 files changed, 54 insertions(+), 54 deletions(-) diff --git a/examples/app-starter/README.md b/examples/app-starter/README.md index ad36a91eb97..9f97e37a57b 100644 --- a/examples/app-starter/README.md +++ b/examples/app-starter/README.md @@ -3,8 +3,8 @@ 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. -- `src/objects/` — `starter_company` (name, type, industry, website, phone, - address) and `starter_contact` (name, company, job title, influence, email, +- `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. @@ -15,7 +15,7 @@ companies, the people at them, and the platform's tasks and notes in one menu. - `src/data/` — five sample companies and six sample contacts. - `src/translations/` — English and Simplified Chinese. -The API names carry the `starter_` namespace, so a tenant can install this +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. diff --git a/examples/app-starter/objectstack.config.ts b/examples/app-starter/objectstack.config.ts index a9f53fd9b0e..a5b0560fd30 100644 --- a/examples/app-starter/objectstack.config.ts +++ b/examples/app-starter/objectstack.config.ts @@ -15,7 +15,7 @@ import { StarterSeedData } from './src/data/index.js'; * and notes in the same menu. * * A small, complete app an organization installs and then makes its own: two - * objects (`starter_company`, `starter_contact`), a grid and a board for each, + * 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. * 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. @@ -23,7 +23,7 @@ import { StarterSeedData } from './src/data/index.js'; export default defineStack({ manifest: { id: 'com.example.starter', - namespace: 'starter', + namespace: 'biz', version: '0.1.0', type: 'app', name: 'Starter', diff --git a/examples/app-starter/src/apps/starter.app.ts b/examples/app-starter/src/apps/starter.app.ts index 767c9f15e9b..ce8f4ad19aa 100644 --- a/examples/app-starter/src/apps/starter.app.ts +++ b/examples/app-starter/src/apps/starter.app.ts @@ -12,7 +12,7 @@ import { App } from '@objectstack/spec/ui'; * label: each shows the current, localized label of what it opens. */ export const StarterApp = App.create({ - name: 'starter_app', + name: 'biz_app', label: 'Starter', icon: 'rocket', branding: { @@ -20,13 +20,13 @@ export const StarterApp = App.create({ }, navigation: [ - { id: 'nav_companies', type: 'object', objectName: 'starter_company', icon: 'building-2' }, - { id: 'nav_contacts', type: 'object', objectName: 'starter_contact', icon: 'contact' }, + { id: 'nav_companies', type: 'object', objectName: 'biz_company', icon: 'building-2' }, + { id: 'nav_contacts', type: 'object', objectName: 'biz_contact', icon: 'contact' }, // `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. { id: 'nav_tasks', type: 'object', objectName: 'sys_task', requiresObject: 'sys_task', icon: 'square-check' }, { id: 'nav_notes', type: 'object', objectName: 'sys_note', requiresObject: 'sys_note', icon: 'notebook-pen' }, - { id: 'nav_overview', type: 'dashboard', dashboardName: 'starter_overview_dashboard', icon: 'layout-dashboard' }, + { id: 'nav_overview', type: 'dashboard', dashboardName: 'biz_overview_dashboard', icon: 'layout-dashboard' }, ], }); diff --git a/examples/app-starter/src/dashboards/overview.dashboard.ts b/examples/app-starter/src/dashboards/overview.dashboard.ts index 504fa4aa1d8..7bba4d03bdf 100644 --- a/examples/app-starter/src/dashboards/overview.dashboard.ts +++ b/examples/app-starter/src/dashboards/overview.dashboard.ts @@ -7,7 +7,7 @@ import { Dashboard } from '@objectstack/spec/ui'; * Every widget binds to one of the two datasets (ADR-0021). */ export const OverviewDashboard = Dashboard.create({ - name: 'starter_overview_dashboard', + name: 'biz_overview_dashboard', label: 'Overview', description: 'Companies and contacts at a glance.', columns: 12, @@ -17,7 +17,7 @@ export const OverviewDashboard = Dashboard.create({ type: 'metric', title: 'Companies', description: 'Every company, whatever its type.', - dataset: 'starter_company_metrics', + dataset: 'biz_company_metrics', values: ['company_count'], layout: { x: 0, y: 0, w: 4, h: 2 }, }, @@ -27,7 +27,7 @@ export const OverviewDashboard = Dashboard.create({ title: 'Customers', description: 'Companies whose type is Customer.', filter: { type: 'customer' }, - dataset: 'starter_company_metrics', + dataset: 'biz_company_metrics', values: ['company_count'], layout: { x: 4, y: 0, w: 4, h: 2 }, }, @@ -36,7 +36,7 @@ export const OverviewDashboard = Dashboard.create({ type: 'metric', title: 'Contacts', description: 'Every contact.', - dataset: 'starter_contact_metrics', + dataset: 'biz_contact_metrics', values: ['contact_count'], layout: { x: 8, y: 0, w: 4, h: 2 }, }, @@ -45,7 +45,7 @@ export const OverviewDashboard = Dashboard.create({ type: 'bar', title: 'Companies by Type', description: 'How many companies there are of each type.', - dataset: 'starter_company_metrics', + dataset: 'biz_company_metrics', dimensions: ['type'], values: ['company_count'], layout: { x: 0, y: 2, w: 6, h: 4 }, @@ -55,7 +55,7 @@ export const OverviewDashboard = Dashboard.create({ type: 'pie', title: 'Companies by Industry', description: 'How the companies split across industries.', - dataset: 'starter_company_metrics', + dataset: 'biz_company_metrics', dimensions: ['industry'], values: ['company_count'], layout: { x: 6, y: 2, w: 6, h: 4 }, @@ -65,7 +65,7 @@ export const OverviewDashboard = Dashboard.create({ type: 'bar', title: 'Contacts by Company', description: 'How many contacts each company has.', - dataset: 'starter_contact_metrics', + dataset: 'biz_contact_metrics', dimensions: ['company'], values: ['contact_count'], layout: { x: 0, y: 6, w: 12, h: 4 }, diff --git a/examples/app-starter/src/datasets/company.dataset.ts b/examples/app-starter/src/datasets/company.dataset.ts index 57e490ea8c1..cbe63a27e1e 100644 --- a/examples/app-starter/src/datasets/company.dataset.ts +++ b/examples/app-starter/src/datasets/company.dataset.ts @@ -7,10 +7,10 @@ import { defineDataset } from '@objectstack/spec/ui'; * select the dimension and measure by name. */ export const CompanyDataset = defineDataset({ - name: 'starter_company_metrics', + name: 'biz_company_metrics', label: 'Company Metrics', description: 'How many companies there are, by type and by industry', - object: 'starter_company', + object: 'biz_company', dimensions: [ { diff --git a/examples/app-starter/src/datasets/contact.dataset.ts b/examples/app-starter/src/datasets/contact.dataset.ts index bc149ba406d..d443afccf33 100644 --- a/examples/app-starter/src/datasets/contact.dataset.ts +++ b/examples/app-starter/src/datasets/contact.dataset.ts @@ -6,10 +6,10 @@ import { defineDataset } from '@objectstack/spec/ui'; * Contact counts (ADR-0021): the dashboard's contact tiles bind here. */ export const ContactDataset = defineDataset({ - name: 'starter_contact_metrics', + name: 'biz_contact_metrics', label: 'Contact Metrics', description: 'How many contacts there are, by company and by influence', - object: 'starter_contact', + object: 'biz_contact', dimensions: [ { diff --git a/examples/app-starter/src/objects/company.object.ts b/examples/app-starter/src/objects/company.object.ts index 2796c0c3d45..f3cdf217d35 100644 --- a/examples/app-starter/src/objects/company.object.ts +++ b/examples/app-starter/src/objects/company.object.ts @@ -6,7 +6,7 @@ import { ObjectSchema, Field } from '@objectstack/spec/data'; * A company the organization works with — a customer, a prospect, a supplier * or a partner. * - * The API names carry the package namespace (`starter_`), so a tenant that + * The API names carry the package namespace (`biz_`), so a tenant that * installs this starter beside a CRM package keeps both: the CRM's own account * and contact objects use other names. * @@ -14,7 +14,7 @@ import { ObjectSchema, Field } from '@objectstack/spec/data'; * `owner_id` column, set to the creator on insert. */ export const Company = ObjectSchema.create({ - name: 'starter_company', + name: 'biz_company', // Shared inside the organization: a starter workspace where everyone sees // every company. An organization that wants owner-only records changes this // after it installs the starter. @@ -78,6 +78,6 @@ export const Company = ObjectSchema.create({ // The company's record page lists its contacts. relatedLists: [ - { list: 'starter_contact', columns: ['name', 'title', 'email', 'phone'] }, + { list: 'biz_contact', columns: ['name', 'title', 'email', 'phone'] }, ], }); diff --git a/examples/app-starter/src/objects/contact.object.ts b/examples/app-starter/src/objects/contact.object.ts index a4ddb36a1fb..eb675fd266d 100644 --- a/examples/app-starter/src/objects/contact.object.ts +++ b/examples/app-starter/src/objects/contact.object.ts @@ -10,7 +10,7 @@ import { ObjectSchema, Field } from '@objectstack/spec/data'; * company (`company`), and the company's record page lists its contacts. */ export const Contact = ObjectSchema.create({ - name: 'starter_contact', + name: 'biz_contact', // Shared inside the organization, as the companies are. sharingModel: 'public_read_write', label: 'Contact', @@ -28,7 +28,7 @@ export const Contact = ObjectSchema.create({ searchable: true, maxLength: 120, }), - company: Field.lookup('starter_company', { + company: Field.lookup('biz_company', { label: 'Company', }), title: Field.text({ diff --git a/examples/app-starter/src/translations/starter.translation.ts b/examples/app-starter/src/translations/starter.translation.ts index 562da8ca235..72af5a4d728 100644 --- a/examples/app-starter/src/translations/starter.translation.ts +++ b/examples/app-starter/src/translations/starter.translation.ts @@ -11,7 +11,7 @@ import { defineTranslationBundle } from '@objectstack/spec/system'; export const StarterTranslationBundle = defineTranslationBundle({ en: { objects: { - starter_company: { + biz_company: { label: 'Company', pluralLabel: 'Companies', fields: { @@ -25,7 +25,7 @@ export const StarterTranslationBundle = defineTranslationBundle({ owner_id: { label: 'Owner' }, }, }, - starter_contact: { + biz_contact: { label: 'Contact', pluralLabel: 'Contacts', fields: { @@ -41,7 +41,7 @@ export const StarterTranslationBundle = defineTranslationBundle({ }, }, apps: { - starter_app: { + biz_app: { label: 'Starter', description: 'Companies and contacts, with tasks and notes', }, @@ -54,7 +54,7 @@ export const StarterTranslationBundle = defineTranslationBundle({ 'com.example.starter': { name: '入门示例', description: '公司与联系人,菜单中附带平台的任务和备注。' }, }, objects: { - starter_company: { + biz_company: { label: '公司', pluralLabel: '公司', description: '与本组织往来的公司。', @@ -98,7 +98,7 @@ export const StarterTranslationBundle = defineTranslationBundle({ more: { label: '更多' }, }, }, - starter_contact: { + biz_contact: { label: '联系人', pluralLabel: '联系人', description: '往来公司里的人,不是本组织的员工。', @@ -132,13 +132,13 @@ export const StarterTranslationBundle = defineTranslationBundle({ }, }, apps: { - starter_app: { + biz_app: { label: '起步应用', description: '公司和联系人,以及任务和备忘', }, }, datasets: { - starter_company_metrics: { + biz_company_metrics: { label: '公司统计', description: '公司有多少家,按类型和行业分', dimensions: { @@ -152,7 +152,7 @@ export const StarterTranslationBundle = defineTranslationBundle({ company_count: { label: '公司数', description: '公司有多少家,不论类型。' }, }, }, - starter_contact_metrics: { + biz_contact_metrics: { label: '联系人统计', description: '联系人有多少位,按公司和影响力分', dimensions: { @@ -165,7 +165,7 @@ export const StarterTranslationBundle = defineTranslationBundle({ }, }, dashboards: { - starter_overview_dashboard: { + biz_overview_dashboard: { label: '概览', description: '公司和联系人一览。', widgets: { diff --git a/examples/app-starter/src/views/company.view.ts b/examples/app-starter/src/views/company.view.ts index 99c232f978c..529538825e3 100644 --- a/examples/app-starter/src/views/company.view.ts +++ b/examples/app-starter/src/views/company.view.ts @@ -13,7 +13,7 @@ export const CompanyViews = defineView({ list: { label: 'All Companies', type: 'grid', - data: { provider: 'object', object: 'starter_company' }, + data: { provider: 'object', object: 'biz_company' }, columns: [ { field: 'name' }, { field: 'type' }, @@ -27,7 +27,7 @@ export const CompanyViews = defineView({ all: { label: 'All Companies', type: 'grid', - data: { provider: 'object', object: 'starter_company' }, + data: { provider: 'object', object: 'biz_company' }, columns: [ { field: 'name' }, { field: 'type' }, @@ -40,7 +40,7 @@ export const CompanyViews = defineView({ by_type: { label: 'Companies by Type', type: 'kanban', - data: { provider: 'object', object: 'starter_company' }, + data: { provider: 'object', object: 'biz_company' }, columns: ['name', 'industry', 'phone'], kanban: { groupByField: 'type', diff --git a/examples/app-starter/src/views/contact.view.ts b/examples/app-starter/src/views/contact.view.ts index 41bf1f839ed..71b06d8e5ae 100644 --- a/examples/app-starter/src/views/contact.view.ts +++ b/examples/app-starter/src/views/contact.view.ts @@ -12,7 +12,7 @@ export const ContactViews = defineView({ list: { label: 'All Contacts', type: 'grid', - data: { provider: 'object', object: 'starter_contact' }, + data: { provider: 'object', object: 'biz_contact' }, columns: [ { field: 'name' }, { field: 'company' }, @@ -26,7 +26,7 @@ export const ContactViews = defineView({ all: { label: 'All Contacts', type: 'grid', - data: { provider: 'object', object: 'starter_contact' }, + data: { provider: 'object', object: 'biz_contact' }, columns: [ { field: 'name' }, { field: 'company' }, @@ -39,7 +39,7 @@ export const ContactViews = defineView({ by_influence: { label: 'Contacts by Influence', type: 'kanban', - data: { provider: 'object', object: 'starter_contact' }, + data: { provider: 'object', object: 'biz_contact' }, columns: ['name', 'company', 'title'], kanban: { groupByField: 'influence', diff --git a/examples/app-starter/test/boot.test.ts b/examples/app-starter/test/boot.test.ts index c9c41ef6971..57c5872541f 100644 --- a/examples/app-starter/test/boot.test.ts +++ b/examples/app-starter/test/boot.test.ts @@ -95,18 +95,18 @@ describe('app-starter — installed as a starter, menu, uninstall', () => { // The copy is a writable package of its own, beside the package id. base = install.body?.data?.targetPackageId; - app = await call('GET', '/meta/app/starter_app'); - companies = await call('GET', '/data/starter_company'); - contacts = await call('GET', '/data/starter_contact'); + app = await call('GET', '/meta/app/biz_app'); + companies = await call('GET', '/data/biz_company'); + contacts = await call('GET', '/data/biz_contact'); task = await call('POST', '/data/sys_task', { title: 'Call Northwind about the renewal' }); note = await call('POST', '/data/sys_note', { title: 'Northwind visit', body: 'Met the purchasing team.' }); uninstall = await call('DELETE', `/packages/${base}`); - after.company = await call('GET', '/meta/object/starter_company'); - after.contact = await call('GET', '/meta/object/starter_contact'); - after.app = await call('GET', '/meta/app/starter_app'); + after.company = await call('GET', '/meta/object/biz_company'); + after.contact = await call('GET', '/meta/object/biz_contact'); + after.app = await call('GET', '/meta/app/biz_app'); after.task = await call('GET', `/data/sys_task/${unwrap(task)?.id}`); after.note = await call('GET', `/data/sys_note/${unwrap(note)?.id}`); }, 180_000); @@ -132,8 +132,8 @@ describe('app-starter — installed as a starter, menu, uninstall', () => { const objectEntries = (unwrap(app)?.navigation ?? []) .filter((n: any) => n.type === 'object') .map((n: any) => n.objectName); - expect(objectEntries).toEqual(['starter_company', 'starter_contact', 'sys_task', 'sys_note']); - expect((stack.objects ?? []).map((o) => o.name).sort()).toEqual(['starter_company', 'starter_contact']); + expect(objectEntries).toEqual(['biz_company', 'biz_contact', 'sys_task', 'sys_note']); + expect((stack.objects ?? []).map((o) => o.name).sort()).toEqual(['biz_company', 'biz_contact']); }); it('precondition: a task and a note were written before the uninstall', () => { diff --git a/packages/create-objectstack/src/blank-template-starter-parity.test.ts b/packages/create-objectstack/src/blank-template-starter-parity.test.ts index 730729c832c..c029449c6b3 100644 --- a/packages/create-objectstack/src/blank-template-starter-parity.test.ts +++ b/packages/create-objectstack/src/blank-template-starter-parity.test.ts @@ -16,12 +16,12 @@ // // ## What "equal" means: the code, modulo the namespace, blind to comments // -// The Starter names its objects under its own namespace (`starter_company`); +// The Starter names its objects under its own namespace (`biz_company`); // the template names them under the template's (`blank_company`), and the // scaffolder moves every such literal onto the project's namespace // (`rewriteObjectNamePrefix`, which rewrites every quoted `blank_…` literal, // references included — see `rewrite-identity.test.ts`). So the Starter's -// source is compared with `starter_` literals spelled `blank_`, and nothing +// source is compared with `biz_` literals spelled `blank_`, and nothing // else changed. // // Comments are NOT compared. The template's comments are written for a @@ -50,7 +50,7 @@ const BLANK_SRC = path.join(BLANK, 'src'); const STARTER_SRC = path.resolve(HERE, '../../../examples/app-starter/src'); const STARTER_CONFIG = path.resolve(HERE, '../../../examples/app-starter/objectstack.config.ts'); -/** The template's namespace, from its config: what every `starter_` literal is spelled as here. */ +/** The template's namespace, from its config: what every `biz_` literal is spelled as here. */ const BLANK_NAMESPACE = /\bnamespace:\s*'([a-z0-9_]+)'/.exec( fs.readFileSync(path.join(BLANK, 'objectstack.config.ts'), 'utf8'), )?.[1]; @@ -117,7 +117,7 @@ const PAIRS = [ describe('blank template — the Starter app\'s companies and contacts, as source', () => { it('reads two real namespaces (vacuity guard)', () => { expect(BLANK_NAMESPACE).toBe('blank'); - expect(STARTER_NAMESPACE).toBe('starter'); + expect(STARTER_NAMESPACE).toBe('biz'); }); it.each(PAIRS)('the $what is the Starter\'s definition, modulo the namespace', ({ file, callee }) => { diff --git a/scripts/ci/publish-starter-marketplace.mjs b/scripts/ci/publish-starter-marketplace.mjs index 996f10d31c8..7e07829c208 100644 --- a/scripts/ci/publish-starter-marketplace.mjs +++ b/scripts/ci/publish-starter-marketplace.mjs @@ -389,8 +389,8 @@ function fixtureDir({ objects = 1, id = STARTER_MANIFEST_ID, manifestVersion = ' if (dist) { fs.mkdirSync(path.join(dir, 'dist')); const artifact = { - manifest: { id, namespace: 'starter', version: manifestVersion, type: 'app', name: 'Starter', description: 'Companies and contacts.' }, - objects: Array.from({ length: objects }, (_, i) => ({ name: `starter_o${i}` })), + manifest: { id, namespace: 'biz', version: manifestVersion, type: 'app', name: 'Starter', description: 'Companies and contacts.' }, + objects: Array.from({ length: objects }, (_, i) => ({ name: `biz_o${i}` })), apps: [{ name: 'starter' }], }; fs.writeFileSync(path.join(dir, 'dist', 'objectstack.json'), JSON.stringify(artifact)); From d11655caedaf1c02967d2e531e6eada555471b87 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 28 Nov 2026 23:23:42 +0000 Subject: [PATCH 02/10] chore(changeset): example-starter namespace rename to biz Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01FEkQ5oQLfL8thb6wtUHnTb --- .changeset/38371-starter-namespace-biz.md | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 .changeset/38371-starter-namespace-biz.md diff --git a/.changeset/38371-starter-namespace-biz.md b/.changeset/38371-starter-namespace-biz.md new file mode 100644 index 00000000000..a62808494dd --- /dev/null +++ b/.changeset/38371-starter-namespace-biz.md @@ -0,0 +1,10 @@ +--- +'@objectstack/example-starter': patch +--- + +refactor(example-starter): the Starter app's namespace is now `biz` (was `starter`) + +Clause-②: no +Metadata-protocol: none + +Every API name that carried the `starter_` prefix now carries `biz_`: the objects `starter_company` → `biz_company` and `starter_contact` → `biz_contact`, the app `starter_app` → `biz_app`, the dashboard `starter_overview_dashboard` → `biz_overview_dashboard`, and the datasets `starter_company_metrics` → `biz_company_metrics` and `starter_contact_metrics` → `biz_contact_metrics`, with their translation keys in both locales. The manifest id stays `com.example.starter`, and the package name and display name are unchanged. No alias is kept: the Starter installs unmanaged, as a copy the organization owns, so an environment that already installed it keeps its `starter_*` objects as they are. From 2c5c3d14954730c8b4a787f6cec3e81e1ff2ee6f Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 28 Nov 2026 23:28:31 +0000 Subject: [PATCH 03/10] feat(create-objectstack): help articles in the blank template A blank_article object (title, Markdown body, category, status), its grid view, a menu entry, en and zh-CN labels, and four sample articles seeded on boot, one left as a draft. The starter test reads the seed and the menu. Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01FEkQ5oQLfL8thb6wtUHnTb --- .../src/templates/blank/README.md | 44 ++++--- .../src/templates/blank/objectstack.config.ts | 15 +++ .../src/templates/blank/src/apps/main.app.ts | 5 +- .../src/templates/blank/src/data/articles.ts | 123 ++++++++++++++++++ .../src/templates/blank/src/data/index.ts | 5 + .../blank/src/objects/article.object.ts | 72 ++++++++++ .../src/templates/blank/src/objects/index.ts | 1 + .../templates/blank/src/translations/index.ts | 4 + .../src/translations/main.translation.ts | 67 ++++++++++ .../templates/blank/src/views/article.view.ts | 39 ++++++ .../src/templates/blank/src/views/index.ts | 1 + .../src/templates/blank/starter.test.ts | 22 +++- 12 files changed, 376 insertions(+), 22 deletions(-) create mode 100644 packages/create-objectstack/src/templates/blank/src/data/articles.ts create mode 100644 packages/create-objectstack/src/templates/blank/src/data/index.ts create mode 100644 packages/create-objectstack/src/templates/blank/src/objects/article.object.ts create mode 100644 packages/create-objectstack/src/templates/blank/src/translations/index.ts create mode 100644 packages/create-objectstack/src/templates/blank/src/translations/main.translation.ts create mode 100644 packages/create-objectstack/src/templates/blank/src/views/article.view.ts diff --git a/packages/create-objectstack/src/templates/blank/README.md b/packages/create-objectstack/src/templates/blank/README.md index 5dc8f2b5783..6cfc8bf2fb0 100644 --- a/packages/create-objectstack/src/templates/blank/README.md +++ b/packages/create-objectstack/src/templates/blank/README.md @@ -1,7 +1,7 @@ # Blank Starter An ObjectStack environment that starts with companies, the people at them, -and the platform's tasks and notes in one menu — yours to change. +help articles, and the platform's tasks and notes in one menu — yours to change. ## Getting started @@ -29,8 +29,8 @@ curl -b cookies.txt "http://localhost:3000/api/v1/data/" ## What this project starts with -The same companies and contacts as the platform's Starter app, as source you -own: +The same companies, contacts and help articles as the platform's Starter app, +as source you own: - `src/objects/company.object.ts` — **Company**: a company the organization works with (a customer, a prospect, a partner, a supplier), with its type, @@ -38,9 +38,15 @@ own: - `src/objects/contact.object.ts` — **Contact**: a person at one of those companies, with a job title, an influence, an email and a phone. A contact is not a user and never signs in. +- `src/objects/article.object.ts` — **Article**: a help article (a how-to, a + common question or a reference page) with a Markdown body, a category and a + status; `src/data/articles.ts` seeds four sample articles, one a draft, and + `src/translations/` labels them in English and Simplified Chinese. - `src/views/company.view.ts`, `src/views/contact.view.ts` — a grid of every - record and a board (companies by type, contacts by influence). -- `src/apps/main.app.ts` — the menu: Companies, Contacts, Tasks and Notes. + record and a board (companies by type, contacts by influence); + `src/views/article.view.ts` — a grid of every article. +- `src/apps/main.app.ts` — the menu: Companies, Contacts, Articles, Tasks and + Notes. **Tasks and Notes are the platform's own objects** (`sys_task`, `sys_note`), which every environment carries. This project declares no copy of them: the @@ -48,7 +54,9 @@ menu points at them, so they stay when your app changes or goes, and a task or a note never changes who may see the record it is about. Change any of it freely: rename a field, add one, or replace both objects with -your own. To remove companies and contacts entirely: +your own. To remove companies and contacts entirely (help articles go the same +way: their object, view, menu entry, `src/data/articles.ts` and the +`src/translations/` entries): 1. Delete `src/objects/company.object.ts` and `src/objects/contact.object.ts` and their export lines in `src/objects/index.ts`. @@ -57,7 +65,8 @@ your own. To remove companies and contacts entirely: entries in `src/apps/main.app.ts` (put your own objects there instead — see [The Console](#the-console) below). 3. Point `starter.test.ts` at your own objects (rename the file to match). It - imports `Company` and `Contact`, so it stops compiling until you do. + imports `Company`, `Contact` and `Article`, so it stops compiling until you + do. 4. Run `pnpm validate` and `pnpm test`. ## The Console @@ -65,11 +74,12 @@ your own. To remove companies and contacts entirely: `pnpm dev` also serves the admin Console at `http://localhost:3000/_console/`, and prints the link on boot. Open it and you will see this project's app, **Main**, beside the platform's own apps (Setup, Account), with Companies, -Contacts, Tasks and Notes in its menu. +Contacts, Articles, Tasks and Notes in its menu. **An object appears in Console navigation only when an app lists it.** -`src/apps/main.app.ts` lists companies and contacts, and -`src/views/company.view.ts` and `src/views/contact.view.ts` draw their lists. A package whose manifest type is `app` holds at most one app, +`src/apps/main.app.ts` lists companies, contacts and articles, and +`src/views/company.view.ts`, `src/views/contact.view.ts` and +`src/views/article.view.ts` draw their lists. A package whose manifest type is `app` holds at most one app, so `main.app.ts` is the one: to show another object, add a navigation entry for it to that app's `navigation` (a `group` entry with children nests them) rather than a second app, and give it a list view. `objectstack generate view OBJECT` @@ -100,11 +110,13 @@ for OAuth, API keys, and which objects/actions become tools. - `objectstack.config.ts` — environment manifest (objects, API, plugins), and the wiring for every directory below -- `src/objects/` — object definitions (one file per object): companies and - contacts, described [above](#what-this-project-starts-with) +- `src/objects/` — object definitions (one file per object): companies, + contacts and articles, described [above](#what-this-project-starts-with) - `src/apps/` — the app, `main.app.ts`, described in - [The Console](#the-console); `src/views/` — the companies' and contacts' - list views + [The Console](#the-console); `src/views/` — the companies', contacts' and + articles' list views +- `src/data/` — sample rows, seeded on each boot; `src/translations/` — labels + in the locales the config's `i18n` block lists - `src/actions/`, `src/flows/`, `src/dashboards/`, `src/skills/`, `src/picklists/`, `src/security/` (permission sets), `src/datasets/` (analytics datasets) — empty to start. Each directory's `index.ts` @@ -169,8 +181,8 @@ record. See `AGENTS.md` for the full convention. `pnpm test` checks what the app *does*. `starter.test.ts` boots this app's stack in-process with `bootStack` from `@objectstack/verify` (in-memory database, no server) and asserts business facts through its handle: a company -without a name is refused, a contact belongs to a company, and the menu lists -Companies, Contacts, Tasks and Notes. Write your own the same way: `stack.hooks.run` makes a real +without a name is refused, a contact belongs to a company, the sample articles +are loaded, and the menu lists Companies, Contacts, Articles, Tasks and Notes. Write your own the same way: `stack.hooks.run` makes a real write through validation, permissions and hooks, and the same handle runs flows and actions, seeds fixtures and reads rows as a given user. diff --git a/packages/create-objectstack/src/templates/blank/objectstack.config.ts b/packages/create-objectstack/src/templates/blank/objectstack.config.ts index e277fcf8450..fe03c0b27c9 100644 --- a/packages/create-objectstack/src/templates/blank/objectstack.config.ts +++ b/packages/create-objectstack/src/templates/blank/objectstack.config.ts @@ -9,6 +9,8 @@ import * as skills from './src/skills'; import * as picklists from './src/picklists'; import * as permissions from './src/security'; import * as datasets from './src/datasets'; +import * as data from './src/data'; +import * as translations from './src/translations'; // Every value a barrel exports, as the list a stack key takes: typed by what // the barrel exports, and an empty list while it exports nothing yet. @@ -81,4 +83,17 @@ export default defineStack({ picklists: exportsOf(picklists), permissions: exportsOf(permissions), datasets: exportsOf(datasets), + + // Sample rows (src/data/): each boot inserts a row that is missing and + // leaves one that exists as it is. + data: exportsOf(data), + + // Labels in each locale the app supports (src/translations/). A user sees + // their own locale, and English where a label has no translation. + i18n: { + defaultLocale: 'en', + supportedLocales: ['en', 'zh-CN'], + fallbackLocale: 'en', + }, + translations: exportsOf(translations), }); diff --git a/packages/create-objectstack/src/templates/blank/src/apps/main.app.ts b/packages/create-objectstack/src/templates/blank/src/apps/main.app.ts index fa241ef5c3c..7f35cee8bcd 100644 --- a/packages/create-objectstack/src/templates/blank/src/apps/main.app.ts +++ b/packages/create-objectstack/src/templates/blank/src/apps/main.app.ts @@ -11,8 +11,8 @@ import * as UI from '@objectstack/spec/ui'; // below (a 'group' entry with children nests them) rather than a second app, // and give it a list view — `objectstack generate view OBJECT` writes one. // -// The menu is the platform's Starter app's: this project's companies and -// contacts, then the platform's tasks and notes. Tasks and notes are the +// The menu is the platform's Starter app's: this project's companies, +// contacts and help articles, then the platform's tasks and notes. Tasks and notes are the // platform objects `sys_task` and `sys_note`, which every environment carries; // this project declares no copy of them, so a task or a note can be about any // record without changing who may see that record. No entry carries a label: @@ -23,6 +23,7 @@ const mainApp: UI.App = { navigation: [ { id: 'nav_companies', type: 'object', objectName: 'blank_company', icon: 'building-2' }, { id: 'nav_contacts', type: 'object', objectName: 'blank_contact', icon: 'contact' }, + { id: 'nav_articles', type: 'object', objectName: 'blank_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. diff --git a/packages/create-objectstack/src/templates/blank/src/data/articles.ts b/packages/create-objectstack/src/templates/blank/src/data/articles.ts new file mode 100644 index 00000000000..f9f2108e3ff --- /dev/null +++ b/packages/create-objectstack/src/templates/blank/src/data/articles.ts @@ -0,0 +1,123 @@ +// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. + +// Sample help articles, so the Articles list has something to show on first +// open: the same articles as the platform's Starter app. Business data: no +// `mode`, so each boot inserts an article that is missing and leaves one that +// exists as you left it. Delete the rows, or this file and its export line in +// `src/data/index.ts`, when they are no longer wanted. +// +// Each `body` is Markdown in one shape: the article's title as a `#` heading, +// then one `##` section per topic, each with its own text and short enough to +// read on its own. Write new articles the same way. + +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.`, + }, + ], +}); diff --git a/packages/create-objectstack/src/templates/blank/src/data/index.ts b/packages/create-objectstack/src/templates/blank/src/data/index.ts new file mode 100644 index 00000000000..ff90ed0dd8e --- /dev/null +++ b/packages/create-objectstack/src/templates/blank/src/data/index.ts @@ -0,0 +1,5 @@ +// The sample data in this directory, as seeds: each names the object it fills +// and the field that identifies a row. objectstack.config.ts hands every +// export of this file to the stack's `data`, and each boot inserts a row that +// is missing and leaves one that exists as it is. +export { articles } from './articles.js'; diff --git a/packages/create-objectstack/src/templates/blank/src/objects/article.object.ts b/packages/create-objectstack/src/templates/blank/src/objects/article.object.ts new file mode 100644 index 00000000000..f4a791482cf --- /dev/null +++ b/packages/create-objectstack/src/templates/blank/src/objects/article.object.ts @@ -0,0 +1,72 @@ +// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. + +// The help articles this project starts with: how-to guides, answers to +// common questions and reference pages, written in Markdown. They are the +// same definition as the platform's Starter app, so a project scaffolded +// today and an environment that installed the Starter hold the same articles. +// They are yours now: add a category, change the fields, or delete the object +// (the README's "What this project starts with" says what goes with it). +// +// The object's API name carries this project's namespace: scaffolding renamed +// every name in `src/`, references included, from the template's own. Write +// any new name the same way, `_`. + +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 sample 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: 'blank_article', + // Org-wide default (OWD), as on the companies and contacts: everyone in the + // organization reads and edits every article. `private` makes them + // owner-only until a permission grant or a sharing rule widens access: + // https://objectstack.ai/docs/permissions/sharing-rules + 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. A field shows on the form only once a section lists it. + fieldGroups: [ + { key: 'basic', label: 'Article', fields: ['title', 'category', 'status', 'body'] }, + ], +}); diff --git a/packages/create-objectstack/src/templates/blank/src/objects/index.ts b/packages/create-objectstack/src/templates/blank/src/objects/index.ts index 9be9e397a92..1c56b35ab15 100644 --- a/packages/create-objectstack/src/templates/blank/src/objects/index.ts +++ b/packages/create-objectstack/src/templates/blank/src/objects/index.ts @@ -2,5 +2,6 @@ // here and adds its export line below. objectstack.config.ts hands every // export of this file to the stack, so an object exported here is part of it, // and an object file this index does not export is never loaded. +export { Article } from './article.object.js'; export { Company } from './company.object.js'; export { Contact } from './contact.object.js'; diff --git a/packages/create-objectstack/src/templates/blank/src/translations/index.ts b/packages/create-objectstack/src/templates/blank/src/translations/index.ts new file mode 100644 index 00000000000..248471e1ed3 --- /dev/null +++ b/packages/create-objectstack/src/templates/blank/src/translations/index.ts @@ -0,0 +1,4 @@ +// The translation bundles in this directory. objectstack.config.ts hands every +// export of this file to the stack's `translations`, in the locales its `i18n` +// block lists. +export { MainTranslationBundle } from './main.translation.js'; diff --git a/packages/create-objectstack/src/templates/blank/src/translations/main.translation.ts b/packages/create-objectstack/src/templates/blank/src/translations/main.translation.ts new file mode 100644 index 00000000000..9fcbab595db --- /dev/null +++ b/packages/create-objectstack/src/templates/blank/src/translations/main.translation.ts @@ -0,0 +1,67 @@ +// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. + +import { defineTranslationBundle } from '@objectstack/spec/system'; + +/** + * This project's labels in English and Simplified Chinese — today the help + * articles', the same text as the platform's Starter app. + * + * Object keys are quoted names, `'_'`, the way every name in + * `src/` is written, so they always name the object they translate. Add a + * locale by listing it in `i18n.supportedLocales` in objectstack.config.ts + * and adding its block here; `objectstack i18n check` lists the keys a locale + * is missing. + */ +export const MainTranslationBundle = defineTranslationBundle({ + en: { + objects: { + 'blank_article': { + label: 'Article', + pluralLabel: 'Articles', + fields: { + title: { label: 'Title' }, + body: { label: 'Body' }, + category: { label: 'Category' }, + status: { label: 'Status' }, + owner_id: { label: 'Owner' }, + }, + }, + }, + }, + + 'zh-CN': { + objects: { + 'blank_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: '文章' }, + }, + }, + }, + }, +}); diff --git a/packages/create-objectstack/src/templates/blank/src/views/article.view.ts b/packages/create-objectstack/src/templates/blank/src/views/article.view.ts new file mode 100644 index 00000000000..f2cfa399836 --- /dev/null +++ b/packages/create-objectstack/src/templates/blank/src/views/article.view.ts @@ -0,0 +1,39 @@ +// 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, the same view as the platform's Starter app. The menu's Articles + * entry (`src/apps/main.app.ts`) opens it. + * + * No `form` here: the Console's create and edit form lays a record out by the + * object's `fieldGroups` (`src/objects/article.object.ts`), and a declared + * default form is not loaded there. + */ +const ArticleViews = defineView({ + list: { + label: 'All Articles', + type: 'grid', + data: { provider: 'object', object: 'blank_article' }, + columns: [ + { field: 'title' }, + { field: 'category' }, + { field: 'status' }, + ], + }, + listViews: { + all: { + label: 'All Articles', + type: 'grid', + data: { provider: 'object', object: 'blank_article' }, + columns: [ + { field: 'title' }, + { field: 'category' }, + { field: 'status' }, + ], + }, + }, +}); + +export default ArticleViews; diff --git a/packages/create-objectstack/src/templates/blank/src/views/index.ts b/packages/create-objectstack/src/templates/blank/src/views/index.ts index 5dd16d3ef15..ce51a865459 100644 --- a/packages/create-objectstack/src/templates/blank/src/views/index.ts +++ b/packages/create-objectstack/src/templates/blank/src/views/index.ts @@ -3,5 +3,6 @@ // export of this file to the stack, so a view exported here is part of it, // and a view file this index does not export is never loaded. export {}; +export { default as article } from './article.view'; export { default as company } from './company.view'; export { default as contact } from './contact.view'; diff --git a/packages/create-objectstack/src/templates/blank/starter.test.ts b/packages/create-objectstack/src/templates/blank/starter.test.ts index e8d7cffe8ed..802276ab244 100644 --- a/packages/create-objectstack/src/templates/blank/starter.test.ts +++ b/packages/create-objectstack/src/templates/blank/starter.test.ts @@ -1,7 +1,7 @@ import { afterAll, beforeAll, describe, expect, it } from 'vitest'; import { bootStack, type VerifyStack } from '@objectstack/verify'; import config from './objectstack.config'; -import { Company, Contact } from './src/objects'; +import { Article, Company, Contact } from './src/objects'; import * as apps from './src/apps'; // Boots THIS app (its objects, its plugins, the services it requires) on the @@ -19,7 +19,7 @@ import * as apps from './src/apps'; // Objects and the app are addressed by the definitions they are imported as // (`Company.name`), never by a typed-out string: scaffolding renamed them to // carry this project's namespace, and adding your own works the same way. -describe('the starter: companies and contacts, with tasks and notes in the menu', () => { +describe('the starter: companies, contacts and help articles, with tasks and notes in the menu', () => { let stack: VerifyStack; let admin: string; @@ -65,7 +65,21 @@ describe('the starter: companies and contacts, with tasks and notes in the menu' expect(contact.company).toBe(company.id); }); - it('the menu lists companies, contacts, tasks and notes', async () => { + it('the sample help articles are loaded, one of them a draft', async () => { + // src/data/articles.ts seeds them on boot; read them the way the Console + // does, through the data route. + const res = await stack.apiAs(admin, 'GET', `/data/${Article.name}`); + expect(res.status).toBe(200); + const body = await res.json(); + const envelope = body?.data ?? body; + const rows: { title: string; status: string }[] = Array.isArray(envelope) + ? envelope + : (envelope?.records ?? envelope?.items ?? []); + expect(rows.map((r) => r.title)).toContain('Set up your new laptop'); + expect(rows.filter((r) => r.status === 'draft')).toHaveLength(1); + }); + + it('the menu lists companies, contacts, articles, tasks and notes', async () => { // Read the app the way the Console does, from the booted stack. Tasks and // notes are the platform's own objects, not this project's. const app = Object.values(apps)[0]; @@ -76,6 +90,6 @@ describe('the starter: companies and contacts, with tasks and notes in the menu' const envelope = body?.data ?? body; const served = envelope?.item ?? envelope; const entries = (served?.navigation ?? []).map((n: { objectName?: string }) => n.objectName); - expect(entries).toEqual([Company.name, Contact.name, 'sys_task', 'sys_note']); + expect(entries).toEqual([Company.name, Contact.name, Article.name, 'sys_task', 'sys_note']); }); }); From 3c0c337f0751e5e4f438ff8c2062fb8d55f7c290 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 28 Nov 2026 23:30:25 +0000 Subject: [PATCH 04/10] feat(example-starter): help articles, the same as the blank template's A biz_article object (title, Markdown body, category, status), its grid view, a menu entry, en and zh-CN labels, and four seed articles, one a draft. A unit test holds every seed body to one Markdown shape; the boot test reads the articles and the menu; the parity test compares the article object, view and seed with the blank template's. Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01FEkQ5oQLfL8thb6wtUHnTb --- examples/app-starter/README.md | 18 ++- examples/app-starter/objectstack.config.ts | 11 +- examples/app-starter/src/apps/starter.app.ts | 5 +- examples/app-starter/src/data/articles.ts | 125 ++++++++++++++++++ examples/app-starter/src/data/index.ts | 9 +- .../app-starter/src/objects/article.object.ts | 57 ++++++++ examples/app-starter/src/objects/index.ts | 1 + .../src/translations/starter.translation.ts | 42 ++++++ .../app-starter/src/views/article.view.ts | 36 +++++ examples/app-starter/src/views/index.ts | 1 + examples/app-starter/test/boot.test.ts | 29 +++- .../test/help-articles-38372.test.ts | 111 ++++++++++++++++ .../src/blank-template-starter-parity.test.ts | 70 ++++++++-- 13 files changed, 477 insertions(+), 38 deletions(-) create mode 100644 examples/app-starter/src/data/articles.ts create mode 100644 examples/app-starter/src/objects/article.object.ts create mode 100644 examples/app-starter/src/views/article.view.ts create mode 100644 examples/app-starter/test/help-articles-38372.test.ts diff --git a/examples/app-starter/README.md b/examples/app-starter/README.md index 9f97e37a57b..6a7e9046dc7 100644 --- a/examples/app-starter/README.md +++ b/examples/app-starter/README.md @@ -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 diff --git a/examples/app-starter/objectstack.config.ts b/examples/app-starter/objectstack.config.ts index a5b0560fd30..ce00c48d4ea 100644 --- a/examples/app-starter/objectstack.config.ts +++ b/examples/app-starter/objectstack.config.ts @@ -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. */ diff --git a/examples/app-starter/src/apps/starter.app.ts b/examples/app-starter/src/apps/starter.app.ts index ce8f4ad19aa..ff8c9fbac86 100644 --- a/examples/app-starter/src/apps/starter.app.ts +++ b/examples/app-starter/src/apps/starter.app.ts @@ -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 @@ -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. diff --git a/examples/app-starter/src/data/articles.ts b/examples/app-starter/src/data/articles.ts new file mode 100644 index 00000000000..6574e42d3ca --- /dev/null +++ b/examples/app-starter/src/data/articles.ts @@ -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.`, + }, + ], +}); diff --git a/examples/app-starter/src/data/index.ts b/examples/app-starter/src/data/index.ts index 189da3c435b..a380b985335 100644 --- a/examples/app-starter/src/data/index.ts +++ b/examples/app-starter/src/data/index.ts @@ -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, { @@ -33,4 +34,4 @@ const contacts = defineSeed(Contact, { ], }); -export const StarterSeedData = [companies, contacts]; +export const StarterSeedData = [companies, contacts, articles]; diff --git a/examples/app-starter/src/objects/article.object.ts b/examples/app-starter/src/objects/article.object.ts new file mode 100644 index 00000000000..b437702af27 --- /dev/null +++ b/examples/app-starter/src/objects/article.object.ts @@ -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'] }, + ], +}); diff --git a/examples/app-starter/src/objects/index.ts b/examples/app-starter/src/objects/index.ts index 89a3487dfe4..a031b5d2a57 100644 --- a/examples/app-starter/src/objects/index.ts +++ b/examples/app-starter/src/objects/index.ts @@ -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'; diff --git a/examples/app-starter/src/translations/starter.translation.ts b/examples/app-starter/src/translations/starter.translation.ts index 72af5a4d728..d56bebc1843 100644 --- a/examples/app-starter/src/translations/starter.translation.ts +++ b/examples/app-starter/src/translations/starter.translation.ts @@ -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: { @@ -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: { diff --git a/examples/app-starter/src/views/article.view.ts b/examples/app-starter/src/views/article.view.ts new file mode 100644 index 00000000000..dad86bb44ac --- /dev/null +++ b/examples/app-starter/src/views/article.view.ts @@ -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' }, + ], + }, + }, +}); diff --git a/examples/app-starter/src/views/index.ts b/examples/app-starter/src/views/index.ts index 540da647017..b037abce0db 100644 --- a/examples/app-starter/src/views/index.ts +++ b/examples/app-starter/src/views/index.ts @@ -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'; diff --git a/examples/app-starter/test/boot.test.ts b/examples/app-starter/test/boot.test.ts index 57c5872541f..258910795be 100644 --- a/examples/app-starter/test/boot.test.ts +++ b/examples/app-starter/test/boot.test.ts @@ -3,9 +3,9 @@ /** * The starter, installed for real: the package goes in through the * marketplace install door as an unmanaged copy with its sample data (the - * starter path), its menu carries the four object entries (companies, - * contacts, and the platform's tasks and notes), and uninstalling it removes - * companies and contacts while every task and note stays. + * starter path), its menu carries the five object entries (companies, + * contacts, articles, and the platform's tasks and notes), and uninstalling it + * removes companies, contacts and articles while every task and note stays. * * One boot of a host with nothing of its own, every phase in `beforeAll`; the * `it`s only read what the phases recorded. The task and the note are written @@ -78,6 +78,7 @@ describe('app-starter — installed as a starter, menu, uninstall', () => { let app: Answer; let companies: Answer; let contacts: Answer; + let articles: Answer; let task: Answer; let note: Answer; let uninstall: Answer; @@ -98,6 +99,7 @@ describe('app-starter — installed as a starter, menu, uninstall', () => { app = await call('GET', '/meta/app/biz_app'); companies = await call('GET', '/data/biz_company'); contacts = await call('GET', '/data/biz_contact'); + articles = await call('GET', '/data/biz_article'); task = await call('POST', '/data/sys_task', { title: 'Call Northwind about the renewal' }); note = await call('POST', '/data/sys_note', { title: 'Northwind visit', body: 'Met the purchasing team.' }); @@ -106,6 +108,7 @@ describe('app-starter — installed as a starter, menu, uninstall', () => { after.company = await call('GET', '/meta/object/biz_company'); after.contact = await call('GET', '/meta/object/biz_contact'); + after.article = await call('GET', '/meta/object/biz_article'); after.app = await call('GET', '/meta/app/biz_app'); after.task = await call('GET', `/data/sys_task/${unwrap(task)?.id}`); after.note = await call('GET', `/data/sys_note/${unwrap(note)?.id}`); @@ -127,13 +130,24 @@ describe('app-starter — installed as a starter, menu, uninstall', () => { expect(olivia?.company).toBe(northwind?.id); }); - it('the menu carries companies, contacts, tasks and notes — tasks and notes are the platform objects', () => { + it('installs its sample help articles, one of them a draft', () => { + expect(articles.status, JSON.stringify(articles.body)).toBe(200); + expect(rows(articles).map((a) => a.title).sort()).toEqual([ + 'Meeting rooms reference', + 'Set up your new laptop', + 'Share files with your team', + 'Wi-Fi and printing FAQ', + ]); + expect(rows(articles).filter((a) => a.status === 'draft').map((a) => a.title)).toEqual(['Share files with your team']); + }); + + it('the menu carries companies, contacts, articles, tasks and notes — tasks and notes are the platform objects', () => { expect(app.status, JSON.stringify(app.body)).toBe(200); const objectEntries = (unwrap(app)?.navigation ?? []) .filter((n: any) => n.type === 'object') .map((n: any) => n.objectName); - expect(objectEntries).toEqual(['biz_company', 'biz_contact', 'sys_task', 'sys_note']); - expect((stack.objects ?? []).map((o) => o.name).sort()).toEqual(['biz_company', 'biz_contact']); + expect(objectEntries).toEqual(['biz_company', 'biz_contact', 'biz_article', 'sys_task', 'sys_note']); + expect((stack.objects ?? []).map((o) => o.name).sort()).toEqual(['biz_article', 'biz_company', 'biz_contact']); }); it('precondition: a task and a note were written before the uninstall', () => { @@ -143,10 +157,11 @@ describe('app-starter — installed as a starter, menu, uninstall', () => { expect(unwrap(note)?.id).toBeTruthy(); }); - it('uninstall removes companies, contacts and the app', () => { + it('uninstall removes companies, contacts, articles and the app', () => { expect(uninstall.status, JSON.stringify(uninstall.body)).toBe(200); expect(after.company.status, JSON.stringify(after.company.body)).toBe(404); expect(after.contact.status, JSON.stringify(after.contact.body)).toBe(404); + expect(after.article.status, JSON.stringify(after.article.body)).toBe(404); expect(after.app.status, JSON.stringify(after.app.body)).toBe(404); }); diff --git a/examples/app-starter/test/help-articles-38372.test.ts b/examples/app-starter/test/help-articles-38372.test.ts new file mode 100644 index 00000000000..3d38089aec8 --- /dev/null +++ b/examples/app-starter/test/help-articles-38372.test.ts @@ -0,0 +1,111 @@ +// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. + +/** + * The seed help articles hold one Markdown shape, so each section reads on + * its own: the body opens with `# TITLE` (the record's own title), then 3 to 6 + * `##` sections, every section with text under its heading and, heading + * included, under 800 characters. One reference article carries a table + * followed by a one-line note, and one article is left a draft. + * + * Read off the seed definition itself, the rows the install door inserts. The + * blank template in create-objectstack carries the same seed; its parity test + * holds the two equal, so this shape holds there too. + */ + +import { describe, it, expect } from 'vitest'; +import { articles } from '../src/data/articles.js'; + +interface SeedArticle { title: string; body: string; category: string; status: string } + +const SECTION_LIMIT = 800; + +/** The body's `##` sections: each heading line with the text under it. */ +function sections(body: string): { heading: string; text: string; raw: string }[] { + const lines = body.split('\n'); + const out: { heading: string; text: string; raw: string }[] = []; + for (const line of lines) { + if (line.startsWith('## ')) out.push({ heading: line, text: '', raw: line }); + else if (out.length > 0) { + const last = out[out.length - 1]; + last.text += `${line}\n`; + last.raw += `\n${line}`; + } + } + return out.map((s) => ({ ...s, text: s.text.trim(), raw: s.raw.trimEnd() })); +} + +/** Every way an article breaks the shape, as readable sentences; empty when it holds. */ +function shapeProblems(article: SeedArticle): string[] { + const problems: string[] = []; + const lines = article.body.split('\n'); + if (lines[0] !== `# ${article.title}`) problems.push(`first line is not "# ${article.title}"`); + const firstSection = lines.findIndex((l) => l.startsWith('## ')); + const preamble = lines.slice(1, firstSection < 0 ? lines.length : firstSection).join('\n').trim(); + if (preamble) problems.push('text stands between the title and the first section'); + if (lines.slice(1).some((l) => /^# /.test(l))) problems.push('a second "# " heading'); + const found = sections(article.body); + if (found.length < 3 || found.length > 6) problems.push(`${found.length} sections, not 3 to 6`); + for (const s of found) { + if (!s.text) problems.push(`"${s.heading}" has no text`); + if (s.raw.length >= SECTION_LIMIT) problems.push(`"${s.heading}" is ${s.raw.length} characters`); + } + return problems; +} + +/** A Markdown table (header, separator, rows) followed by exactly one line of text, ending the section. */ +function hasTableThenOneLineNote(text: string): boolean { + const lines = text.split('\n'); + const start = lines.findIndex((l) => l.startsWith('|')); + if (start < 0 || !/^\|(\s*-+\s*\|)+$/.test(lines[start + 1] ?? '')) return false; + let end = start; + while (lines[end + 1]?.startsWith('|')) end++; + if (end - start < 2) return false; + const after = lines.slice(end + 1).filter((l) => l.trim() !== ''); + return after.length === 1 && !after[0].startsWith('|'); +} + +const records = articles.records as SeedArticle[]; + +describe('seed help articles — one Markdown shape', () => { + it('reads the seed (vacuity guard): three to four articles, keyed by title', () => { + expect(articles.externalId).toBe('title'); + expect(records.length).toBeGreaterThanOrEqual(3); + expect(records.length).toBeLessThanOrEqual(4); + }); + + it.each(records.map((r) => [r.title, r] as const))('"%s" holds the shape', (_title, article) => { + expect(shapeProblems(article)).toEqual([]); + }); + + it('covers every category, and leaves exactly one article a draft', () => { + expect(new Set(records.map((r) => r.category))).toEqual(new Set(['how_to', 'faq', 'reference'])); + expect(records.filter((r) => r.status === 'draft')).toHaveLength(1); + expect(records.filter((r) => r.status === 'published').length).toBe(records.length - 1); + }); + + it('a reference article carries a table followed by a one-line note', () => { + const withTable = records + .filter((r) => r.category === 'reference') + .filter((r) => sections(r.body).some((s) => hasTableThenOneLineNote(s.text))); + expect(withTable.map((r) => r.title)).toHaveLength(1); + }); + + it('CONTROL: each break of the shape is caught', () => { + const good = records.find((r) => r.category === 'faq')!; + expect(shapeProblems(good)).toEqual([]); + const firstSection = good.body.indexOf('\n## '); + const cases: Record = { + 'wrong title': good.body.replace(`# ${good.title}`, '# Something else'), + 'empty section': good.body.replace('\n## ', '\n## A heading alone\n\n## '), + 'long section': `${good.body}\n\n## Long\n\n${'x'.repeat(SECTION_LIMIT)}`, + 'too few sections': good.body.slice(0, good.body.indexOf('\n## ', firstSection + 1)), + 'text before the first section': good.body.replace(`# ${good.title}\n`, `# ${good.title}\n\nIntro.\n`), + }; + for (const [name, body] of Object.entries(cases)) { + expect(shapeProblems({ ...good, body }), name).not.toEqual([]); + } + expect(hasTableThenOneLineNote('| a | b |\n| --- | --- |\n| 1 | 2 |\n\nOne note.')).toBe(true); + expect(hasTableThenOneLineNote('| a | b |\n| --- | --- |\n| 1 | 2 |\n\nOne note.\n\nA second.')).toBe(false); + expect(hasTableThenOneLineNote('| a | b |\n| --- | --- |\n| 1 | 2 |')).toBe(false); + }); +}); diff --git a/packages/create-objectstack/src/blank-template-starter-parity.test.ts b/packages/create-objectstack/src/blank-template-starter-parity.test.ts index c029449c6b3..d5e34f4e250 100644 --- a/packages/create-objectstack/src/blank-template-starter-parity.test.ts +++ b/packages/create-objectstack/src/blank-template-starter-parity.test.ts @@ -1,9 +1,10 @@ // Copyright (c) 2026 ObjectStack contributors. Apache-2.0 license. // -// The blank template's companies and contacts ARE the platform's Starter app -// (`examples/app-starter`), as source a new project owns. The two must never -// drift: a project scaffolded today and an environment that installed the -// Starter hold the same objects, the same views and the same menu entries. +// The blank template's companies, contacts and help articles ARE the +// platform's Starter app (`examples/app-starter`), as source a new project +// owns. The two must never drift: a project scaffolded today and an +// environment that installed the Starter hold the same objects, the same +// views, the same menu entries and the same sample articles. // // ## Why a pin, and not a copy at build time // @@ -28,13 +29,15 @@ // newcomer reading their own project (what the org-wide default means, how to // remove the objects); the Starter's for a package author. Both files are // parsed with the TypeScript compiler and the definition (the argument of -// `ObjectSchema.create` / `defineView`, each menu entry) is printed without -// comments, so formatting and commentary are free and every key and value is -// held. +// `ObjectSchema.create` / `defineView`, each menu entry, the whole +// `defineSeed(Article, …)` call) is printed without comments, so formatting +// and commentary are free and every key and value is held. // // The template's menu is the Starter's object entries — companies, contacts, -// and the platform's tasks and notes — without the Starter's dashboard entry: -// the template ships no dashboard. +// articles, and the platform's tasks and notes — without the Starter's +// dashboard entry: the template ships no dashboard. Of the Starter's seed the +// template carries only the help articles: its companies and contacts start +// empty. import { describe, it, expect } from 'vitest'; import fs from 'node:fs'; @@ -107,14 +110,28 @@ function navigation(file: string, rename: boolean): { type: string | undefined; }); } +// Object pairs in file-name order: the object-file guard below compares them +// with the directory listing. const PAIRS = [ + { what: 'article object', file: 'objects/article.object.ts', callee: 'ObjectSchema.create' }, { what: 'company object', file: 'objects/company.object.ts', callee: 'ObjectSchema.create' }, { what: 'contact object', file: 'objects/contact.object.ts', callee: 'ObjectSchema.create' }, { what: 'company views', file: 'views/company.view.ts', callee: 'defineView' }, { what: 'contact views', file: 'views/contact.view.ts', callee: 'defineView' }, + { what: 'article views', file: 'views/article.view.ts', callee: 'defineView' }, ]; -describe('blank template — the Starter app\'s companies and contacts, as source', () => { +/** The printed `defineSeed(, …)` calls of the file — the whole call, records included. */ +function seeds(file: string, seeded: string, rename: boolean): string[] { + const sf = parse(file, rename); + return findAll( + sf, + (n): n is ts.CallExpression => + ts.isCallExpression(n) && n.expression.getText(sf) === 'defineSeed' && n.arguments[0]?.getText(sf) === seeded, + ).map((call) => print(call, sf)); +} + +describe('blank template — the Starter app\'s companies, contacts and articles, as source', () => { it('reads two real namespaces (vacuity guard)', () => { expect(BLANK_NAMESPACE).toBe('blank'); expect(STARTER_NAMESPACE).toBe('biz'); @@ -149,17 +166,42 @@ describe('blank template — the Starter app\'s companies and contacts, as sourc expect(objectFiles(BLANK_SRC)).toEqual(PAIRS.filter((p) => p.callee === 'ObjectSchema.create').map((p) => path.basename(p.file))); }); - it('the menu is the Starter\'s four object entries: companies, contacts, and the platform\'s tasks and notes', () => { + it('the sample help articles are the Starter\'s seed, modulo the namespace', () => { + const starter = seeds(path.join(STARTER_SRC, 'data', 'articles.ts'), 'Article', true); + const template = seeds(path.join(BLANK_SRC, 'data', 'articles.ts'), 'Article', false); + // Vacuity guard: one seed found on each side, carrying records. + expect(starter).toHaveLength(1); + expect(starter[0]).toMatch(/records: \[/); + expect(template).toEqual(starter); + }); + + it('CONTROL: a one-word change in a template article is caught', () => { + const file = path.join(BLANK_SRC, 'data', 'articles.ts'); + const sf = ts.createSourceFile( + file, + fs.readFileSync(file, 'utf8').replace('Plug the laptop into power', 'Plug the laptop into a socket'), + ts.ScriptTarget.Latest, + true, + ts.ScriptKind.TS, + ); + const mutated = findAll(sf, (n): n is ts.CallExpression => ts.isCallExpression(n) && n.expression.getText(sf) === 'defineSeed') + .map((call) => print(call, sf)); + expect(mutated).toHaveLength(1); + expect(mutated).not.toEqual(seeds(path.join(STARTER_SRC, 'data', 'articles.ts'), 'Article', true)); + }); + + it('the menu is the Starter\'s five object entries: companies, contacts, articles, and the platform\'s tasks and notes', () => { const starter = navigation(path.join(STARTER_SRC, 'apps', 'starter.app.ts'), true); const template = navigation(path.join(BLANK_SRC, 'apps', 'main.app.ts'), false); const starterObjects = starter.filter((e) => e.type === 'object'); // The Starter also carries a dashboard entry, which the template does not ship. expect(starter.length).toBeGreaterThan(starterObjects.length); - expect(starterObjects).toHaveLength(4); + expect(starterObjects).toHaveLength(5); expect(template.map((e) => e.text)).toEqual(starterObjects.map((e) => e.text)); + expect(template[2].text).toMatch(/objectName: 'blank_article'/); // The last two are the platform's own objects, gated as such. - expect(template[2].text).toMatch(/objectName: 'sys_task', requiresObject: 'sys_task'/); - expect(template[3].text).toMatch(/objectName: 'sys_note', requiresObject: 'sys_note'/); + expect(template[3].text).toMatch(/objectName: 'sys_task', requiresObject: 'sys_task'/); + expect(template[4].text).toMatch(/objectName: 'sys_note', requiresObject: 'sys_note'/); }); it('the scaffolder\'s closing summary names what the project starts with', () => { From 13aa4cfdee366f3b5366f1d25fb117be46076314 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 28 Nov 2026 23:30:57 +0000 Subject: [PATCH 05/10] chore(changeset): help articles in the Starter and the blank template Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01FEkQ5oQLfL8thb6wtUHnTb --- .changeset/38372-starter-help-articles.md | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 .changeset/38372-starter-help-articles.md diff --git a/.changeset/38372-starter-help-articles.md b/.changeset/38372-starter-help-articles.md new file mode 100644 index 00000000000..3ed1e705685 --- /dev/null +++ b/.changeset/38372-starter-help-articles.md @@ -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, `_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, English and Simplified Chinese labels, 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. A new project also gains `src/data/` (the sample rows, seeded on each boot), `src/translations/` and an `i18n` block in `objectstack.config.ts` listing `en` and `zh-CN`. Neither app declares a knowledge source. From 01ecc6bd9344fd446f255869932117ba5ad035e3 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 28 Nov 2026 23:39:40 +0000 Subject: [PATCH 06/10] test(example-starter): read the seed records as strings Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01FEkQ5oQLfL8thb6wtUHnTb --- examples/app-starter/test/help-articles-38372.test.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/examples/app-starter/test/help-articles-38372.test.ts b/examples/app-starter/test/help-articles-38372.test.ts index 3d38089aec8..e4dcc9d9de2 100644 --- a/examples/app-starter/test/help-articles-38372.test.ts +++ b/examples/app-starter/test/help-articles-38372.test.ts @@ -64,7 +64,12 @@ function hasTableThenOneLineNote(text: string): boolean { return after.length === 1 && !after[0].startsWith('|'); } -const records = articles.records as SeedArticle[]; +const records: SeedArticle[] = articles.records.map((r) => ({ + title: String(r.title), + body: String(r.body), + category: String(r.category), + status: String(r.status), +})); describe('seed help articles — one Markdown shape', () => { it('reads the seed (vacuity guard): three to four articles, keyed by title', () => { From 3309ce173029fc8d8f86eb3b6cfd1413339cba96 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 28 Nov 2026 23:41:02 +0000 Subject: [PATCH 07/10] docs(create-objectstack): the scaffolded AGENTS.md names src/data and src/translations The blank template's config now imports both barrels, and the Project Structure tree is held to exactly the directories the config loads. Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01FEkQ5oQLfL8thb6wtUHnTb --- packages/create-objectstack/src/templates/AGENTS.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/create-objectstack/src/templates/AGENTS.md b/packages/create-objectstack/src/templates/AGENTS.md index 4e5dfe3ed07..d4b24e3a541 100644 --- a/packages/create-objectstack/src/templates/AGENTS.md +++ b/packages/create-objectstack/src/templates/AGENTS.md @@ -74,7 +74,9 @@ Run `{{PM}} run build` when you need the compiled `dist/objectstack.json` artifa │ ├── skills/ # AI skills │ ├── picklists/ # Shared option sets that select fields reuse │ ├── security/ # Permission sets (what signed-in users may do) -│ └── datasets/ # Analytics datasets that dashboard widgets bind to +│ ├── datasets/ # Analytics datasets that dashboard widgets bind to +│ ├── data/ # Sample rows (seeds), inserted on boot when missing +│ └── translations/ # Labels per locale (the config's i18n block) ``` These are exactly the directories `objectstack.config.ts` wires. A new directory From 750964744f2714ed74fcbda72001ecb334c76c7e Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 29 Nov 2026 01:35:21 +0000 Subject: [PATCH 08/10] fix(create-objectstack): list the blank template's seed and labels by name The template's barrel imports stay exactly the ones `os init` wires (one per generator directory); the sample rows and the translation bundle are not generator output, so the config lists them by name, as the Starter does. The scaffolded AGENTS.md tree goes back to the generator directories, and the CLI wiring pin's views vacuity guard names the article view line. Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01FEkQ5oQLfL8thb6wtUHnTb --- .../test/create-objectstack-wiring-parity.test.ts | 1 + packages/create-objectstack/src/templates/AGENTS.md | 4 +--- .../create-objectstack/src/templates/blank/README.md | 9 ++++++--- .../src/templates/blank/objectstack.config.ts | 12 ++++++++---- .../src/templates/blank/src/data/articles.ts | 5 +++-- .../src/templates/blank/src/data/index.ts | 6 +++--- .../src/templates/blank/src/translations/index.ts | 4 ++-- 7 files changed, 24 insertions(+), 17 deletions(-) diff --git a/packages/cli/test/create-objectstack-wiring-parity.test.ts b/packages/cli/test/create-objectstack-wiring-parity.test.ts index 5009d65313e..64a2cd2d88a 100644 --- a/packages/cli/test/create-objectstack-wiring-parity.test.ts +++ b/packages/cli/test/create-objectstack-wiring-parity.test.ts @@ -172,6 +172,7 @@ describe('[#20333] the blank template ships every wired barrel', () => { }; expect(appendedTo('src/apps/index.ts')).toEqual(["export { default as main } from './main.app';"]); expect(appendedTo('src/views/index.ts')).toEqual([ + "export { default as article } from './article.view';", "export { default as company } from './company.view';", "export { default as contact } from './contact.view';", ]); diff --git a/packages/create-objectstack/src/templates/AGENTS.md b/packages/create-objectstack/src/templates/AGENTS.md index d4b24e3a541..4e5dfe3ed07 100644 --- a/packages/create-objectstack/src/templates/AGENTS.md +++ b/packages/create-objectstack/src/templates/AGENTS.md @@ -74,9 +74,7 @@ Run `{{PM}} run build` when you need the compiled `dist/objectstack.json` artifa │ ├── skills/ # AI skills │ ├── picklists/ # Shared option sets that select fields reuse │ ├── security/ # Permission sets (what signed-in users may do) -│ ├── datasets/ # Analytics datasets that dashboard widgets bind to -│ ├── data/ # Sample rows (seeds), inserted on boot when missing -│ └── translations/ # Labels per locale (the config's i18n block) +│ └── datasets/ # Analytics datasets that dashboard widgets bind to ``` These are exactly the directories `objectstack.config.ts` wires. A new directory diff --git a/packages/create-objectstack/src/templates/blank/README.md b/packages/create-objectstack/src/templates/blank/README.md index 6cfc8bf2fb0..c165f6302be 100644 --- a/packages/create-objectstack/src/templates/blank/README.md +++ b/packages/create-objectstack/src/templates/blank/README.md @@ -55,8 +55,9 @@ a note never changes who may see the record it is about. Change any of it freely: rename a field, add one, or replace both objects with your own. To remove companies and contacts entirely (help articles go the same -way: their object, view, menu entry, `src/data/articles.ts` and the -`src/translations/` entries): +way: their object, view, menu entry, `src/data/articles.ts`, the +`src/translations/` entries, and their `data` and `translations` lines in +`objectstack.config.ts`): 1. Delete `src/objects/company.object.ts` and `src/objects/contact.object.ts` and their export lines in `src/objects/index.ts`. @@ -116,7 +117,9 @@ for OAuth, API keys, and which objects/actions become tools. [The Console](#the-console); `src/views/` — the companies', contacts' and articles' list views - `src/data/` — sample rows, seeded on each boot; `src/translations/` — labels - in the locales the config's `i18n` block lists + in the locales the config's `i18n` block lists. `objectstack generate` writes + into neither, so the config lists each seed and bundle by name (`data`, + `translations`): list a new one there too - `src/actions/`, `src/flows/`, `src/dashboards/`, `src/skills/`, `src/picklists/`, `src/security/` (permission sets), `src/datasets/` (analytics datasets) — empty to start. Each directory's `index.ts` diff --git a/packages/create-objectstack/src/templates/blank/objectstack.config.ts b/packages/create-objectstack/src/templates/blank/objectstack.config.ts index fe03c0b27c9..3325e1a5645 100644 --- a/packages/create-objectstack/src/templates/blank/objectstack.config.ts +++ b/packages/create-objectstack/src/templates/blank/objectstack.config.ts @@ -9,8 +9,8 @@ import * as skills from './src/skills'; import * as picklists from './src/picklists'; import * as permissions from './src/security'; import * as datasets from './src/datasets'; -import * as data from './src/data'; -import * as translations from './src/translations'; +import { articles } from './src/data'; +import { MainTranslationBundle } from './src/translations'; // Every value a barrel exports, as the list a stack key takes: typed by what // the barrel exports, and an empty list while it exports nothing yet. @@ -84,9 +84,13 @@ export default defineStack({ permissions: exportsOf(permissions), datasets: exportsOf(datasets), + // The sample rows and the labels are listed by name, not wired as a + // directory: `objectstack generate` writes neither, so a seed or a + // translation bundle you add is loaded once you list it here too. + // // Sample rows (src/data/): each boot inserts a row that is missing and // leaves one that exists as it is. - data: exportsOf(data), + data: [articles], // Labels in each locale the app supports (src/translations/). A user sees // their own locale, and English where a label has no translation. @@ -95,5 +99,5 @@ export default defineStack({ supportedLocales: ['en', 'zh-CN'], fallbackLocale: 'en', }, - translations: exportsOf(translations), + translations: [MainTranslationBundle], }); diff --git a/packages/create-objectstack/src/templates/blank/src/data/articles.ts b/packages/create-objectstack/src/templates/blank/src/data/articles.ts index f9f2108e3ff..daa670cccb9 100644 --- a/packages/create-objectstack/src/templates/blank/src/data/articles.ts +++ b/packages/create-objectstack/src/templates/blank/src/data/articles.ts @@ -3,8 +3,9 @@ // Sample help articles, so the Articles list has something to show on first // open: the same articles as the platform's Starter app. Business data: no // `mode`, so each boot inserts an article that is missing and leaves one that -// exists as you left it. Delete the rows, or this file and its export line in -// `src/data/index.ts`, when they are no longer wanted. +// exists as you left it. Delete the rows, or this file, its export line in +// `src/data/index.ts` and its entry in `data` in objectstack.config.ts, when +// they are no longer wanted. // // Each `body` is Markdown in one shape: the article's title as a `#` heading, // then one `##` section per topic, each with its own text and short enough to diff --git a/packages/create-objectstack/src/templates/blank/src/data/index.ts b/packages/create-objectstack/src/templates/blank/src/data/index.ts index ff90ed0dd8e..779f8adc494 100644 --- a/packages/create-objectstack/src/templates/blank/src/data/index.ts +++ b/packages/create-objectstack/src/templates/blank/src/data/index.ts @@ -1,5 +1,5 @@ // The sample data in this directory, as seeds: each names the object it fills -// and the field that identifies a row. objectstack.config.ts hands every -// export of this file to the stack's `data`, and each boot inserts a row that -// is missing and leaves one that exists as it is. +// and the field that identifies a row. objectstack.config.ts lists each seed +// by name in the stack's `data`, and each boot inserts a row that is missing +// and leaves one that exists as it is. export { articles } from './articles.js'; diff --git a/packages/create-objectstack/src/templates/blank/src/translations/index.ts b/packages/create-objectstack/src/templates/blank/src/translations/index.ts index 248471e1ed3..1c5a44955e6 100644 --- a/packages/create-objectstack/src/templates/blank/src/translations/index.ts +++ b/packages/create-objectstack/src/templates/blank/src/translations/index.ts @@ -1,4 +1,4 @@ -// The translation bundles in this directory. objectstack.config.ts hands every -// export of this file to the stack's `translations`, in the locales its `i18n` +// The translation bundles in this directory. objectstack.config.ts lists each +// bundle by name in the stack's `translations`, in the locales its `i18n` // block lists. export { MainTranslationBundle } from './main.translation.js'; From 55400478bc19912a1c680f22cc560574e0fe2af4 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 29 Nov 2026 01:55:49 +0000 Subject: [PATCH 09/10] test(cli): the on-ramp starter validates with its three objects plus the generated one Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01FEkQ5oQLfL8thb6wtUHnTb --- packages/cli/test/create-objectstack-stack-reach.test.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/cli/test/create-objectstack-stack-reach.test.ts b/packages/cli/test/create-objectstack-stack-reach.test.ts index f4da53d298d..3c41ca9c45d 100644 --- a/packages/cli/test/create-objectstack-stack-reach.test.ts +++ b/packages/cli/test/create-objectstack-stack-reach.test.ts @@ -168,8 +168,9 @@ describe('[#20333] `npm create objectstack` → `os g flow` → `os validate`', it('`os validate` exits 0 and counts the generated flow beside the control', () => { expect(validate.code, out(validate)).toBe(0); - // The starter's two objects (company, contact) plus the generated one. - expect(validate.stdout).toMatch(/\bData: 3 Objects\b/); + // The starter's three objects (article, company, contact) plus the + // generated one. + expect(validate.stdout).toMatch(/\bData: 4 Objects\b/); expect(validate.stdout).toMatch(/\bLogic: 1 Flows\b/); }); }); From 1db02279e136a77c658f3625667e771454e334c2 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 29 Nov 2026 02:19:33 +0000 Subject: [PATCH 10/10] fix(create-objectstack): the blank template carries no translation bundle The blank template ships the article object, view, menu entry and seed; its labels are the English ones in its source, as for the companies and contacts. A zh-CN half translated next to an untranslated rest gives a fresh project i18n findings on `objectstack lint`. Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01FEkQ5oQLfL8thb6wtUHnTb --- .changeset/38372-starter-help-articles.md | 2 +- .../src/templates/blank/README.md | 15 ++--- .../src/templates/blank/objectstack.config.ts | 16 +---- .../templates/blank/src/translations/index.ts | 4 -- .../src/translations/main.translation.ts | 67 ------------------- 5 files changed, 10 insertions(+), 94 deletions(-) delete mode 100644 packages/create-objectstack/src/templates/blank/src/translations/index.ts delete mode 100644 packages/create-objectstack/src/templates/blank/src/translations/main.translation.ts diff --git a/.changeset/38372-starter-help-articles.md b/.changeset/38372-starter-help-articles.md index 3ed1e705685..87ebf5c5688 100644 --- a/.changeset/38372-starter-help-articles.md +++ b/.changeset/38372-starter-help-articles.md @@ -8,4 +8,4 @@ feat(example-starter, create-objectstack): help articles in the Starter app and 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, `_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, English and Simplified Chinese labels, 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. A new project also gains `src/data/` (the sample rows, seeded on each boot), `src/translations/` and an `i18n` block in `objectstack.config.ts` listing `en` and `zh-CN`. Neither app declares a knowledge source. +The Starter app and the project `npm create objectstack` scaffolds now start with help articles: an Article object (`biz_article` in the Starter, `_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. diff --git a/packages/create-objectstack/src/templates/blank/README.md b/packages/create-objectstack/src/templates/blank/README.md index c165f6302be..d96e9e510f8 100644 --- a/packages/create-objectstack/src/templates/blank/README.md +++ b/packages/create-objectstack/src/templates/blank/README.md @@ -40,8 +40,7 @@ as source you own: is not a user and never signs in. - `src/objects/article.object.ts` — **Article**: a help article (a how-to, a common question or a reference page) with a Markdown body, a category and a - status; `src/data/articles.ts` seeds four sample articles, one a draft, and - `src/translations/` labels them in English and Simplified Chinese. + status; `src/data/articles.ts` seeds four sample articles, one a draft. - `src/views/company.view.ts`, `src/views/contact.view.ts` — a grid of every record and a board (companies by type, contacts by influence); `src/views/article.view.ts` — a grid of every article. @@ -55,9 +54,8 @@ a note never changes who may see the record it is about. Change any of it freely: rename a field, add one, or replace both objects with your own. To remove companies and contacts entirely (help articles go the same -way: their object, view, menu entry, `src/data/articles.ts`, the -`src/translations/` entries, and their `data` and `translations` lines in -`objectstack.config.ts`): +way: their object, view, menu entry, `src/data/articles.ts`, and its entry in +`data` in `objectstack.config.ts`): 1. Delete `src/objects/company.object.ts` and `src/objects/contact.object.ts` and their export lines in `src/objects/index.ts`. @@ -116,10 +114,9 @@ for OAuth, API keys, and which objects/actions become tools. - `src/apps/` — the app, `main.app.ts`, described in [The Console](#the-console); `src/views/` — the companies', contacts' and articles' list views -- `src/data/` — sample rows, seeded on each boot; `src/translations/` — labels - in the locales the config's `i18n` block lists. `objectstack generate` writes - into neither, so the config lists each seed and bundle by name (`data`, - `translations`): list a new one there too +- `src/data/` — sample rows, seeded on each boot. `objectstack generate` writes + no seed, so the config lists each one by name in `data`: list a new one there + too - `src/actions/`, `src/flows/`, `src/dashboards/`, `src/skills/`, `src/picklists/`, `src/security/` (permission sets), `src/datasets/` (analytics datasets) — empty to start. Each directory's `index.ts` diff --git a/packages/create-objectstack/src/templates/blank/objectstack.config.ts b/packages/create-objectstack/src/templates/blank/objectstack.config.ts index 3325e1a5645..1675497bb7c 100644 --- a/packages/create-objectstack/src/templates/blank/objectstack.config.ts +++ b/packages/create-objectstack/src/templates/blank/objectstack.config.ts @@ -10,7 +10,6 @@ import * as picklists from './src/picklists'; import * as permissions from './src/security'; import * as datasets from './src/datasets'; import { articles } from './src/data'; -import { MainTranslationBundle } from './src/translations'; // Every value a barrel exports, as the list a stack key takes: typed by what // the barrel exports, and an empty list while it exports nothing yet. @@ -84,20 +83,11 @@ export default defineStack({ permissions: exportsOf(permissions), datasets: exportsOf(datasets), - // The sample rows and the labels are listed by name, not wired as a - // directory: `objectstack generate` writes neither, so a seed or a - // translation bundle you add is loaded once you list it here too. + // The sample rows are listed by name, not wired as a directory: + // `objectstack generate` writes no seed, so a seed you add is loaded once + // you list it here too. // // Sample rows (src/data/): each boot inserts a row that is missing and // leaves one that exists as it is. data: [articles], - - // Labels in each locale the app supports (src/translations/). A user sees - // their own locale, and English where a label has no translation. - i18n: { - defaultLocale: 'en', - supportedLocales: ['en', 'zh-CN'], - fallbackLocale: 'en', - }, - translations: [MainTranslationBundle], }); diff --git a/packages/create-objectstack/src/templates/blank/src/translations/index.ts b/packages/create-objectstack/src/templates/blank/src/translations/index.ts deleted file mode 100644 index 1c5a44955e6..00000000000 --- a/packages/create-objectstack/src/templates/blank/src/translations/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -// The translation bundles in this directory. objectstack.config.ts lists each -// bundle by name in the stack's `translations`, in the locales its `i18n` -// block lists. -export { MainTranslationBundle } from './main.translation.js'; diff --git a/packages/create-objectstack/src/templates/blank/src/translations/main.translation.ts b/packages/create-objectstack/src/templates/blank/src/translations/main.translation.ts deleted file mode 100644 index 9fcbab595db..00000000000 --- a/packages/create-objectstack/src/templates/blank/src/translations/main.translation.ts +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. - -import { defineTranslationBundle } from '@objectstack/spec/system'; - -/** - * This project's labels in English and Simplified Chinese — today the help - * articles', the same text as the platform's Starter app. - * - * Object keys are quoted names, `'_'`, the way every name in - * `src/` is written, so they always name the object they translate. Add a - * locale by listing it in `i18n.supportedLocales` in objectstack.config.ts - * and adding its block here; `objectstack i18n check` lists the keys a locale - * is missing. - */ -export const MainTranslationBundle = defineTranslationBundle({ - en: { - objects: { - 'blank_article': { - label: 'Article', - pluralLabel: 'Articles', - fields: { - title: { label: 'Title' }, - body: { label: 'Body' }, - category: { label: 'Category' }, - status: { label: 'Status' }, - owner_id: { label: 'Owner' }, - }, - }, - }, - }, - - 'zh-CN': { - objects: { - 'blank_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: '文章' }, - }, - }, - }, - }, -});