@operato/ops-contract 0.9.40 → 0.9.41

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.
package/dist/erp.d.ts CHANGED
@@ -149,6 +149,60 @@ export declare function materialMovementKey(e: Pick<ProductionPerformanceEntry,
149
149
  * 거절 이유를 목록으로 낸다. 첫 번째에서 멈추면 사람이 한 번에 하나씩 고치게 된다.
150
150
  */
151
151
  export declare function validatePerformance(e: ProductionPerformanceEntry, nowMs: number): string[];
152
+ /**
153
+ * ERP 에 앉아 있는 실적 한 줄 — **되읽은 것**이다.
154
+ *
155
+ * 사람이 반영하는 ERP(`traits.posting: 'manual-export'`)는 우리가 내보낸 줄이 실제로 앉았는지 이것으로만 안다.
156
+ * API 로 올리는 ERP 에서도 대사에 쓴다. 우리 실적과 짝짓는 것은 부르는 쪽(MES)의 함수 하나가 한다 — 여기는
157
+ * ERP 가 가진 사실만 옮긴다. 짝이 없거나 둘 이상이면 짐작하지 않는다.
158
+ */
159
+ export interface ErpPerformanceRecord {
160
+ /** ERP 의 오더번호. */
161
+ orderId: string;
162
+ operationId?: string;
163
+ goodQuantity: number;
164
+ scrapQuantity?: number;
165
+ uom: string;
166
+ /** ERP 가 그 실적을 앉힌 날짜 · 시각(원문 그대로). */
167
+ postedAt?: ISOTime;
168
+ /** ERP 의 문서 번호 — 있으면 짝이 맞은 뒤 우리 기록에 남는다. */
169
+ documentRef?: string;
170
+ /**
171
+ * ERP 가 보존하는 칸(비고 등)에 실려 돌아온 우리 멱등 키(`performanceKey`). 있으면 짝짓기는 이것으로 한다.
172
+ * ERP 가 그런 칸을 갖는지는 어댑터가 확인해 둔다 — 없으면 비운다(지어내지 않는다).
173
+ */
174
+ carriedKey?: string;
175
+ }
176
+ /** ERP 에 있는 재고 한 줄 — 되읽은 것. */
177
+ export interface ErpInventoryRecord {
178
+ materialDefinitionId: string;
179
+ quantity: number;
180
+ uom: string;
181
+ site?: string;
182
+ location?: string;
183
+ lot?: string;
184
+ /** 그 수량이 언제 기준인가(원문 그대로). */
185
+ asOf?: ISOTime;
186
+ }
187
+ /** 되읽기의 범위. 빠진 칸은 「제한 없음」이 아니라 어댑터가 정한 창이다. */
188
+ export interface ErpReadQuery {
189
+ since?: ISOTime;
190
+ orderIds?: string[];
191
+ }
192
+ /**
193
+ * 사람이 ERP 에 붙여 넣거나 올릴 실적 묶음.
194
+ *
195
+ * ERP 마다 붙여넣기 열 순서 · 날짜 모양이 다르므로 내용은 어댑터가 만든다. 줄마다 우리 멱등 키를 함께 돌려줘서
196
+ * 부르는 쪽이 「내보냄 · 확인 대기」로 적을 줄을 안다 — 내보냈다고 올라간 것이 아니다.
197
+ */
198
+ export interface ErpExport {
199
+ fileName: string;
200
+ /** `text/tab-separated-values` · `text/csv` 처럼. */
201
+ mediaType: string;
202
+ body: string;
203
+ /** 이 묶음에 든 실적의 멱등 키, 줄 순서대로. */
204
+ keys: string[];
205
+ }
152
206
  /**
153
207
  * 잘못 올린 실적을 되돌리는 요청 — **삭제가 아니라 역분개다.**
154
208
  *
@@ -216,6 +270,18 @@ export interface ErpAdapter {
216
270
  reversePerformance?(cfg: ErpConfig, reversal: PerformanceReversal, key: string): Promise<ErpOutcome<ErpDocumentRef>>;
217
271
  /** 마스터를 당긴다 — 구조는 밀지 않고 당겨 간다(사실과 다른 규율). */
218
272
  readMaster?(cfg: ErpConfig, axis: ErpMasterAxis): Promise<ErpOutcome<unknown[]>>;
273
+ /**
274
+ * 사람이 반영할 실적 묶음을 만든다 — `traits.posting: 'manual-export'` 인 ERP 의 「올리기」다.
275
+ * 값을 바꾸지 않는다. 사람이 반영했는지는 `readPerformance` 로 되읽어야 안다.
276
+ */
277
+ exportPerformance?(cfg: ErpConfig, entries: {
278
+ entry: ProductionPerformanceEntry;
279
+ key: string;
280
+ }[]): Promise<ErpOutcome<ErpExport>>;
281
+ /** ERP 에 앉은 실적을 되읽는다(결정 2). */
282
+ readPerformance?(cfg: ErpConfig, query?: ErpReadQuery): Promise<ErpOutcome<ErpPerformanceRecord[]>>;
283
+ /** ERP 의 재고를 되읽는다(결정 2). */
284
+ readInventory?(cfg: ErpConfig, query?: ErpReadQuery): Promise<ErpOutcome<ErpInventoryRecord[]>>;
219
285
  }
