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
15 changes: 15 additions & 0 deletions .changeset/setup-manual-wave-one.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
'@objectstack/setup': patch
'@objectstack/studio': patch
---

Clause-②: no
Metadata-protocol: none

The in-product help for administrators is corrected and extended.

- **Setup overview** no longer teaches roles and a role hierarchy. It says what the product does: positions hand out permission sets and are flat, and the one hierarchy is the business-unit tree.
- **App Studio overview** no longer says an edit is a draft only its author sees until it is published. A Save is live for everyone at once; only changes the AI assistant drafts wait, on the package Overview's Pending tab.
- Three pages join the Setup manual, read by whoever may open Setup: **Going live** (`setup_go_live`: the order to set an organization up in, why a new user sees almost nothing, what a pending invitation is, what a ban does), **Who can see and do what** (`setup_access`: how access adds up, object permission against record visibility against field security, and how to find out why a record cannot be seen or edited) and **Installing and upgrading apps** (`setup_install_upgrade`: what an install adds, what an update keeps and asks to confirm, why no earlier version can be put back, what uninstall leaves). Each page marks where editions differ.

Every page is served in English and Chinese. `@objectstack/setup` now also exports `SETUP_GO_LIVE_DOC`, `SETUP_ACCESS_DOC` and `SETUP_INSTALL_UPGRADE_DOC`.
11 changes: 8 additions & 3 deletions packages/apps/setup/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
import { SETUP_APP, SETUP_NAV_CONTRIBUTIONS } from '@objectstack/platform-objects/apps';

import { SETUP_OVERVIEW_DOC } from './setup-overview.doc.js';
import { SETUP_GO_LIVE_DOC } from './setup-go-live.doc.js';
import { SETUP_ACCESS_DOC } from './setup-access.doc.js';
import { SETUP_INSTALL_UPGRADE_DOC } from './setup-install-upgrade.doc.js';
import { SETUP_MANUAL_BOOK } from './setup-manual.book.js';

export const SETUP_APP_PACKAGE_ID = 'com.objectstack.setup';
Expand Down Expand Up @@ -59,8 +62,10 @@ export class SetupAppPlugin {
...setupAppManifestHeader,
apps: [SETUP_APP],
navigationContributions: SETUP_NAV_CONTRIBUTIONS,
// ADR-0046 package docs — grouped under "Setup" at /_console/docs.
docs: [SETUP_OVERVIEW_DOC],
// ADR-0046 package docs — grouped under "Setup" at /_console/docs: the
// overview, then the three administrator pages it links to. Each name
// carries the `setup_` prefix `SETUP_MANUAL_BOOK` claims its pages by.
docs: [SETUP_OVERVIEW_DOC, SETUP_GO_LIVE_DOC, SETUP_ACCESS_DOC, SETUP_INSTALL_UPGRADE_DOC],
// ADR-0046 §6.7 — the manual claiming those docs, read only by the
// callers who may open the Setup app (its `audience`).
books: [SETUP_MANUAL_BOOK],
Expand All @@ -74,5 +79,5 @@ export function createSetupAppPlugin(): SetupAppPlugin {
}

export { SETUP_APP, SETUP_NAV_CONTRIBUTIONS };
export { SETUP_OVERVIEW_DOC };
export { SETUP_OVERVIEW_DOC, SETUP_GO_LIVE_DOC, SETUP_ACCESS_DOC, SETUP_INSTALL_UPGRADE_DOC };
export { SETUP_MANUAL_BOOK };
190 changes: 188 additions & 2 deletions packages/apps/setup/src/manual-claims-docs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,27 @@

import { describe, expect, it } from 'vitest';
import { resolveDocAudiences, type AudienceBook, type ResolverDoc } from '@objectstack/spec/system';
import { createSetupAppPlugin, SETUP_APP_PACKAGE_ID, SETUP_MANUAL_BOOK } from './index.js';
import { en, zhCN, SETUP_NAV_CONTRIBUTIONS } from '@objectstack/platform-objects/apps';
import {
createSetupAppPlugin,
SETUP_ACCESS_DOC,
SETUP_APP_PACKAGE_ID,
SETUP_GO_LIVE_DOC,
SETUP_INSTALL_UPGRADE_DOC,
SETUP_MANUAL_BOOK,
SETUP_OVERVIEW_DOC,
} from './index.js';

interface RegisteredDoc {
name: string;
label?: string;
content: string;
translations?: Record<string, { label?: string; description?: string; content: string }>;
}

interface Registered {
id: string;
docs: Array<{ name: string; label?: string }>;
docs: RegisteredDoc[];
books: AudienceBook[];
}

Expand Down Expand Up @@ -56,3 +72,173 @@ describe('setup_manual claims every doc @objectstack/setup registers', () => {
expect(audiences.get('unbound_page'), 'the manual claims a doc bound to no package').toEqual(['org']);
});
});

