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
32 changes: 16 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,24 @@
"verify": "pnpm validate && pnpm typecheck && pnpm test"
},
"dependencies": {
"@objectstack/spec": "^18.3.0",
"@objectstack/runtime": "^18.3.0",
"@objectstack/plugin-hono-server": "^18.3.0",
"@objectstack/connector-rest": "^18.3.0",
"@objectstack/connector-openapi": "^18.3.0",
"@objectstack/connector-mcp": "^18.3.0"
"@objectstack/spec": "^18.6.0",
"@objectstack/runtime": "^18.6.0",
"@objectstack/plugin-hono-server": "^18.6.0",
"@objectstack/connector-rest": "^18.6.0",
"@objectstack/connector-openapi": "^18.6.0",
"@objectstack/connector-mcp": "^18.6.0"
},
"devDependencies": {
"@objectstack/cli": "^18.3.0",
"@objectstack/platform-objects": "^18.3.0",
"@objectstack/plugin-auth": "^18.3.0",
"@objectstack/plugin-email": "^18.3.0",
"@objectstack/plugin-security": "^18.3.0",
"@objectstack/plugin-sharing": "^18.3.0",
"@objectstack/service-automation": "^18.3.0",
"@objectstack/service-job": "^18.3.0",
"@objectstack/service-messaging": "^18.3.0",
"@objectstack/trigger-schedule": "^18.3.0",
"@objectstack/cli": "^18.6.0",
"@objectstack/platform-objects": "^18.6.0",
"@objectstack/plugin-auth": "^18.6.0",
"@objectstack/plugin-email": "^18.6.0",
"@objectstack/plugin-security": "^18.6.0",
"@objectstack/plugin-sharing": "^18.6.0",
"@objectstack/service-automation": "^18.6.0",
"@objectstack/service-job": "^18.6.0",
"@objectstack/service-messaging": "^18.6.0",
"@objectstack/trigger-schedule": "^18.6.0",
"typescript": "^6.0.0",
"vitest": "^4.1.10"
}
Expand Down
1,166 changes: 603 additions & 563 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

20 changes: 19 additions & 1 deletion src/objects/duty.object.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.

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

