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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .changeset/38371-starter-namespace-biz.md
Original file line number Diff line number Diff line change
@@ -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.
6 changes: 3 additions & 3 deletions examples/app-starter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.

Expand Down
4 changes: 2 additions & 2 deletions examples/app-starter/objectstack.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ 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.
*/
export default defineStack({
manifest: {
id: 'com.example.starter',
namespace: 'starter',
namespace: 'biz',
version: '0.1.0',
type: 'app',
name: 'Starter',
Expand Down
8 changes: 4 additions & 4 deletions examples/app-starter/src/apps/starter.app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,21 @@ 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: {
primaryColor: '#2563EB',
},

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' },
],
});
14 changes: 7 additions & 7 deletions examples/app-starter/src/dashboards/overview.dashboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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 },
},
Expand All @@ -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 },
},
Expand All @@ -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 },
},
Expand All @@ -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 },
Expand All @@ -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 },
Expand All @@ -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 },
Expand Down
4 changes: 2 additions & 2 deletions examples/app-starter/src/datasets/company.dataset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
{
Expand Down
4 changes: 2 additions & 2 deletions examples/app-starter/src/datasets/contact.dataset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
{
Expand Down
6 changes: 3 additions & 3 deletions examples/app-starter/src/objects/company.object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ 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.
*
* There is no owner field here: every package object gets the platform's
* `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.
Expand Down Expand Up @@ -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'] },
],
});
4 changes: 2 additions & 2 deletions examples/app-starter/src/objects/contact.object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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({
Expand Down
18 changes: 9 additions & 9 deletions examples/app-starter/src/translations/starter.translation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand All @@ -25,7 +25,7 @@ export const StarterTranslationBundle = defineTranslationBundle({
owner_id: { label: 'Owner' },
},
},
starter_contact: {
biz_contact: {
label: 'Contact',
pluralLabel: 'Contacts',
fields: {
Expand All @@ -41,7 +41,7 @@ export const StarterTranslationBundle = defineTranslationBundle({
},
},
apps: {
starter_app: {
biz_app: {
label: 'Starter',
description: 'Companies and contacts, with tasks and notes',
},
Expand All @@ -54,7 +54,7 @@ export const StarterTranslationBundle = defineTranslationBundle({
'com.example.starter': { name: '入门示例', description: '公司与联系人,菜单中附带平台的任务和备注。' },
},
objects: {
starter_company: {
biz_company: {
label: '公司',
pluralLabel: '公司',
description: '与本组织往来的公司。',
Expand Down Expand Up @@ -98,7 +98,7 @@ export const StarterTranslationBundle = defineTranslationBundle({
more: { label: '更多' },
},
},
starter_contact: {
biz_contact: {
label: '联系人',
pluralLabel: '联系人',
description: '往来公司里的人,不是本组织的员工。',
Expand Down Expand Up @@ -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: {
Expand All @@ -152,7 +152,7 @@ export const StarterTranslationBundle = defineTranslationBundle({
company_count: { label: '公司数', description: '公司有多少家,不论类型。' },
},
},
starter_contact_metrics: {
biz_contact_metrics: {
label: '联系人统计',
description: '联系人有多少位,按公司和影响力分',
dimensions: {
Expand All @@ -165,7 +165,7 @@ export const StarterTranslationBundle = defineTranslationBundle({
},
},
dashboards: {
starter_overview_dashboard: {
biz_overview_dashboard: {
label: '概览',
description: '公司和联系人一览。',
widgets: {
Expand Down
6 changes: 3 additions & 3 deletions examples/app-starter/src/views/company.view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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' },
Expand All @@ -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' },
Expand All @@ -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',
Expand Down
6 changes: 3 additions & 3 deletions examples/app-starter/src/views/contact.view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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' },
Expand All @@ -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' },
Expand All @@ -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',
Expand Down
16 changes: 8 additions & 8 deletions examples/app-starter/test/boot.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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', () => {
Expand Down
Loading
Loading