/**
* The manual's pages name screens, buttons and lists, and a name the product
* does not show sends an administrator looking for a page that is not there.
* Each pin below reads the name from the declaration the screen is drawn from
* (the Setup app's navigation labels and the object labels, per language), so
* a renamed entry turns the page that still uses the old name red, and the
* zh page is held to the labels the zh screens show.
*
* What these cannot hold: the rules a page states about `ui/` (the marketplace
* and Studio screens) and about the security, sharing and approvals plugins.
* This package depends on none of them; each doc's header names the code its
* statements were read from.
*/

type Labelled = Record<string, { label?: string } | undefined>;
interface ObjectLabels {
fields?: Labelled;
_actions?: Labelled;
_views?: Labelled;
}
interface Bundle {
apps: { setup: { label: string; navigation: Labelled } };
objects: Record<string, ObjectLabels | undefined>;
}

const BUNDLES: Record<'en' | 'zh', Bundle> = {
en: en as unknown as Bundle,
zh: zhCN as unknown as Bundle,
};

/** A page's body in one language: the base is English, `translations.zh` the Chinese. */
function body(doc: RegisteredDoc, locale: 'en' | 'zh'): string {
const text = locale === 'en' ? doc.content : doc.translations?.zh?.content;
expect(text, `${doc.name} has no ${locale} body`).toBeTruthy();
return text!;
}

/** Every bold span of a page, with a span wrapped over two lines read as one. */
function boldSpans(markdown: string): string[] {
return [...markdown.matchAll(/\*\*([^*]+)\*\*/g)].map((m) => m[1]!.replace(/\s*\n\s*/g, ' ').trim());
}

/** The navigation id carrying `label` under `prefix`, in one language's bundle. */
function navIdOf(bundle: Bundle, prefix: 'group_' | 'nav_', label: string): string | undefined {
return Object.entries(bundle.apps.setup.navigation).find(([id, node]) => id.startsWith(prefix) && node?.label === label)?.[0];
}

/**
* The menu paths a page names, as `[group id, entry id]`: every bold span that
* opens with the Setup app's own name in that language and an arrow.
*/
function menuPaths(doc: RegisteredDoc, locale: 'en' | 'zh'): Array<[string, string]> {
const bundle = BUNDLES[locale];
const app = bundle.apps.setup.label;
return boldSpans(body(doc, locale))
.filter((span) => span.startsWith(`${app} → `))
.map((span) => {
const parts = span.split(' → ');
expect(parts, `${doc.name} (${locale}): "${span}" is not app → group → entry`).toHaveLength(3);
const group = navIdOf(bundle, 'group_', parts[1]!);
const entry = navIdOf(bundle, 'nav_', parts[2]!);
expect(group, `${doc.name} (${locale}): Setup has no group labelled "${parts[1]}"`).toBeDefined();
expect(entry, `${doc.name} (${locale}): Setup has no entry labelled "${parts[2]}"`).toBeDefined();
return [group!, entry!];
});
}

