Download mock-app/modules/o2c/extensions.js from EnergyVenom/patchwise-agent-studio: direct link, hf CLI and curl.
- Browser
- Download file 2.95 kB
-
https://huggingface.co/spaces/EnergyVenom/patchwise-agent-studio/resolve/main/mock-app/modules/o2c/extensions.js
- Command line
-
hf download hf://spaces/EnergyVenom/patchwise-agent-studio/mock-app/modules/o2c/extensions.js
-
curl -L -o extensions.js https://huggingface.co/spaces/EnergyVenom/patchwise-agent-studio/resolve/main/mock-app/modules/o2c/extensions.js
2.95 kB
| ; | |
| /* | |
| * MOCK Order Management extension + flexfield inventory (O2C-INT-003 stand-in; DR-O2C-INT-003 says the mock "should pre-seed an | |
| * equivalent object exposing the same output keys": om_extensions, page_extensions). NOT Oracle software. The extensions below are | |
| * SYNTHETIC examples that really execute in the mock order flow; the pod's real inventory and count are POD-REQUIRED. | |
| * Each entry declares how to trigger it and the observable effect, so a test can iterate the inventory generically. | |
| */ | |
| const { err } = require('../../core/errors'); | |
| const OM_EXTENSIONS = [ | |
| { name: 'ZZ_DEFAULT_SHIP_INSTRUCTIONS (MOCK)', event: 'On Save', kind: 'default', | |
| trigger: {}, effect: { kind: 'attribute', label: 'Shipping Instructions', value: 'ZZ Deliver to dock 3 (MOCK)' } }, | |
| { name: 'ZZ_PARTNER_ORDER_NEEDS_PO (MOCK)', event: 'On Start of Submission Request', kind: 'validation', | |
| trigger: { salesChannel: 'Partner', customerPO: '' }, effect: { kind: 'message', text: 'ZZ: Partner orders require a customer purchase order (MOCK extension).' } }, | |
| { name: 'ZZ_LOG_SUBMISSION (MOCK)', event: 'On End of Submission Request', kind: 'log', | |
| trigger: {}, effect: { kind: 'log', table: 'Extension Log', text: 'ZZ_LOG_SUBMISSION (MOCK): submission recorded' } }, | |
| ]; | |
| const PAGE_EXTENSIONS = [ | |
| { name: 'ZZ Sales Channel (MOCK)', type: 'flexfield', context: 'Order Header', field: 'salesChannel', label: 'ZZ Sales Channel (MOCK)', values: ['Direct', 'Partner'] }, | |
| ]; | |
| const inventory = () => ({ source: 'MOCK (synthetic; pod inventory is POD-REQUIRED)', om_extensions: OM_EXTENSIONS, page_extensions: PAGE_EXTENSIONS }); | |
| // Hooks called by store.js. Disabled extensions (e.g. by a mutation check) simply do not run. | |
| let disabled = new Set((process.env.MOCK_O2C_DISABLED_EXTENSIONS || '').split(',').filter(Boolean)); | |
| const on = (n) => !disabled.has(n); | |
| function onSave(o, b) { | |
| for (const f of PAGE_EXTENSIONS) if (b[f.field] !== undefined && b[f.field] !== '') { | |
| if (!f.values.includes(b[f.field])) throw err(400, 'VALIDATION', `${f.label}: value ${b[f.field]} is not valid.`); | |
| o.ext = { ...(o.ext || {}), [f.field]: b[f.field] }; | |
| } | |
| if (on('ZZ_DEFAULT_SHIP_INSTRUCTIONS (MOCK)') && !o.shippingInstructions) o.shippingInstructions = OM_EXTENSIONS[0].effect.value; | |
| o.extensionLog = o.extensionLog || []; | |
| } | |
| function onStartOfSubmission(o) { | |
| if (on('ZZ_PARTNER_ORDER_NEEDS_PO (MOCK)') && (o.ext || {}).salesChannel === 'Partner' && !o.customerPO) throw err(400, 'VALIDATION', OM_EXTENSIONS[1].effect.text); | |
| } | |
| function onEndOfSubmission(o) { | |
| if (on('ZZ_LOG_SUBMISSION (MOCK)')) (o.extensionLog = o.extensionLog || []).push({ extension: 'ZZ_LOG_SUBMISSION (MOCK)', event: 'On End of Submission Request', message: OM_EXTENSIONS[2].effect.text, at: new Date().toISOString() }); | |
| } | |
| module.exports = { inventory, PAGE_EXTENSIONS, onSave, onStartOfSubmission, onEndOfSubmission }; | |