220
286
  /**
221
287
  * ERP 마다 갈리는 성질.
@@ -245,9 +311,19 @@ export interface ErpTraits {
245
311
  * 기다리지 않는다.
246
312
  */
247
313
  reversal: 'api' | 'manual' | 'none';
314
+ /**
315
+ * 실적이 어떻게 ERP 에 들어가나 (ADR-0110 결정 1).
316
+ *
317
+ * api 우리가 부르면 앉는다 — `postPerformance`
318
+ * manual-export 사람이 ERP 화면에 붙여 넣거나 올린다 — 우리는 `exportPerformance` 로 묶음을 만들 뿐이다.
319
+ * 국내 중소 ERP 에 흔하다(미라텍의 SystemEver: 작업실적에 파일 업로드도 공식 API 도 없다)
320
+ *
321
+ * 이 칸이 없으면 내보낸 줄을 올라간 것으로 적는 거짓이 생긴다. 그래서 필수다.
322
+ */
323
+ posting: 'api' | 'manual-export';
248
324
  }
249
325
  /** 이 ERP 가 할 수 있다고 선언하는 것. 구현이 없으면 없는 것으로 읽는다. */
250
- export declare const ERP_CAPABILITY: readonly ["schedule", "performance", "material-movement", "reversal", "master"];
326
+ export declare const ERP_CAPABILITY: readonly ["schedule", "performance", "material-movement", "reversal", "master", "performance-read", "inventory-read"];
251
327
  export type ErpCapability = (typeof ERP_CAPABILITY)[number];
252
328
  /** 당겨 올 수 있는 마스터의 축. */
253
329
  export declare const ERP_MASTER_AXIS: readonly ["product", "bom", "routing", "work-center"];
package/dist/erp.js CHANGED
@@ -107,7 +107,15 @@ export function reversalKey(performanceKey) {
107
107
  return `${performanceKey}|reversal`;
108
108
  }
109
109
  /** 이 ERP 가 할 수 있다고 선언하는 것. 구현이 없으면 없는 것으로 읽는다. */
110
- export const ERP_CAPABILITY = ['schedule', 'performance', 'material-movement', 'reversal', 'master'];
110
+ export const ERP_CAPABILITY = [
111
+ 'schedule',
112
+ 'performance',
113
+ 'material-movement',
114
+ 'reversal',
115
+ 'master',
116
+ 'performance-read',
117
+ 'inventory-read'
118
+ ];
111
119
  /** 당겨 올 수 있는 마스터의 축. */
112
120
  export const ERP_MASTER_AXIS = ['product', 'bom', 'routing', 'work-center'];
113
121
  /**
@@ -117,12 +125,16 @@ export const ERP_MASTER_AXIS = ['product', 'bom', 'routing', 'work-center'];
117
125
  * 화면에 서지 않는다.
118
126
  */