/**
* `duly_duty` — the STANDING DEFINITION of a piece of work someone owes.
Expand Down Expand Up @@ -104,6 +104,24 @@ export const Duty = ObjectSchema.create({
description: 'Exactly one accountable person. Work owed by "the team" is owed by nobody.',
}),

// The platform's own owner column, declared here to hide it and name it
// apart. The platform injects `owner_id` on every user-owned object,
// labelled "Owner" (负责人 to a zh-CN reader), so a record page showed two
// "Owner"s naming two different people: Duly's `owner` above, and
// `owner_id`, which is whoever created the row — the dispatcher, the seed
// or an administrator (#143). From @objectstack 18.5 that is the
// author-time error `field-label-duplicate`. `owner` is the one a reader
// means. Only the label, the help and the visibility change: the type, the
// reference and every job the column does (the insert stamp, `own` read
// scope) stay the platform's.
owner_id: {
...OWNER_FIELD_DEF,
label: 'Record owner',
description: 'Who created this row: the platform\'s record owner, which drives owner-scoped reads. Not the person who owes it — that is Owner.',
group: 'basics',
hidden: true,
} as ReturnType<typeof Field.lookup>,

// On a hand-made duty, `duly_duty_unit_stamp` (src/hooks/duty.hook.ts)
// writes the owner's primary business unit at create. Apply catalog runs
// as system, so the stamp skips it; its handler resolves the same rung
Expand Down
20 changes: 19 additions & 1 deletion src/objects/log-entry.object.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.

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

/**
* `duly_log_entry` — the personal work log. The calendar, not the checklist.
Expand Down Expand Up @@ -50,6 +50,24 @@ export const LogEntry = ObjectSchema.create({

owner: Field.user({ label: 'Owner', group: 'sharing', required: true, defaultValue: 'current_user' }),

// The platform's own owner column, declared here to hide it and name it
// apart. The platform injects `owner_id` on every user-owned object,
// labelled "Owner" (负责人 to a zh-CN reader), so a record page showed two
// "Owner"s naming two different people: Duly's `owner` above, and
// `owner_id`, which is whoever created the row — the dispatcher, the seed
// or an administrator (#143). From @objectstack 18.5 that is the
// author-time error `field-label-duplicate`. `owner` is the one a reader
// means. Only the label, the help and the visibility change: the type, the
// reference and every job the column does (the insert stamp, `own` read
// scope) stay the platform's.
owner_id: {
...OWNER_FIELD_DEF,
label: 'Record owner',
description: 'Who created this row: the platform\'s record owner, which drives owner-scoped reads. Not the person who owes it — that is Owner.',
group: 'sharing',
hidden: true,
} as ReturnType<typeof Field.lookup>,

logged_on: Field.date({ label: 'Date', group: 'basics', required: true, defaultValue: 'NOW()' }),

category: Field.select({
Expand Down
20 changes: 19 additions & 1 deletion src/objects/task.object.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.

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

/**
* `duly_task` — ONE occurrence of a duty, owed by ONE person, for ONE period.
Expand Down Expand Up @@ -126,6 +126,24 @@ export const Task = ObjectSchema.create({
defaultValue: 'current_user',
}),

// The platform's own owner column, declared here to hide it and name it
// apart. The platform injects `owner_id` on every user-owned object,
// labelled "Owner" (负责人 to a zh-CN reader), so a record page showed two
// "Owner"s naming two different people: Duly's `owner` above, and
// `owner_id`, which is whoever created the row — the dispatcher, the seed
// or an administrator (#143). From @objectstack 18.5 that is the
// author-time error `field-label-duplicate`. `owner` is the one a reader
// means. Only the label, the help and the visibility change: the type, the
// reference and every job the column does (the insert stamp, `own` read
// scope) stay the platform's.
owner_id: {
...OWNER_FIELD_DEF,
label: 'Record owner',
description: 'Who created this row: the platform\'s record owner, which drives owner-scoped reads. Not the person who owes it — that is Owner.',
group: 'basics',
hidden: true,
} as ReturnType<typeof Field.lookup>,

business_unit: Field.lookup('sys_business_unit', {
label: 'Business unit',
group: 'basics',
Expand Down
6 changes: 5 additions & 1 deletion src/translations/authored-text.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1061,7 +1061,11 @@ export const COLLECTION_HANDLING: Readonly<Record<string, string>> = {
functions: 'handler registrations',
plugins: 'plugin instances',
requires: 'capability tokens',
mappings: 'field mappings — machine names',
// Not walked because there is nothing to walk: `dulyMappings` is empty. From
// @objectstack 18.6 a mapping's `label` IS display text (the import wizard
// lists mappings by label, keyed `mappings.<name>.label`), so the first
// mapping must be walked; `test/i18n-coverage.test.ts` fails until it is.
mappings: 'none declared — a mapping label is translatable from 18.6; walk it when the first mapping lands',
i18n: 'the locale configuration these bundles serve',
translations: 'the bundles themselves',
};
Expand Down
12 changes: 12 additions & 0 deletions src/translations/zh-CN.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,10 @@ export const dulyChinese = defineTranslationBundle({
label: '负责人',
help: '有且只有一个担责的人。“由团队负责”的工作等于没人负责。',
},
owner_id: {
label: '记录所有者',
help: '创建这一行的人:平台的记录所有者,按所有者划分的读取以它为准。不是承担这项工作的人——那是“负责人”。',
},
business_unit: {
label: '部门',
help: '汇总口径的锚点。创建时取自负责人的主业务单元。负责人没有主业务单元时,应用岗位职责库会改用其岗位锚定的业务单元(仅当这些岗位都指向同一个业务单元时);否则留空。',
Expand Down Expand Up @@ -308,6 +312,10 @@ export const dulyChinese = defineTranslationBundle({
help: '对于从未建模成职责的一次性工作,此处为空。',
},
owner: { label: '负责人' },
owner_id: {
label: '记录所有者',
help: '创建这一行的人:平台的记录所有者,按所有者划分的读取以它为准。不是承担这项工作的人——那是“负责人”。',
},
business_unit: {
label: '部门',
help: '派发时从负责人处冗余写入,使汇总在此后的人员调动中依然成立。',
Expand Down Expand Up @@ -603,6 +611,10 @@ export const dulyChinese = defineTranslationBundle({
subject: { label: '你做了什么' },
detail: { label: '详情' },
owner: { label: '负责人' },
owner_id: {
label: '记录所有者',
help: '创建这一行的人:平台的记录所有者,按所有者划分的读取以它为准。不是承担这项工作的人——那是“负责人”。',
},
logged_on: { label: '日期' },
category: {
label: '类别',
Expand Down
52 changes: 35 additions & 17 deletions test/assignment-fanout.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -793,12 +793,24 @@ describe('assignment fan-out — a removed or banned assignee, driven through th
const mkUser = async (name: string, extra: AnyRec = {}): Promise<string> =>
String(first(await data.insert('sys_user', { name, email: `${name}@example.test`, ...extra }, sys)).id);

/** Save the assignment while every assignee exists, then run the fan-out on the row as stored. */
const fanOut = async (assigner: string, assignees: string[], removeBeforeRun: string[] = []) => {
/**
* Save the assignment while every assignee exists and may be assigned, then
* remove or ban the ones named, then run the fan-out on the row as stored.
* Since @objectstack 18.5 the assignment write itself refuses an assignee
* whose ban is in force (`reference_user_banned`), so a ban, like a removal,
* can only reach the fan-out by landing after the save.
*/
const fanOut = async (
assigner: string,
assignees: string[],
removeBeforeRun: string[] = [],
banBeforeRun: Record<string, AnyRec> = {},
) => {
const assignment = first(await data.insert('duly_assignment', {
subject: SUBJECT, assigner, assignees, due_date: '2026-10-01', status: 'dispatched', needs_collection: false,
}));
for (const id of removeBeforeRun) await data.delete('sys_user', { where: { id }, ...sys });
for (const [id, ban] of Object.entries(banBeforeRun)) await data.update('sys_user', ban, { where: { id }, ...sys });
const stored = (await data.find('duly_assignment', { where: { id: assignment.id } }))[0] as AnyRec;
const result = await automation.execute('duly_assignment_fanout', {
record: stored, object: 'duly_assignment', event: 'afterUpdate',
Expand Down Expand Up @@ -858,16 +870,16 @@ describe('assignment fan-out — a removed or banned assignee, driven through th
// Sign-in clears a ban whose expiry has passed, so that person can open a
// task and gets one. A standing ban — no expiry, or one still ahead — is
// an account nobody can sign in as.
const banned = await mkUser('fanout148_banned', { banned: true });
const bannedUntilLater = await mkUser('fanout148_banned_later', {
banned: true, ban_expires: new Date(Date.now() + 7 * 86_400_000).toISOString(),
});
const banLapsed = await mkUser('fanout148_ban_lapsed', {
banned: true, ban_expires: new Date(Date.now() - 86_400_000).toISOString(),
});
const banned = await mkUser('fanout148_banned');
const bannedUntilLater = await mkUser('fanout148_banned_later');
const banLapsed = await mkUser('fanout148_ban_lapsed');
const boss = await mkUser('fanout148_boss_2');

const { result, tasks, inbox } = await fanOut(boss, [banned, bannedUntilLater, banLapsed]);
const { result, tasks, inbox } = await fanOut(boss, [banned, bannedUntilLater, banLapsed], [], {
[banned]: { banned: true },
[bannedUntilLater]: { banned: true, ban_expires: new Date(Date.now() + 7 * 86_400_000).toISOString() },
[banLapsed]: { banned: true, ban_expires: new Date(Date.now() - 86_400_000).toISOString() },
});

expect(tasks.map((t) => String(t.owner))).toEqual([banLapsed]);
expect(result.success, String(result.error ?? '')).toBe(true);
Expand Down Expand Up @@ -994,19 +1006,23 @@ describe('assignment fan-out — the notice the assigner reads, per cause and pe
String(first(await data.insert('sys_user', { name: `${name}_${++seq}`, email: `${name}_${seq}@example.test`, ...extra }, sys)).id);

/**
* Save the assignment while every stored assignee exists, remove the ones
* named, then run the fan-out. `runAssignees`, when given, rides on the
* trigger context instead of the stored row — the only way to reach a bad
* handle the assignment write itself now refuses (see the #123 block).
* Save the assignment while every stored assignee exists and may be
* assigned, remove or ban the ones named, then run the fan-out.
* `runAssignees`, when given, rides on the trigger context instead of the
* stored row — the only way to reach a bad handle the assignment write
* itself now refuses (see the #123 block). A ban in force is refused at the
* assignment write too since @objectstack 18.5, so it lands after the save.
*/
const fanOut = async (opts: {
assigner: string; stored: string[]; remove?: string[]; runAssignees?: unknown[]; expectNotices: number;
assigner: string; stored: string[]; remove?: string[]; ban?: Record<string, AnyRec>;
runAssignees?: unknown[]; expectNotices: number;
}) => {
const assignment = first(await data.insert('duly_assignment', {
subject: SUBJECT, assigner: opts.assigner, assignees: opts.stored, due_date: '2026-10-01',
status: 'dispatched', needs_collection: false,
}));
for (const id of opts.remove ?? []) await data.delete('sys_user', { where: { id }, ...sys });
for (const [id, ban] of Object.entries(opts.ban ?? {})) await data.update('sys_user', ban, { where: { id }, ...sys });
const stored = (await data.find('duly_assignment', { where: { id: assignment.id } }))[0] as AnyRec;
const result = await automation.execute('duly_assignment_fanout', {
record: opts.runAssignees ? { ...stored, assignees: opts.runAssignees } : stored,
Expand Down Expand Up @@ -1051,10 +1067,12 @@ describe('assignment fan-out — the notice the assigner reads, per cause and pe
}, 30_000);

it.each(LOCALES)('a banned account: the %s notice says the account is banned and how to fix it', async (locale) => {
const banned = await mkUser('n160_banned', { banned: true });
const banned = await mkUser('n160_banned');
const boss = await mkUser('n160_boss', { locale });

const { result, tasks, inbox } = await fanOut({ assigner: boss, stored: [banned], expectNotices: 1 });
const { result, tasks, inbox } = await fanOut({
assigner: boss, stored: [banned], ban: { [banned]: { banned: true } }, expectNotices: 1,
});

expect(result.success, String(result.error ?? '')).toBe(true);
expect(tasks).toEqual([]);
Expand Down
14 changes: 13 additions & 1 deletion test/i18n-coverage.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -312,13 +312,25 @@ describe('the bundles reach the stack', () => {
// `book` arrived in 18.3.0. Re-derived, nothing moves: this app declares
// no book, and no `untranslatable` verdict in the walk rests on books
// being absent. So the pin widens with no verdict to revisit.
//
// `mapping` arrived in 18.6.0: a named import mapping's `label`, keyed
// `mappings.<name>.label`. Re-derived: this app declares no mapping, so no
// string moves, but `COLLECTION_HANDLING.mappings` called mappings
// "machine names", which is no longer true of their label. The skip now
// rests on the collection being empty, and the assertion after the pin
// holds it to that: the first mapping fails here until the walk reads it.
expect(
[...PLATFORM_TRANSLATABLE_TYPES].sort(),
'the platform\'s translatable metadata types changed — re-derive the '
+ '`untranslatable` verdicts in src/translations/authored-text.ts against the new set',
).toEqual([
'action', 'app', 'book', 'dashboard', 'dataset', 'object', 'page', 'permission', 'picklist', 'position', 'report', 'view',
'action', 'app', 'book', 'dashboard', 'dataset', 'mapping', 'object', 'page', 'permission', 'picklist', 'position', 'report', 'view',
]);
expect(
(stackConfig as { mappings?: unknown[] }).mappings ?? [],
'a mapping\'s label is translatable from @objectstack 18.6 and `mappings` is not walked — '
+ 'walk its label (`mappings.<name>.label`) before declaring one',
).toEqual([]);
});
});

Expand Down
18 changes: 16 additions & 2 deletions test/seed-history.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,21 @@ let data: any;
let protocol: any;
let kernel: any;

/**
* `seed_user_alice`'s id, read back after the seed. The seed loader resolves
* `owner: 'seed_user_alice'` as a natural key against `sys_user.name`; a data
* write does not — it takes the value as the user's id. From @objectstack 18.4
* a non-system write is refused `reference_not_found` for a `user` field that
* names no row the caller can read (objectstack eb96480), so the boundary
* payloads below must name Alice by her id, or that refusal would answer in
* place of the completion rule under test.
*/
let ALICE = '';

/** A non-seed task payload, used for the boundary assertions. */
const adhoc = (over: Record<string, unknown> = {}) => ({
subject: 'ad-hoc probe task',
owner: 'seed_user_alice',
owner: ALICE,
source: 'catalog',
...over,
});
Expand Down Expand Up @@ -179,6 +190,9 @@ beforeAll(async () => {
// The inline seed is kicked off against a budget rather than awaited by
// bootstrap, so give it a moment to settle before reading its rows.
await new Promise((resolve) => setTimeout(resolve, 1500));
const alice = await data.findOne('sys_user', { where: { name: 'seed_user_alice' } }, { context: SYSTEM_CONTEXT });
ALICE = String(alice?.id ?? '');
if (!ALICE) throw new Error('the seed must have written seed_user_alice before the boundary cases run');
}, 120_000);

afterAll(async () => {
Expand Down Expand Up @@ -303,7 +317,7 @@ describe('an ordinary caller still may not', () => {
await protocol.createData({
object: 'duly_task',
data: adhoc({ subject: 'explicit non-system done', status: 'done', completed_at: COMPLETED_ON }),
context: { userId: 'seed_user_alice', isSystem: false },
context: { userId: ALICE, isSystem: false },
});
} catch (e) {
error = e;
Expand Down
Loading
Loading