@operato/twin-figure-capabilities 0.0.0-stage → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,61 @@
1
+ import type { FigureAsset, FigureCapabilityDescriptor } from '@hatiolab/figure-model';
2
+ import { type CapabilityKey } from '@operato/ops-contract';
3
+ /** The twin's scene actions (ADR-0209 decision 3): `<provider>.<action>`. The twin app registers what each does. */
4
+ export declare const TWIN_ACTIONS: {
5
+ readonly preview: "twin.preview-entity";
6
+ readonly info: "twin.entity-info";
7
+ readonly open: "twin.open-entity";
8
+ readonly command: "twin.command";
9
+ };
10
+ /** What every twin entity answers to, by meaning (ADR-0209 decision 2). */
11
+ export declare const TWIN_ENTITY_INTERACTIONS: readonly ({
12
+ meaning: "preview";
13
+ action: "twin.preview-entity";
14
+ label?: undefined;
15
+ } | {
16
+ meaning: "select";
17
+ action: "twin.entity-info";
18
+ label?: undefined;
19
+ } | {
20
+ meaning: "enter";
21
+ action: "twin.open-entity";
22
+ label?: undefined;
23
+ } | {
24
+ meaning: "actions";
25
+ action: "twin.entity-info";
26
+ label: {
27
+ ko: string;
28
+ en: string;
29
+ };
30
+ } | {
31
+ meaning: "actions";
32
+ action: "twin.open-entity";
33
+ label: {
34
+ ko: string;
35
+ en: string;
36
+ };
37
+ })[];
38
+ /** The settings key of the entity types */
39
+ export declare const ENTITY_TYPES_SETTING = "types";
40
+ /** The entity types a figure declares, as written. */
41
+ export declare function entityTypesOf(settings: Record<string, unknown> | undefined): string[];
42
+ /** Why the settings cannot be taken: no type declared, keys out of place. */
43
+ export declare function entitySettingsIssues(settings: Record<string, unknown> | undefined): string[];
44
+ /** The capabilities the contract's standard catalog gives a type, across its systems; none for a type it does not know. */
45
+ export declare function standardCapabilitiesOfType(type: string): CapabilityKey[];
46
+ /**
47
+ * What the declared types and the capabilities worn say about each other (decision 14): a capability a type has that the
48
+ * figure does not take on, and one the figure wears that no declared type has. Advice for the author -- the figure stands
49
+ * either way, so it is not the check, which would take the capability off. `typeCapabilities` is the domain catalog's
50
+ * answer (the choice list's data); left out, the contract's standard catalog answers for the types it knows.
51
+ */
52
+ export declare function entityCapabilityAdvice(settings: Record<string, unknown> | undefined, asset: Pick<FigureAsset, 'document'>, typeCapabilities?: (type: string) => readonly string[]): {
53
+ missing: {
54
+ type: string;
55
+ capability: string;
56
+ }[];
57
+ extra: string[];
58
+ };
59
+ /** The twin capabilities a figure can wear besides the base (kept in step with module.ts by a test). */
60
+ export declare const TWIN_FIGURE_CAPABILITY_NAMES: string[];
61
+ export declare const ENTITY: FigureCapabilityDescriptor;
package/dist/entity.js ADDED
@@ -0,0 +1,89 @@
1
+ import { DOMAIN_SYSTEMS, capabilitiesForType } from '@operato/ops-contract';
2
+ import { TWIN_COMMAND_ACTION, TWIN_ENTITY_NAME, twinCapabilityName } from "./generate.js";
3
+ /*
4
+ * `twin.Entity` (ADR-0208 amendment 1 decision 12): the base every twin capability stands on. It says which entity types
5
+ * the figure draws -- a location's `type`, equipment's `kind` -- and that saying is the mapping: the twin draws an entity
6
+ * of a declared type with this figure (decision 16). The list a modeller offers comes from the linked twin domain's
7
+ * catalog (ADR-0172 amendment 2), not from this module. The interactions every entity shares (preview, select, enter its
8
+ * 360) take their place here once ADR-0209 decision 4 lands.
9
+ */
10
+ /** The twin's scene actions (ADR-0209 decision 3): `<provider>.<action>`. The twin app registers what each does. */
11
+ export const TWIN_ACTIONS = {
12
+ preview: 'twin.preview-entity',
13
+ info: 'twin.entity-info',
14
+ open: 'twin.open-entity',
15
+ command: TWIN_COMMAND_ACTION
16
+ };
17
+ /** What every twin entity answers to, by meaning (ADR-0209 decision 2). */
18
+ export const TWIN_ENTITY_INTERACTIONS = Object.freeze([
19
+ { meaning: 'preview', action: TWIN_ACTIONS.preview },
20
+ { meaning: 'select', action: TWIN_ACTIONS.info },
21
+ { meaning: 'enter', action: TWIN_ACTIONS.open },
22
+ /* The actions menu (amendment 1 decision 8): these two, then each capability's commands (`commandInteractionsOf`) */
23
+ { meaning: 'actions', action: TWIN_ACTIONS.info, label: { ko: '정보', en: 'Info' } },
24
+ { meaning: 'actions', action: TWIN_ACTIONS.open, label: { ko: '360 열기', en: 'Open 360' } }
25
+ ]);
26
+ /** The settings key of the entity types */
27
+ export const ENTITY_TYPES_SETTING = 'types';
28
+ /** The entity types a figure declares, as written. */
29
+ export function entityTypesOf(settings) {
30
+ const types = (settings ?? {})[ENTITY_TYPES_SETTING];
31
+ return Array.isArray(types) ? types.filter((t) => typeof t === 'string' && t.trim() !== '') : [];
32
+ }
33
+ /** Why the settings cannot be taken: no type declared, keys out of place. */
34
+ export function entitySettingsIssues(settings) {
35
+ const out = [];
36
+ for (const key of Object.keys(settings ?? {}))
37
+ if (key !== ENTITY_TYPES_SETTING)
38
+ out.push(`${key}은(는) 이 능력에서 사용하지 않는 설정입니다. 삭제하세요.`);
39
+ if (!entityTypesOf(settings).length)
40
+ out.push('이 피규어가 나타내는 엔티티 종류를 하나 이상 선택하세요.');
41
+ return out;
42
+ }
43
+ /** The capabilities the contract's standard catalog gives a type, across its systems; none for a type it does not know. */
44
+ export function standardCapabilitiesOfType(type) {
45
+ return [...new Set(DOMAIN_SYSTEMS.flatMap(system => capabilitiesForType(system, type)))];
46
+ }
47
+ /**
48
+ * What the declared types and the capabilities worn say about each other (decision 14): a capability a type has that the
49
+ * figure does not take on, and one the figure wears that no declared type has. Advice for the author -- the figure stands
50
+ * either way, so it is not the check, which would take the capability off. `typeCapabilities` is the domain catalog's
51
+ * answer (the choice list's data); left out, the contract's standard catalog answers for the types it knows.
52
+ */
53
+ export function entityCapabilityAdvice(settings, asset, typeCapabilities = standardCapabilitiesOfType) {
54
+ const worn = new Set(asset.document.capabilities.names ?? []);
55
+ const types = entityTypesOf(settings);
56
+ const missing = [];
57
+ const covered = new Set();
58
+ for (const type of types)
59
+ for (const key of typeCapabilities(type)) {
60
+ const name = twinCapabilityName(key);
61
+ covered.add(name);
62
+ if (TWIN_FIGURE_CAPABILITY_NAMES.includes(name) && !worn.has(name))
63
+ missing.push({ type, capability: name });
64
+ }
65
+ const extra = [...worn].filter(name => TWIN_FIGURE_CAPABILITY_NAMES.includes(name) && types.length > 0 && !covered.has(name));
66
+ return { missing, extra };
67
+ }
68
+ /** The twin capabilities a figure can wear besides the base (kept in step with module.ts by a test). */
69
+ export const TWIN_FIGURE_CAPABILITY_NAMES = ['twin.Operable', 'twin.Storable', 'twin.Mobile'];
70
+ export const ENTITY = {
71
+ name: TWIN_ENTITY_NAME,
72
+ label: { ko: '트윈 엔티티', en: 'Twin entity' },
73
+ note: {
74
+ ko: '이 피규어가 나타내는 트윈 엔티티 종류를 정합니다. 트윈은 이 종류의 엔티티를 이 피규어로 그립니다. 운영 상태 · 보관 · 이동 능력은 이 능력 위에 켭니다.',
75
+ en: 'Sets the twin entity types this figure draws. The twin draws entities of these types with it. Operating status, storage and motion are turned on over this capability.'
76
+ },
77
+ version: '2',
78
+ needs: [],
79
+ /* The marker the twin sends with every entity's data (headless-twin entity-delta `entity`) */
80
+ data: [{ name: 'entity' }],
81
+ settings: [{ key: ENTITY_TYPES_SETTING, kind: 'choice', label: { ko: '엔티티 종류', en: 'Entity types' }, multiple: true, required: true }],
82
+ check: settings => entitySettingsIssues(settings),
83
+ takes: () => ({}),
84
+ /*
85
+ * 엔티티 공통의 상호작용(ADR-0209 결정 4, ADR-0208 개정 1 결정 12): 미리보기는 이름과 핵심 상태, 선택은 정보 창, 들어가기는 엔티티 360, 동작
86
+ * 메뉴는 그 엔티티에 할 수 있는 일. 무엇을 할지는 트윈 보드에 등록된 동작이 정한다 — 다른 보드에서는 정의만 남고 아무 일도 하지 않는다.
87
+ */
88
+ interactions: () => TWIN_ENTITY_INTERACTIONS
89
+ };
@@ -0,0 +1,54 @@
1
+ import type { FigureAsset, FigureCapabilityCard, FigureCapabilityDescriptor, FigureDataBinding } from '@hatiolab/figure-model';
2
+ import { type CapabilityKey } from '@operato/ops-contract';
3
+ import type { Words } from './words.ts';
4
+ /** The base capability every twin capability stands on. */
5
+ export declare const TWIN_ENTITY_NAME = "twin.Entity";
6
+ /** The scene action that sends one contract command to the entity (ADR-0209 decision 3); the twin app registers it. */
7
+ export declare const TWIN_COMMAND_ACTION = "twin.command";
8
+ /**
9
+ * The words of the contract's commands, as an actions menu lists them (ADR-0209 amendment 1 decision 8). A capability's
10
+ * command with no words here is a test failure, not a menu item named by its code.
11
+ */
12
+ export declare const COMMAND_WORDS: Readonly<Record<string, Words>>;
13
+ /** A capability's commands as `actions` menu items: each sends its command, with the twin's confirmation. */
14
+ export declare const commandInteractionsOf: (key: CapabilityKey) => {
15
+ meaning: "actions";
16
+ action: string;
17
+ value: string;
18
+ label: Words;
19
+ }[];
20
+ /** `twin.<Capability>`, as the contract names the capability. */
21
+ export declare const twinCapabilityName: (key: CapabilityKey) => string;
22
+ /** The legend role of a listed field: `twin-<field>` (the operating status: `twin-status`). */
23
+ export declare const legendRoleOf: (field: string) => string;
24
+ /** The settings key of a listed field's parts: `<field>Parts` (the operating status: `statusParts`). */
25
+ export declare const partsSettingOf: (field: string) => string;
26
+ export interface TwinCapabilitySpec {
27
+ key: CapabilityKey;
28
+ label: Words;
29
+ note: Words;
30
+ version: string;
31
+ /** What it needs besides `twin.Entity` */
32
+ needs?: ReadonlyArray<string | readonly string[]>;
33
+ /** Data it reads besides the contract's state fields (Storable: its location's items) */
34
+ moreData?: readonly string[];
35
+ /** What its own mixin takes over besides the listed fields' parts (Storable: the item list) */
36
+ takesItems?: boolean;
37
+ /** The 2D card places it offers (ADR-0209 decision 5): the twin board puts its card there. */
38
+ cards?: readonly FigureCapabilityCard[];
39
+ }
40
+ /** The listed fields of a capability: its state fields the contract gives a closed list for. */
41
+ export declare const listedFieldsOf: (key: CapabilityKey) => string[];
42
+ /** Why the settings cannot be taken: a listed field with no part, parts the figure lacks, keys out of place. */
43
+ export declare function listedSettingsIssues(key: CapabilityKey, settings: Record<string, unknown> | undefined, asset: FigureAsset): string[];
44
+ /** The tables the capability hands the figure engine (ADR-0166): each listed field's rows on its parts, by its legend role. */
45
+ export declare function listedDataInterface(key: CapabilityKey, settings: Record<string, unknown> | undefined): {
46
+ schema: {
47
+ name: string;
48
+ label: string;
49
+ kind: 'text';
50
+ }[];
51
+ bindings: FigureDataBinding[];
52
+ } | undefined;
53
+ /** A twin capability's descriptor, made from the contract and the spec. */
54
+ export declare function twinCapability(spec: TwinCapabilitySpec): FigureCapabilityDescriptor;
@@ -0,0 +1,101 @@
1
+ import { CAPABILITIES } from '@operato/ops-contract';
2
+ import { STATE_FIELD_WORDS, STATE_VALUE_LISTS, legendRowsOf } from "./values.js";
3
+ /*
4
+ * A twin capability's definition made from the contract (ADR-0208 amendment 1 decision 15): the data it reads is the
5
+ * capability's state fields, and each field with a closed value list gets its legend rows and a parts setting -- the one
6
+ * thing left to the author is which parts show it. What a capability does beyond that (putting items in places, moving)
7
+ * is a mixin written by hand in the twin app. Every twin capability needs `twin.Entity` (decision 13).
8
+ */
9
+ /** The base capability every twin capability stands on. */
10
+ export const TWIN_ENTITY_NAME = 'twin.Entity';
11
+ /** The scene action that sends one contract command to the entity (ADR-0209 decision 3); the twin app registers it. */
12
+ export const TWIN_COMMAND_ACTION = 'twin.command';
13
+ /**
14
+ * The words of the contract's commands, as an actions menu lists them (ADR-0209 amendment 1 decision 8). A capability's
15
+ * command with no words here is a test failure, not a menu item named by its code.
16
+ */
17
+ export const COMMAND_WORDS = Object.freeze({
18
+ 'resource.hold': { ko: '계획 정지', en: 'Plan stop' },
19
+ 'resource.resume': { ko: '재개', en: 'Resume' },
20
+ 'resource.down': { ko: '고장 주입', en: 'Inject fault' },
21
+ 'resource.repair': { ko: '수리', en: 'Repair' },
22
+ 'resource.reset-metrics': { ko: '지표 리셋', en: 'Reset metrics' }
23
+ });
24
+ /** A capability's commands as `actions` menu items: each sends its command, with the twin's confirmation. */
25
+ export const commandInteractionsOf = (key) => CAPABILITIES[key].commands.map(command => ({ meaning: 'actions', action: TWIN_COMMAND_ACTION, value: command, label: COMMAND_WORDS[command] ?? { ko: command, en: command } }));
26
+ /** `twin.<Capability>`, as the contract names the capability. */
27
+ export const twinCapabilityName = (key) => `twin.${key[0].toUpperCase()}${key.slice(1)}`;
28
+ /** The legend role of a listed field: `twin-<field>` (the operating status: `twin-status`). */
29
+ export const legendRoleOf = (field) => `twin-${field}`;
30
+ /** The settings key of a listed field's parts: `<field>Parts` (the operating status: `statusParts`). */
31
+ export const partsSettingOf = (field) => `${field}Parts`;
32
+ /** The listed fields of a capability: its state fields the contract gives a closed list for. */
33
+ export const listedFieldsOf = (key) => CAPABILITIES[key].stateFields.filter(field => STATE_VALUE_LISTS[field]);
34
+ const partsOf = (settings, field) => {
35
+ const parts = (settings ?? {})[partsSettingOf(field)];
36
+ return Array.isArray(parts) ? parts.filter((p) => typeof p === 'string') : [];
37
+ };
38
+ /** Why the settings cannot be taken: a listed field with no part, parts the figure lacks, keys out of place. */
39
+ export function listedSettingsIssues(key, settings, asset) {
40
+ const fields = listedFieldsOf(key);
41
+ const keys = fields.map(partsSettingOf);
42
+ const parts = new Set(asset.appearance.map(a => a.target));
43
+ const out = [];
44
+ for (const k of Object.keys(settings ?? {}))
45
+ if (!keys.includes(k))
46
+ out.push(`${k}은(는) 이 능력에서 사용하지 않는 설정입니다. 삭제하세요.`);
47
+ for (const field of fields) {
48
+ const chosen = partsOf(settings, field);
49
+ if (!chosen.length)
50
+ out.push(`${STATE_FIELD_WORDS[field]?.ko ?? field}을(를) 표시할 부품을 하나 이상 선택하세요.`);
51
+ for (const part of chosen)
52
+ if (!parts.has(part))
53
+ out.push(`${part} 부품이 이 피규어에 없습니다. 다른 부품을 선택하세요.`);
54
+ }
55
+ return out;
56
+ }
57
+ /** The tables the capability hands the figure engine (ADR-0166): each listed field's rows on its parts, by its legend role. */
58
+ export function listedDataInterface(key, settings) {
59
+ const fields = listedFieldsOf(key).filter(field => partsOf(settings, field).length);
60
+ if (!fields.length)
61
+ return undefined;
62
+ return {
63
+ schema: fields.map(field => ({ name: field, label: STATE_FIELD_WORDS[field]?.ko ?? field, kind: 'text' })),
64
+ bindings: fields.map(field => ({
65
+ id: legendRoleOf(field),
66
+ label: STATE_FIELD_WORDS[field]?.ko ?? field,
67
+ accessor: field,
68
+ rule: 'table',
69
+ lookup: 'code',
70
+ targets: { parts: partsOf(settings, field) },
71
+ table: legendRowsOf(field),
72
+ legend: { role: legendRoleOf(field) }
73
+ }))
74
+ };
75
+ }
76
+ /** A twin capability's descriptor, made from the contract and the spec. */
77
+ export function twinCapability(spec) {
78
+ const { key } = spec;
79
+ const fields = listedFieldsOf(key);
80
+ return {
81
+ name: twinCapabilityName(key),
82
+ label: spec.label,
83
+ note: spec.note,
84
+ version: spec.version,
85
+ needs: [TWIN_ENTITY_NAME, ...(spec.needs ?? [])],
86
+ data: [...CAPABILITIES[key].stateFields, ...(spec.moreData ?? [])].map(name => ({ name })),
87
+ ...(fields.length
88
+ ? {
89
+ settings: fields.map(field => ({ key: partsSettingOf(field), kind: 'parts', label: STATE_FIELD_WORDS[field] ?? { ko: field, en: field }, required: true })),
90
+ check: (settings, asset) => listedSettingsIssues(key, settings, asset),
91
+ dataInterface: (settings) => listedDataInterface(key, settings)
92
+ }
93
+ : {}),
94
+ ...(spec.cards?.length ? { cards: () => spec.cards } : {}),
95
+ ...(CAPABILITIES[key].commands.length ? { interactions: () => commandInteractionsOf(key) } : {}),
96
+ takes: (settings) => ({
97
+ ...(spec.takesItems ? { items: true } : {}),
98
+ ...(fields.length ? { parts: fields.flatMap(field => partsOf(settings, field)) } : {})
99
+ })
100
+ };
101
+ }
@@ -0,0 +1,7 @@
1
+ export { ENTITY, ENTITY_TYPES_SETTING, TWIN_ACTIONS, TWIN_ENTITY_INTERACTIONS, TWIN_FIGURE_CAPABILITY_NAMES, entityCapabilityAdvice, entitySettingsIssues, entityTypesOf, standardCapabilitiesOfType } from './entity.ts';
2
+ export { COMMAND_WORDS, TWIN_COMMAND_ACTION, TWIN_ENTITY_NAME, commandInteractionsOf, legendRoleOf, listedDataInterface, listedFieldsOf, listedSettingsIssues, partsSettingOf, twinCapability, twinCapabilityName, type TwinCapabilitySpec } from './generate.ts';
3
+ export { DEFAULT_VALUE_COLOUR, STATE_FIELD_WORDS, STATE_VALUE_LISTS, VALUE_COLOURS, legendRowsOf } from './values.ts';
4
+ export { OPERABLE } from './operable.ts';
5
+ export { STORABLE, twinItemId, twinItemRecords, type TwinItemRecord, type TwinLocationItem } from './storable.ts';
6
+ export { MOBILE } from './mobile.ts';
7
+ export { capabilities as TWIN_FIGURE_CAPABILITIES, label as TWIN_CAPABILITY_PROVIDER_LABEL, provider as TWIN_CAPABILITY_PROVIDER, version as TWIN_CAPABILITY_MODULE_VERSION } from './module.ts';
package/dist/index.js ADDED
@@ -0,0 +1,12 @@
1
+ /*
2
+ * What the twin puts on a figure (ADR-0208, amendment 1): the base capability twin.Entity, the capabilities made from the
3
+ * ops-contract (twin.Operable, twin.Storable, twin.Mobile) and their pure functions -- no scene, DOM or API. The twin
4
+ * app registers them with its mixins; a figure server loads the module.
5
+ */
6
+ export { ENTITY, ENTITY_TYPES_SETTING, TWIN_ACTIONS, TWIN_ENTITY_INTERACTIONS, TWIN_FIGURE_CAPABILITY_NAMES, entityCapabilityAdvice, entitySettingsIssues, entityTypesOf, standardCapabilitiesOfType } from "./entity.js";
7
+ export { COMMAND_WORDS, TWIN_COMMAND_ACTION, TWIN_ENTITY_NAME, commandInteractionsOf, legendRoleOf, listedDataInterface, listedFieldsOf, listedSettingsIssues, partsSettingOf, twinCapability, twinCapabilityName } from "./generate.js";
8
+ export { DEFAULT_VALUE_COLOUR, STATE_FIELD_WORDS, STATE_VALUE_LISTS, VALUE_COLOURS, legendRowsOf } from "./values.js";
9
+ export { OPERABLE } from "./operable.js";
10
+ export { STORABLE, twinItemId, twinItemRecords } from "./storable.js";
11
+ export { MOBILE } from "./mobile.js";
12
+ export { capabilities as TWIN_FIGURE_CAPABILITIES, label as TWIN_CAPABILITY_PROVIDER_LABEL, provider as TWIN_CAPABILITY_PROVIDER, version as TWIN_CAPABILITY_MODULE_VERSION } from "./module.js";
@@ -0,0 +1 @@
1
+ export declare const MOBILE: import("@hatiolab/figure-model").FigureCapabilityDescriptor;
package/dist/mobile.js ADDED
@@ -0,0 +1,15 @@
1
+ import { twinCapability } from "./generate.js";
2
+ /*
3
+ * `twin.Mobile`: the figure stands where the twin observes the resource -- at its location, or on the way between two
4
+ * locations by its motion's progress -- with its front face (+Z) ahead. The kernel has no coordinates, so the scene finds
5
+ * the locations by their placed components (ADR-0208 미결 1: a straight line first). The moving is the scene's mixin.
6
+ */
7
+ export const MOBILE = twinCapability({
8
+ key: 'mobile',
9
+ label: { ko: '이동', en: 'Mobile' },
10
+ note: {
11
+ ko: '트윈이 관측한 위치와 이동으로 피규어를 자리 사이에서 움직입니다. 피규어의 앞면이 진행 방향을 향합니다.',
12
+ en: 'Moves the figure between locations as the twin observes it moving, its front face ahead.'
13
+ },
14
+ version: '2'
15
+ });
@@ -0,0 +1,10 @@
1
+ export declare const provider = "twin";
2
+ /** The provider's name on the modeller's screen. */
3
+ export declare const label: {
4
+ ko: string;
5
+ en: string;
6
+ };
7
+ /** The module's version: the package's (a test keeps them the same). */
8
+ export declare const version = "0.5.0";
9
+ /** The base first, then the capabilities that stand on it. */
10
+ export declare const capabilities: import("@hatiolab/figure-model").FigureCapabilityDescriptor[];
package/dist/module.js ADDED
@@ -0,0 +1,16 @@
1
+ /*
2
+ * The twin's capability module (ADR-0172 decision 3): one provider, its version and its descriptors, in one file the
3
+ * build bundles (`dist/twin-capabilities.module.mjs`) for a figure server to load. Nothing outside the file is imported
4
+ * at run time.
5
+ */
6
+ import { ENTITY } from "./entity.js";
7
+ import { MOBILE } from "./mobile.js";
8
+ import { OPERABLE } from "./operable.js";
9
+ import { STORABLE } from "./storable.js";
10
+ export const provider = 'twin';
11
+ /** The provider's name on the modeller's screen. */
12
+ export const label = { ko: '트윈', en: 'Twin' };
13
+ /** The module's version: the package's (a test keeps them the same). */
14
+ export const version = '0.5.0';
15
+ /** The base first, then the capabilities that stand on it. */
16
+ export const capabilities = [ENTITY, OPERABLE, STORABLE, MOBILE];
@@ -0,0 +1 @@
1
+ export declare const OPERABLE: import("@hatiolab/figure-model").FigureCapabilityDescriptor;
@@ -0,0 +1,16 @@
1
+ import { twinCapability } from "./generate.js";
2
+ /*
3
+ * `twin.Operable`: the operating status the twin observes -- the five equipment statuses -- on the parts the author
4
+ * picks, by the legend role `twin-status`. All of it is made from the contract; the scene adds no behaviour.
5
+ */
6
+ export const OPERABLE = twinCapability({
7
+ key: 'operable',
8
+ label: { ko: '운영 상태', en: 'Operable' },
9
+ note: {
10
+ ko: '트윈이 관측한 설비 상태(가동 · 준비 · 고장 · 대기 · 계획정지)를 선택한 부품의 색으로 표시합니다. 색은 설비 상태 범례를 따릅니다.',
11
+ en: 'Shows the equipment status the twin observes (busy, setup, down, idle, planned stop) as the colour of the parts you pick, by the equipment status legend.'
12
+ },
13
+ version: '3',
14
+ /* 설비 상태 배지 — 피규어 위 */
15
+ cards: [{ id: 'status', anchor: 'top', label: { ko: '설비 상태', en: 'Equipment status' } }]
16
+ });
@@ -0,0 +1,30 @@
1
+ /** One item as the location's payload carries it (headless-twin `entity-delta`). */
2
+ export interface TwinLocationItem {
3
+ epc: string;
4
+ /** The part of a lot, when one lot lies in more than one part (ops-contract `ItemState.subLotId`). */
5
+ subLotId?: string;
6
+ itemType?: string;
7
+ status?: string;
8
+ }
9
+ /** The id an item is held by: the part of a lot when it has one, else its epc (ops-contract `ItemState.subLotId`). */
10
+ export declare const twinItemId: (item: TwinLocationItem) => string;
11
+ /** One record a holder reconciles its items by (things-scene `SlotRecord`): where it is, its id, type and state. */
12
+ export interface TwinItemRecord {
13
+ slotId: string;
14
+ itemId: string;
15
+ itemType?: string;
16
+ itemState: {
17
+ id: string;
18
+ status?: string;
19
+ };
20
+ }
21
+ /**
22
+ * The location's items as the records a figure holds them by: in the payload's order, into the figure's places one after
23
+ * another, each up to its capacity (a place with no capacity takes the rest). What no place has room for is held with no
24
+ * place -- kept, not dropped, so the figure says what it holds.
25
+ */
26
+ export declare function twinItemRecords(items: readonly TwinLocationItem[], places: ReadonlyArray<{
27
+ id: string;
28
+ maxCount?: number;
29
+ }>): TwinItemRecord[];
30
+ export declare const STORABLE: import("@hatiolab/figure-model").FigureCapabilityDescriptor;
@@ -0,0 +1,45 @@
1
+ import { twinCapability } from "./generate.js";
2
+ /** The id an item is held by: the part of a lot when it has one, else its epc (ops-contract `ItemState.subLotId`). */
3
+ export const twinItemId = (item) => item.subLotId ?? item.epc;
4
+ /**
5
+ * The location's items as the records a figure holds them by: in the payload's order, into the figure's places one after
6
+ * another, each up to its capacity (a place with no capacity takes the rest). What no place has room for is held with no
7
+ * place -- kept, not dropped, so the figure says what it holds.
8
+ */
9
+ export function twinItemRecords(items, places) {
10
+ let at = 0;
11
+ let used = 0;
12
+ return items
13
+ .filter(item => item?.epc)
14
+ .map(item => {
15
+ while (at < places.length && typeof places[at].maxCount === 'number' && used >= places[at].maxCount) {
16
+ at++;
17
+ used = 0;
18
+ }
19
+ used++;
20
+ const id = twinItemId(item);
21
+ return {
22
+ slotId: places[at]?.id ?? '',
23
+ itemId: id,
24
+ ...(item.itemType ? { itemType: item.itemType } : {}),
25
+ itemState: { id, ...(item.status !== undefined ? { status: item.status } : {}) }
26
+ };
27
+ });
28
+ }
29
+ export const STORABLE = twinCapability({
30
+ key: 'storable',
31
+ label: { ko: '보관', en: 'Storable' },
32
+ note: {
33
+ ko: '트윈이 관측한 이 자리의 물품을 피규어의 적재 위치에 놓습니다. 물품의 모양은 사업장의 아이템 타입 표가 정합니다.',
34
+ en: 'Puts the items the twin observes at this location in the figure\'s places. How an item looks is set by the workspace\'s item type table.'
35
+ },
36
+ version: '2',
37
+ needs: [
38
+ ['Holdable', 'FlowNode'],
39
+ ['Capacity', 'FlowNode']
40
+ ],
41
+ moreData: ['items'],
42
+ takesItems: true,
43
+ /* 점유 게이지 — 피규어 아래(상태 배지와 겹치지 않게) */
44
+ cards: [{ id: 'occupancy', anchor: 'bottom', label: { ko: '점유', en: 'Occupancy' } }]
45
+ });