119
127
  export function erpCapabilityGaps(adapter) {
128
+ const manual = adapter.traits?.posting === 'manual-export';
120
129
  const needs = {
121
130
  schedule: 'readSchedules',
122
- performance: 'postPerformance',
131
+ /* 사람이 반영하는 ERP 에서 「실적을 올린다」는 묶음을 만드는 것이다. */
132
+ performance: manual ? 'exportPerformance' : 'postPerformance',
123
133
  'material-movement': 'postMaterialMovement',
124
134
  reversal: 'reversePerformance',
125
- master: 'readMaster'
135
+ master: 'readMaster',
136
+ 'performance-read': 'readPerformance',
137
+ 'inventory-read': 'readInventory'
126
138
  };
127
139
  const gaps = [];
128
140
  for (const cap of adapter.capabilities ?? []) {
@@ -141,5 +153,23 @@ export function erpCapabilityGaps(adapter) {
141
153
  if (adapter.traits?.materialWithPerformance && typeof adapter.postMaterialMovement === 'function') {
142
154
  gaps.push('traits.materialWithPerformance 가 참인데 postMaterialMovement 가 따로 있다 — 소비가 두 번 앉는다');
143
155
  }
156
+ /*
157
+ * 사람이 반영하는 ERP 에 부르면 앉는 문이 있으면, 펌프가 그 문으로 「올라갔다」고 적는다 — 아무것도 안 앉았는데
158
+ * (ADR-0110 결정 1 가). 실적과 함께 앉는 자재도 같다.
159
+ */
160
+ if (manual) {
161
+ if (typeof adapter.postPerformance === 'function') {
162
+ gaps.push('traits.posting 이 manual-export 인데 postPerformance 가 있다 — 부르면 앉는 ERP 가 아니다');
163
+ }
164
+ if (typeof adapter.postMaterialMovement === 'function') {
165
+ gaps.push('traits.posting 이 manual-export 인데 postMaterialMovement 가 있다');
166
+ }
167
+ if (adapter.capabilities?.includes('material-movement')) {
168
+ gaps.push('traits.posting 이 manual-export 인데 material-movement 능력을 선언했다');
169
+ }
170
+ }
171
+ if (adapter.traits?.posting !== 'api' && adapter.traits?.posting !== 'manual-export') {
172
+ gaps.push('traits.posting 이 없다 — api 인지 manual-export 인지 말해야 펌프가 내보낸 줄을 올라간 것으로 적지 않는다');
173
+ }
144
174
  return gaps;
145
175
  }
@@ -4987,15 +4987,27 @@ function reversalKey(performanceKey2) {
4987
4987
  if (!String(performanceKey2 ?? "").trim()) throw new Error("reversalKey: \uB418\uB3CC\uB9B4 \uC2E4\uC801\uC758 \uD0A4\uAC00 \uC5C6\uB2E4");
4988
4988
  return `${performanceKey2}|reversal`;
4989
4989
  }
4990
- var ERP_CAPABILITY = ["schedule", "performance", "material-movement", "reversal", "master"];
4990
+ var ERP_CAPABILITY = [
4991
+ "schedule",
4992
+ "performance",
4993
+ "material-movement",
4994
+ "reversal",
4995
+ "master",
4996
+ "performance-read",
4997
+ "inventory-read"
4998
+ ];
4991
4999
  var ERP_MASTER_AXIS = ["product", "bom", "routing", "work-center"];
4992
5000
  function erpCapabilityGaps(adapter) {
5001
+ const manual = adapter.traits?.posting === "manual-export";
4993
5002
  const needs = {
4994
5003
  schedule: "readSchedules",
4995
- performance: "postPerformance",
5004
+ /* 사람이 반영하는 ERP 에서 「실적을 올린다」는 묶음을 만드는 것이다. */
5005
+ performance: manual ? "exportPerformance" : "postPerformance",
4996
5006
  "material-movement": "postMaterialMovement",
4997
5007
  reversal: "reversePerformance",
4998
- master: "readMaster"
5008
+ master: "readMaster",
5009
+ "performance-read": "readPerformance",
5010
+ "inventory-read": "readInventory"
4999
5011
  };
5000
5012
  const gaps = [];
5001
5013
  for (const cap of adapter.capabilities ?? []) {
@@ -5011,6 +5023,20 @@ function erpCapabilityGaps(adapter) {
5011
5023
  if (adapter.traits?.materialWithPerformance && typeof adapter.postMaterialMovement === "function") {
5012
5024
  gaps.push("traits.materialWithPerformance \uAC00 \uCC38\uC778\uB370 postMaterialMovement \uAC00 \uB530\uB85C \uC788\uB2E4 \u2014 \uC18C\uBE44\uAC00 \uB450 \uBC88 \uC549\uB294\uB2E4");
5013
5025
  }
5026
+ if (manual) {
5027
+ if (typeof adapter.postPerformance === "function") {
5028
+ gaps.push("traits.posting \uC774 manual-export \uC778\uB370 postPerformance \uAC00 \uC788\uB2E4 \u2014 \uBD80\uB974\uBA74 \uC549\uB294 ERP \uAC00 \uC544\uB2C8\uB2E4");
5029
+ }
5030
+ if (typeof adapter.postMaterialMovement === "function") {
5031
+ gaps.push("traits.posting \uC774 manual-export \uC778\uB370 postMaterialMovement \uAC00 \uC788\uB2E4");
5032
+ }
5033
+ if (adapter.capabilities?.includes("material-movement")) {
5034
+ gaps.push("traits.posting \uC774 manual-export \uC778\uB370 material-movement \uB2A5\uB825\uC744 \uC120\uC5B8\uD588\uB2E4");
5035
+ }
5036
+ }
5037
+ if (adapter.traits?.posting !== "api" && adapter.traits?.posting !== "manual-export") {
5038
+ gaps.push("traits.posting \uC774 \uC5C6\uB2E4 \u2014 api \uC778\uC9C0 manual-export \uC778\uC9C0 \uB9D0\uD574\uC57C \uD38C\uD504\uAC00 \uB0B4\uBCF4\uB0B8 \uC904\uC744 \uC62C\uB77C\uAC04 \uAC83\uC73C\uB85C \uC801\uC9C0 \uC54A\uB294\uB2E4");
5039
+ }
5014
5040
  return gaps;
5015
5041
  }
5016
5042
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@operato/ops-contract",
3
- "version": "0.9.40",
3
+ "version": "0.9.41",
4
4
  "description": "Operations domain contract — the standard vocabulary that producers and readers agree on (EPCIS 2.0/GS1, ISA-95, IEC 61850/ISO 50001). Types, guards, validation. No state, no engine.",
5
5
  "type": "module",
6
6
  "main": "./dist-cjs/index.cjs",