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. 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));