Initial commit: core-prestashop module v1.1.1
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
const { DB } = require('@orbito/api-lib');
|
||||
const { customAlphabet } = require('nanoid');
|
||||
const alphabet = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
||||
|
||||
const schema = new DB.Schema('shop_config', {
|
||||
companyId: { type: 'ObjectId' },
|
||||
|
||||
apiUrl: { type: 'string', optional: true },
|
||||
apiKey: { type: 'string', optional: true },
|
||||
shopName: { type: 'string', optional: true },
|
||||
versionCode: { type: 'string', optional: true },
|
||||
|
||||
// shopPrefix: prefiks używany w uniqueId zamówienia (np. "PL" -> "PL:389218").
|
||||
// Na razie tylko przechowywany; nie jest jeszcze wpinany w format uniqueId w imporcie.
|
||||
shopPrefix: { type: 'string', optional: true },
|
||||
|
||||
// orderStatus: domyślny status gdy brak mapowania PS → Orbito
|
||||
orderStatus: { type: 'ObjectId', optional: true },
|
||||
|
||||
// statusMapping: [{ psStateId: 2, orbitoStatusId: "..." }]
|
||||
statusMapping: {
|
||||
type: 'array',
|
||||
items: { type: 'object' },
|
||||
optional: true,
|
||||
default: []
|
||||
},
|
||||
|
||||
// Podgląd statusów PS (cache do formularza konfiguracji)
|
||||
psStatesPreview: { type: 'string', optional: true, default: '' },
|
||||
|
||||
// Lista statusów PS pobrana z API (do UI mapowania)
|
||||
psStates: {
|
||||
type: 'array',
|
||||
items: { type: 'object' },
|
||||
optional: true,
|
||||
default: []
|
||||
},
|
||||
|
||||
lastOrderId: { type: 'number', optional: true },
|
||||
|
||||
createdAt: { type: 'date', default: () => new Date() },
|
||||
isRemoved: { type: 'boolean', default: false }
|
||||
});
|
||||
|
||||
// Pre-validate hook - calculate summary and update derived fields
|
||||
schema.pre('validate', async function(data) {
|
||||
});
|
||||
|
||||
schema.post('create', function(data) {
|
||||
// Hook for post-create actions (e.g., emit events, notifications)
|
||||
});
|
||||
|
||||
DB.createIndex('shop_config', { companyId: 1 });
|
||||
|
||||
module.exports = schema;
|
||||
Reference in New Issue
Block a user