/** The group each entry this package's own contributions declare sits in. */
const DECLARED_GROUP = new Map<string, string>(
SETUP_NAV_CONTRIBUTIONS.flatMap((c) => (c.items ?? []).map((item): [string, string] => [String(item.id), c.group ?? ''])),
);

describe('the Setup manual names the menu by the labels Setup shows', () => {
it('every menu path of every page is a group and an entry of the Setup app, in English and in Chinese', async () => {
const m = await registeredManifest();
let named = 0;
for (const doc of m.docs) {
const enPaths = menuPaths(doc, 'en');
const zhPaths = menuPaths(doc, 'zh');
// The Chinese page sends the reader to the same screens, in the same order.
expect(zhPaths, `${doc.name}: the zh page names other menu paths than the English one`).toEqual(enPaths);
for (const [group, entry] of enPaths) {
// An entry another package contributes is held to its label alone.
const declared = DECLARED_GROUP.get(entry);
if (declared !== undefined) expect(declared, `${doc.name}: ${entry} is not under ${group}`).toBe(group);
}
named += enPaths.length;
}
expect(named, 'a manual naming no menu path pins nothing').toBeGreaterThan(0);
});

it('the three administrator pages each name at least one menu path', () => {
for (const doc of [SETUP_GO_LIVE_DOC, SETUP_ACCESS_DOC, SETUP_INSTALL_UPGRADE_DOC] as RegisteredDoc[]) {
expect(menuPaths(doc, 'en').length, `${doc.name} names no menu path`).toBeGreaterThan(0);
}
});

it('a link from one page to another names a page this package registers', async () => {
const m = await registeredManifest();
const names = new Set(m.docs.map((d) => d.name));
let links = 0;
for (const doc of m.docs) {
for (const locale of ['en', 'zh'] as const) {
// The console's rule (`doc-links.ts`): `./<name>.md` opens the doc `<name>`.
for (const [, target] of body(doc, locale).matchAll(/\]\((?:\.\/)?([a-z][a-z0-9_]*)\.md(?:#[^)\s]*)?\)/g)) {
expect(names.has(target!), `${doc.name} (${locale}) links to ${target}, which is not registered`).toBe(true);
links += 1;
}
}
}
expect(links, 'the overview links to the three pages').toBeGreaterThan(0);
});
});

describe('the going-live page names actions and lists by the labels their screens show', () => {
const ACTIONS: Array<[object: string, action: string]> = [
['sys_user', 'create_user'],
['sys_user', 'ban_user'],
['sys_user', 'unban_user'],
['sys_invitation', 'invite_user'],
['sys_invitation', 'resend_invitation'],
['sys_invitation', 'copy_invitation_link'],
];

it.each(['en', 'zh'] as const)('%s: each action, the Pending list and the Role field carry the bundle label', (locale) => {
const objects = BUNDLES[locale].objects;
const spans = new Set(boldSpans(body(SETUP_GO_LIVE_DOC as RegisteredDoc, locale)));
const expected: Array<[what: string, label: string | undefined]> = [
...ACTIONS.map(([object, action]): [string, string | undefined] => [
`${object}.${action}`,
objects[object]?._actions?.[action]?.label,
]),
['sys_invitation list view pending', objects.sys_invitation?._views?.pending?.label],
['sys_invitation.role', objects.sys_invitation?.fields?.role?.label],
];
for (const [what, label] of expected) {
expect(label, `${locale}: the bundle carries no label for ${what}`).toBeTruthy();
expect(spans.has(label!), `${locale}: the page does not name ${what} as "${label}"`).toBe(true);
}
});
});

describe('the Setup manual keeps to the platform vocabulary', () => {
it('no page teaches a role hierarchy, and the overview names positions and business units', async () => {
const m = await registeredManifest();
for (const doc of m.docs) {
expect(body(doc, 'en')).not.toMatch(/role hierarchy/i);
expect(body(doc, 'zh')).not.toMatch(/角色层级/);
}
const overview = SETUP_OVERVIEW_DOC as RegisteredDoc;
// The one place the word stays is the invitation's membership Role field, on the going-live page.
expect(body(overview, 'en')).not.toMatch(/\broles?\b/i);
expect(body(overview, 'zh')).not.toMatch(/角色/);
expect(body(overview, 'en')).toMatch(/positions/);
expect(body(overview, 'en')).toMatch(/business-unit tree/);
expect(body(overview, 'zh')).toMatch(/岗位/);
expect(body(overview, 'zh')).toMatch(/业务单元/);
});

it('every page carries a zh label, description and body', async () => {
const m = await registeredManifest();
for (const doc of m.docs) {
const zh = doc.translations?.zh;
expect(zh?.label, `${doc.name} has no zh label`).toBeTruthy();
expect(zh?.description, `${doc.name} has no zh description`).toBeTruthy();
expect(zh?.content, `${doc.name} has no zh body`).toBeTruthy();
}
});
});
146 changes: 146 additions & 0 deletions packages/apps/setup/src/setup-access.doc.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.

import type { Doc } from '@objectstack/spec/system';

/**
* Setup manual, "Who can see and do what" (ADR-0046): how access adds up,
* object permission against record visibility against field security, and
* how to find out why someone cannot see or edit a record.
*
* Same authoring rule as `setup-overview.doc.ts`. Read off: the grant
* resolver (`resolveUserAuthzGrants`, `@objectstack/core`), the explain
* engine and field masking in `@objectstack/plugin-security`, the sharing
* rule's access levels in `@objectstack/plugin-sharing`, the pending-approval
* lock in `@objectstack/plugin-approvals`, and the closed-state lock in
* `@objectstack/objectql`. `manual-claims-docs.test.ts` pins the menu paths.
*/
export const SETUP_ACCESS_DOC: Doc = {
name: 'setup_access',
label: 'Who can see and do what',
description:
'How access adds up, the difference between object permission and record visibility, and how to find out why someone cannot see or edit a record.',
order: 2,
content: `# Who can see and do what

> **Editions.** Letting a permission set reach records by business unit (read
> scope "unit" and the other hierarchy scopes) needs the enterprise edition. On
> the open edition, business units still decide who a sharing rule reaches.
> Everything else on this page is the same on every edition.

## Access adds up

A person's access is the union of three sources:

- the permission sets handed out by each **position** they hold
(**Setup → Access & Sharing → Position Holders**);
- the permission sets granted to them directly
(**Setup → Access & Sharing → Permission Set Assignment**);
- the baseline permission sets every signed-in member gets.

No permission set takes access away. To restrict someone, do not grant.
A position has no access of its own: it only names the permission sets its
holders receive. A position or permission set that is switched off grants
nothing.

## Three separate questions

**1. May this person use this object at all?** Create, read, edit and delete
on an object come from a permission set.

**2. Which records of it do they reach?** That starts from the object's
**Who can see which records** setting in App Studio: *Only the owner can see* (the
default), *Everyone can see*, *Everyone can see and edit*, or *Follows its
parent record*. From there access is only widened:

- **Sharing rules** and **record shares** (**Setup → Access & Sharing →
Sharing Rules** and **Record Shares**) give more people *read*, or *read and
edit*. They never give delete or change of owner.
- **View All** and **Modify All** on a permission set skip the ownership and
sharing checks for that object.

**3. Which fields do they read and edit?** A field hidden by field security is
removed from what the person is served, so it looks absent, not locked. Field
rules add up across a person's permission sets, and the most permissive one
wins. **View All** and **Modify All** reach every record but do not open a
hidden field.

## "I can't see it" or "I can't edit it"

**Ask the platform first.** **Explain access** runs the same evaluation the
platform enforces and reports what each step contributed: which permission set
granted, through which position, and which sharing rule widened. Give it a
record and it says whether that record is visible and which step decided.
It is in App Studio, on a permission set's page and on a package's **Who can see
which records** page; **Setup → Access & Sharing → Positions and Permissions**
opens permission sets there. Explaining another user needs the \`manage_users\`
capability, or a delegated administration scope that covers that user.

Then check the cases a permission cannot fix:

- **An approval is in progress.** An approval can lock the record it is
deciding. While it does, the record and the lines under it refuse edits
until the approval is complete.
- **The record is closed.** A record in one of its object's closed states is
final. It and its lines cannot be edited or deleted, and no permission opens
it.
- **A field is missing.** Field security hides it (question 3 above).
- **A new user sees almost nothing.** They hold no position yet.
- **Access disappeared after a move.** Access shared with a business unit
follows membership: a person who leaves the unit loses it.
`,
translations: {
zh: {
label: '谁能看到什么、做什么',
description:
'访问权限如何叠加,对象权限与记录可见性有何区别,以及如何查明某人为什么看不到或改不了某条记录。',
content: `# 谁能看到什么、做什么

> **版本说明。** 让权限集按业务单元读取记录(读取范围「unit」及其他层级范围)需要企业版。
> 在开源版中,业务单元仍然决定共享规则能覆盖到谁。
> 本页其余内容在所有版本中都一样。

## 访问权限是叠加的

一个人的访问权限是三个来源的并集:

- 他所担任的每个**岗位**所发放的权限集
(**系统设置 → 权限与共享 → 岗位成员**);
- 直接授予他的权限集
(**系统设置 → 权限与共享 → 权限集授权**);
- 每位已登录成员都有的基线权限集。

没有任何权限集会收回访问权限。要限制某人,就不要授予。
岗位本身没有任何访问权限:它只是列出其成员会获得的权限集。
已停用的岗位或权限集不授予任何权限。

## 三个相互独立的问题

**1. 这个人能不能使用这个对象?** 对象的创建、读取、编辑和删除权限来自权限集。

**2. 他能触及该对象的哪些记录?** 这从应用搭建中该对象的**谁能看到哪些记录**设置开始:*只有负责人能看*(默认)、*所有人能看*、*所有人都能看和改*,或*跟随所属的主记录*。
在此基础上,访问范围只会被放宽:

- **共享规则**和**共享明细**(**系统设置 → 权限与共享 → 共享规则**和**共享明细**)让更多人获得*读取*权限,或*读取和编辑*权限。它们从不授予删除或更改负责人的权限。
- 权限集上的**查看所有记录**和**修改所有记录**会跳过该对象的所有权检查和共享检查。

**3. 他能读取和编辑哪些字段?** 被字段安全隐藏的字段,会从提供给该用户的内容中移除,所以看起来是不存在,而不是被锁定。字段规则会在一个人的多个权限集之间叠加,取最宽松的一条。
**查看所有记录**和**修改所有记录**能触及每一条记录,但不会打开被隐藏的字段。

## 「我看不到」或「我改不了」

**先问平台。** **解释访问权限**会运行与平台实际执行完全相同的评估,并报告每一步的贡献:哪个权限集授予了权限,通过哪个岗位,哪条共享规则放宽了范围。
给它一条记录,它会告诉你这条记录是否可见,以及由哪一步决定。
它位于应用搭建中,在权限集的页面上,也在软件包的**谁能看到哪些记录**页面上;**系统设置 → 权限与共享 → 岗位与权限**会在那里打开权限集。
解释其他用户需要 \`manage_users\` 能力,或覆盖该用户的委托管理范围。

然后检查权限无法解决的情况:

- **审批正在进行。** 审批可以锁定它正在裁决的记录。在此期间,该记录及其下的明细行都拒绝编辑,直到审批完成。
- **记录已关闭。** 处于其对象的某个关闭状态的记录是最终状态。它和它的明细行不能被编辑或删除,任何权限都无法打开它。
- **字段缺失。** 字段安全把它隐藏了(见上面的问题 3)。
- **新用户几乎什么都看不到。** 他们还没有担任任何岗位。
- **调动后访问权限消失。** 共享给业务单元的访问权限跟随成员关系:离开该单元的人会失去它。
`,
},
},
};
Loading
Loading