@fctc/interface-logic 4.3.9 → 4.4.1

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/services.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  // src/services/action-service/index.ts
2
- import { useCallback as useCallback32 } from "react";
2
+ import { useCallback as useCallback33 } from "react";
3
3
 
4
4
  // src/constants/api/uri-constant.ts
5
5
  var UriConstants = /* @__PURE__ */ ((UriConstants2) => {
@@ -50,6 +50,58 @@ var UriConstants = /* @__PURE__ */ ((UriConstants2) => {
50
50
  // src/utils/format.ts
51
51
  import moment from "moment";
52
52
 
53
+ // src/constants/model/model-constant.ts
54
+ var LoadDataModel = /* @__PURE__ */ ((LoadDataModel2) => {
55
+ LoadDataModel2["ACCOUNT_CASH_ROUNDING"] = "account.cash.rounding";
56
+ LoadDataModel2["ACCOUNT_FISCAL_POSITION"] = "account.fiscal.position";
57
+ LoadDataModel2["ACCOUNT_FISCAL_POSITION_TAX"] = "account.fiscal.position.tax";
58
+ LoadDataModel2["ACCOUNT_TAX"] = "account.tax";
59
+ LoadDataModel2["ACCOUNT_TAX_GROUP"] = "account.tax.group";
60
+ LoadDataModel2["DECIMAL_PRECISION"] = "decimal.precision";
61
+ LoadDataModel2["IR_MODULE_MODULE"] = "ir.module.module";
62
+ LoadDataModel2["IR_UI_VIEW"] = "ir.ui.view";
63
+ LoadDataModel2["POS_BILL"] = "pos.bill";
64
+ LoadDataModel2["POS_CATEGORY"] = "pos.category";
65
+ LoadDataModel2["POS_CONFIG"] = "pos.config";
66
+ LoadDataModel2["POS_NOTE"] = "pos.note";
67
+ LoadDataModel2["POS_ORDER"] = "pos.order";
68
+ LoadDataModel2["POS_ORDER_LINE"] = "pos.order.line";
69
+ LoadDataModel2["POS_PACK_OPERATION_LOT"] = "pos.pack.operation.lot";
70
+ LoadDataModel2["POS_PAYMENT"] = "pos.payment";
71
+ LoadDataModel2["POS_PAYMENT_METHOD"] = "pos.payment.method";
72
+ LoadDataModel2["POS_PRINTER"] = "pos.printer";
73
+ LoadDataModel2["POS_SESSION"] = "pos.session";
74
+ LoadDataModel2["POS_PREPARATION_DISPLAY_DISPLAY"] = "pos_preparation_display.display";
75
+ LoadDataModel2["PRODUCT_ATTRIBUTE"] = "product.attribute";
76
+ LoadDataModel2["PRODUCT_ATTRIBUTE_CUSTOM_VALUE"] = "product.attribute.custom.value";
77
+ LoadDataModel2["PRODUCT_CATEGORY"] = "product.category";
78
+ LoadDataModel2["PRODUCT_COMBO"] = "product.combo";
79
+ LoadDataModel2["PRODUCT_COMBO_ITEM"] = "product.combo.item";
80
+ LoadDataModel2["PRODUCT_PACKAGING"] = "product.packaging";
81
+ LoadDataModel2["PRODUCT_PRICELIST"] = "product.pricelist";
82
+ LoadDataModel2["PRODUCT_PRICELIST_ITEM"] = "product.pricelist.item";
83
+ LoadDataModel2["PRODUCT_PRODUCT"] = "product.product";
84
+ LoadDataModel2["PRODUCT_TAG"] = "product.tag";
85
+ LoadDataModel2["PRODUCT_TEMPLATE_ATTRIBUTE_LINE"] = "product.template.attribute.line";
86
+ LoadDataModel2["PRODUCT_TEMPLATE_ATTRIBUTE_VALUE"] = "product.template.attribute.value";
87
+ LoadDataModel2["RES_COMPANY"] = "res.company";
88
+ LoadDataModel2["RES_COUNTRY"] = "res.country";
89
+ LoadDataModel2["RES_COUNTRY_STATE"] = "res.country.state";
90
+ LoadDataModel2["RES_CURRENCY"] = "res.currency";
91
+ LoadDataModel2["RES_LANG"] = "res.lang";
92
+ LoadDataModel2["RES_PARTNER"] = "res.partner";
93
+ LoadDataModel2["RES_USERS"] = "res.users";
94
+ LoadDataModel2["STOCK_PICKING_TYPE"] = "stock.picking.type";
95
+ LoadDataModel2["UOM_CATEGORY"] = "uom.category";
96
+ LoadDataModel2["UOM_UOM"] = "uom.uom";
97
+ LoadDataModel2["LOYALTY_PROGRAM"] = "loyalty.program";
98
+ LoadDataModel2["LOYALTY_RULE"] = "loyalty.rule";
99
+ LoadDataModel2["RESTAURANT_TABLE"] = "restaurant.table";
100
+ LoadDataModel2["RESTAURANT_FLOOR"] = "restaurant.floor";
101
+ LoadDataModel2["POS_MAKE_PAYMENT"] = "pos.make.payment";
102
+ return LoadDataModel2;
103
+ })(LoadDataModel || {});
104
+
53
105
  // src/utils/domain/py_tokenizer.ts
54
106
  var TokenizerError = class extends Error {
55
107
  };
@@ -2178,13 +2230,6 @@ function cleanObject(obj) {
2178
2230
  }
2179
2231
  return result;
2180
2232
  }
2181
- var extractIdFromDomain = (domain) => {
2182
- if (!domain || !Array.isArray(domain)) return null;
2183
- const idCond = domain.find(
2184
- ([field, operator]) => field === "id" && operator === "="
2185
- );
2186
- return idCond ? Number(idCond[2]) : null;
2187
- };
2188
2233
 
2189
2234
  // src/provider/react-query-provider.tsx
2190
2235
  import { useState as useState2 } from "react";
@@ -2237,7 +2282,7 @@ var initialState2 = {
2237
2282
  lang: "vi_VN",
2238
2283
  tz: "Asia/Saigon"
2239
2284
  },
2240
- isLocalMode: false
2285
+ isSupaMode: false
2241
2286
  };
2242
2287
  var envSlice = createSlice2({
2243
2288
  name: "env",
@@ -2844,7 +2889,7 @@ function useEnv() {
2844
2889
  }
2845
2890
 
2846
2891
  // src/provider/service-provider.tsx
2847
- import { createContext as createContext2, useContext as useContext2 } from "react";
2892
+ import { createContext as createContext3, useContext as useContext3 } from "react";
2848
2893
 
2849
2894
  // src/hooks/auth/use-forgot-password.ts
2850
2895
  import { useMutation } from "@tanstack/react-query";
@@ -3148,544 +3193,7 @@ var getASessionService = (env) => {
3148
3193
 
3149
3194
  // src/services/pos-service/add-entity.ts
3150
3195
  import { useCallback as useCallback4 } from "react";
3151
-
3152
- // src/services/filesystem-service/file-service.ts
3153
- import { Directory, Encoding, Filesystem } from "@capacitor/filesystem";
3154
- var fileService = {
3155
- read: async (path) => {
3156
- try {
3157
- const res = await Filesystem.readFile({
3158
- path,
3159
- directory: Directory.Data,
3160
- encoding: Encoding.UTF8
3161
- });
3162
- if (typeof res.data === "string") return res.data;
3163
- if (res.data instanceof Blob) return await res.data.text();
3164
- return null;
3165
- } catch {
3166
- return null;
3167
- }
3168
- },
3169
- write: async (path, data) => {
3170
- await Filesystem.writeFile({
3171
- path,
3172
- data,
3173
- directory: Directory.Data,
3174
- encoding: Encoding.UTF8,
3175
- recursive: true
3176
- });
3177
- },
3178
- writeAtomic: async (path, data) => {
3179
- const tempPath = path + ".tmp";
3180
- await Filesystem.writeFile({
3181
- path: tempPath,
3182
- data,
3183
- directory: Directory.Data,
3184
- encoding: Encoding.UTF8,
3185
- recursive: true
3186
- });
3187
- try {
3188
- await Filesystem.deleteFile({
3189
- path,
3190
- directory: Directory.Data
3191
- });
3192
- } catch {
3193
- }
3194
- await Filesystem.rename({
3195
- from: tempPath,
3196
- to: path,
3197
- directory: Directory.Data
3198
- });
3199
- },
3200
- delete: async (path) => {
3201
- try {
3202
- await Filesystem.deleteFile({
3203
- path,
3204
- directory: Directory.Data
3205
- });
3206
- } catch {
3207
- }
3208
- },
3209
- exists: async (path) => {
3210
- try {
3211
- await Filesystem.stat({
3212
- path,
3213
- directory: Directory.Data
3214
- });
3215
- return true;
3216
- } catch {
3217
- return false;
3218
- }
3219
- },
3220
- mkdir: async (path) => {
3221
- try {
3222
- await Filesystem.mkdir({
3223
- path,
3224
- directory: Directory.Data,
3225
- recursive: true
3226
- });
3227
- } catch (e) {
3228
- if (!String(e?.message).includes("Exists")) {
3229
- throw e;
3230
- }
3231
- }
3232
- },
3233
- list: async (path) => {
3234
- return Filesystem.readdir({
3235
- path,
3236
- directory: Directory.Data
3237
- });
3238
- },
3239
- getUri: async (path) => {
3240
- return Filesystem.getUri({
3241
- path,
3242
- directory: Directory.Data
3243
- });
3244
- }
3245
- };
3246
-
3247
- // src/services/filesystem-service/json-worker.ts
3248
- function createWorkerBlob() {
3249
- const workerCode = `
3250
- self.addEventListener("message", async (ev) => {
3251
- const { id, cmd, payload } = ev.data;
3252
- try {
3253
- if (cmd === "parse") {
3254
- const parsed = JSON.parse(payload);
3255
- self.postMessage({ id, ok: true, result: parsed });
3256
- } else if (cmd === "stringify") {
3257
- const str = JSON.stringify(payload);
3258
- self.postMessage({ id, ok: true, result: str });
3259
- }
3260
- } catch (err) {
3261
- self.postMessage({ id, ok: false, error: err?.message || String(err) });
3262
- }
3263
- });
3264
- `;
3265
- const blob = new Blob([workerCode], { type: "application/javascript" });
3266
- return URL.createObjectURL(blob);
3267
- }
3268
- function spawnParseWorker(raw) {
3269
- return new Promise((resolve, reject) => {
3270
- const workerUrl = createWorkerBlob();
3271
- const worker = new Worker(workerUrl);
3272
- const id = Math.random().toString(36).slice(2);
3273
- worker.onmessage = (ev) => {
3274
- const { ok, result, error } = ev.data;
3275
- if (ok) {
3276
- resolve(result);
3277
- } else {
3278
- reject(new Error(error));
3279
- }
3280
- URL.revokeObjectURL(workerUrl);
3281
- worker.terminate();
3282
- };
3283
- worker.onerror = (err) => {
3284
- reject(err);
3285
- URL.revokeObjectURL(workerUrl);
3286
- worker.terminate();
3287
- };
3288
- worker.postMessage({ id, cmd: "parse", payload: raw });
3289
- });
3290
- }
3291
- function spawnStringifyWorker(obj) {
3292
- return new Promise((resolve, reject) => {
3293
- const workerUrl = createWorkerBlob();
3294
- const worker = new Worker(workerUrl);
3295
- worker.onmessage = (ev) => {
3296
- const { ok, result, error } = ev.data;
3297
- if (ok) resolve(result);
3298
- else reject(new Error(error));
3299
- URL.revokeObjectURL(workerUrl);
3300
- worker.terminate();
3301
- };
3302
- worker.onerror = (err) => {
3303
- reject(err);
3304
- URL.revokeObjectURL(workerUrl);
3305
- worker.terminate();
3306
- };
3307
- worker.postMessage({ cmd: "stringify", payload: obj });
3308
- });
3309
- }
3310
-
3311
- // src/services/filesystem-service/manifest.ts
3312
- var MANIFEST_PATH = "pos/manifest.json";
3313
- var MANIFEST_BAK_PATH = "pos/manifest.bak.json";
3314
- async function writeManifest(manifest) {
3315
- const oldRaw = await fileService.read(MANIFEST_PATH);
3316
- if (oldRaw !== null) {
3317
- await fileService.writeAtomic(MANIFEST_BAK_PATH, oldRaw);
3318
- }
3319
- await fileService.writeAtomic(MANIFEST_PATH, JSON.stringify(manifest));
3320
- try {
3321
- await fileService.delete(MANIFEST_BAK_PATH);
3322
- } catch {
3323
- }
3324
- }
3325
-
3326
- // src/services/filesystem-service/import-snapshot.ts
3327
- var DATA_DIR = "pos";
3328
- var MODELS_DIR = `${DATA_DIR}/models`;
3329
- var MODELS_META_DIR = `${DATA_DIR}/models_meta`;
3330
- var importSnapshot = async ({ data, onProgress }) => {
3331
- onProgress?.(1, "Parsing snapshot");
3332
- const parsed = await spawnParseWorker(data);
3333
- const modelNames = Object.keys(parsed);
3334
- const total = modelNames.length;
3335
- const manifest = { version: (/* @__PURE__ */ new Date()).toISOString(), models: {} };
3336
- const TMP_PREFIX = `pos/data/tmp_import_${Date.now()}`;
3337
- await fileService.writeAtomic(`${TMP_PREFIX}/.marker`, "1");
3338
- let i = 0;
3339
- for (const model of modelNames) {
3340
- i++;
3341
- onProgress?.(
3342
- Math.round(i / total * 100),
3343
- `Processing ${model} (${i}/${total})`
3344
- );
3345
- const block = parsed[model];
3346
- const dataPart = block?.data ?? block ?? [];
3347
- const fields = block?.fields ?? [];
3348
- const relations = block?.relations ?? {};
3349
- const serialized = await spawnStringifyWorker(dataPart);
3350
- const tmpModelPath = `${TMP_PREFIX}/${encodeURIComponent(model)}.json`;
3351
- await fileService.writeAtomic(tmpModelPath, serialized);
3352
- const meta = {
3353
- fields,
3354
- relations,
3355
- count: Array.isArray(dataPart) ? dataPart.length : 0,
3356
- writtenAt: (/* @__PURE__ */ new Date()).toISOString()
3357
- };
3358
- const tmpMetaPath = `${TMP_PREFIX}/${encodeURIComponent(model)}.meta.json`;
3359
- await fileService.writeAtomic(tmpMetaPath, JSON.stringify(meta));
3360
- manifest.models[model] = {
3361
- file: `${MODELS_DIR}/${encodeURIComponent(model)}.json`,
3362
- metaFile: `${MODELS_META_DIR}/${encodeURIComponent(model)}.meta.json`,
3363
- count: meta.count,
3364
- updatedAt: meta.writtenAt
3365
- };
3366
- }
3367
- onProgress?.(95, "Committing import (moving files)");
3368
- for (const model of modelNames) {
3369
- const tmpModelPath = `${TMP_PREFIX}/${encodeURIComponent(model)}.json`;
3370
- const finalModelPath = `${MODELS_DIR}/${encodeURIComponent(model)}.json`;
3371
- const tmpMetaPath = `${TMP_PREFIX}/${encodeURIComponent(model)}.meta.json`;
3372
- const finalMetaPath = `${MODELS_META_DIR}/${encodeURIComponent(
3373
- model
3374
- )}.meta.json`;
3375
- const tmpRaw = await fileService.read(tmpModelPath);
3376
- if (tmpRaw !== null) await fileService.writeAtomic(finalModelPath, tmpRaw);
3377
- const tmpMetaRaw = await fileService.read(tmpMetaPath);
3378
- if (tmpMetaRaw !== null)
3379
- await fileService.writeAtomic(finalMetaPath, tmpMetaRaw);
3380
- onProgress?.(
3381
- 95 + Math.round(
3382
- (Object.keys(manifest.models).indexOf(model) + 1) / modelNames.length * 5
3383
- ),
3384
- `Committed ${model}`
3385
- );
3386
- }
3387
- await writeManifest(manifest);
3388
- try {
3389
- for (const model of modelNames) {
3390
- await fileService.delete(
3391
- `${TMP_PREFIX}/${encodeURIComponent(model)}.json`
3392
- );
3393
- await fileService.delete(
3394
- `${TMP_PREFIX}/${encodeURIComponent(model)}.meta.json`
3395
- );
3396
- }
3397
- await fileService.delete(`${TMP_PREFIX}/.marker`);
3398
- } catch (e) {
3399
- console.log("Failed to cleanup tmp import files:", e);
3400
- }
3401
- onProgress?.(100, "Import complete");
3402
- return manifest;
3403
- };
3404
- var import_snapshot_default = importSnapshot;
3405
-
3406
- // src/services/filesystem-service/memory-cache.ts
3407
- var MemoryCache = class {
3408
- map = /* @__PURE__ */ new Map();
3409
- get(k) {
3410
- const e = this.map.get(k);
3411
- if (!e) return null;
3412
- if (e.ttl && Date.now() - e.t > e.ttl) {
3413
- this.map.delete(k);
3414
- return null;
3415
- }
3416
- return e.value;
3417
- }
3418
- set(k, v, ttl = 5 * 60 * 1e3) {
3419
- this.map.set(k, { value: v, t: Date.now(), ttl });
3420
- }
3421
- del(k) {
3422
- this.map.delete(k);
3423
- }
3424
- clear() {
3425
- this.map.clear();
3426
- }
3427
- };
3428
- var memoryCache = new MemoryCache();
3429
-
3430
- // src/services/filesystem-service/model-loader.ts
3431
- var MODELS_DIR2 = "pos/models";
3432
- var MODELS_META_DIR2 = "pos/models_meta";
3433
- async function loadModelData(modelName, includeMeta = true) {
3434
- const key = `model:${modelName}:meta:${includeMeta}`;
3435
- const cached = memoryCache.get(key);
3436
- if (cached) return cached;
3437
- const dataPath = `${MODELS_DIR2}/${encodeURIComponent(modelName)}.json`;
3438
- const metaPath = `${MODELS_META_DIR2}/${encodeURIComponent(
3439
- modelName
3440
- )}.meta.json`;
3441
- const rawData = await fileService.read(dataPath);
3442
- if (!rawData) return null;
3443
- const parsedData = await spawnParseWorker(rawData);
3444
- const data = Array.isArray(parsedData) ? parsedData : [];
3445
- if (!includeMeta) {
3446
- const result2 = { data };
3447
- memoryCache.set(key, result2, 1e3 * 60 * 60);
3448
- return result2;
3449
- }
3450
- const rawMeta = await fileService.read(metaPath);
3451
- let fields = [];
3452
- let relations = {};
3453
- if (rawMeta) {
3454
- const parsedMeta = await spawnParseWorker(rawMeta);
3455
- fields = parsedMeta?.fields ?? [];
3456
- relations = parsedMeta?.relations ?? {};
3457
- }
3458
- const result = {
3459
- data,
3460
- fields,
3461
- relations
3462
- };
3463
- memoryCache.set(key, result, 1e3 * 60 * 60);
3464
- return result;
3465
- }
3466
- async function loadData(includeMeta = true) {
3467
- try {
3468
- const listResult = await fileService.list(MODELS_DIR2);
3469
- if (!listResult || !Array.isArray(listResult.files)) {
3470
- console.log("No models found");
3471
- return {};
3472
- }
3473
- const result = {};
3474
- for (const file of listResult.files) {
3475
- if (file.type !== "file") continue;
3476
- if (!file.name.endsWith(".json")) continue;
3477
- const fileName = file.name;
3478
- const modelName = fileName.replace(/\.json$/, "");
3479
- const dataPath = `${MODELS_DIR2}/${fileName}`;
3480
- const rawData = await fileService.read(dataPath);
3481
- if (!rawData) continue;
3482
- const parsedData = await spawnParseWorker(rawData);
3483
- const data = Array.isArray(parsedData) ? parsedData : [];
3484
- if (!includeMeta) {
3485
- result[modelName] = { data };
3486
- continue;
3487
- }
3488
- const metaPath = `${MODELS_META_DIR2}/${encodeURIComponent(
3489
- modelName
3490
- )}.meta.json`;
3491
- const rawMeta = await fileService.read(metaPath);
3492
- let fields = [];
3493
- let relations = {};
3494
- if (rawMeta) {
3495
- const parsedMeta = await spawnParseWorker(rawMeta);
3496
- fields = parsedMeta?.fields ?? [];
3497
- relations = parsedMeta?.relations ?? {};
3498
- }
3499
- result[modelName] = {
3500
- data,
3501
- fields,
3502
- relations
3503
- };
3504
- }
3505
- return result;
3506
- } catch (error) {
3507
- console.error("Error loading data:", error);
3508
- throw error;
3509
- }
3510
- }
3511
-
3512
- // src/services/filesystem-service/snapshot-helper.ts
3513
- var createEmptySnapshot = () => {
3514
- return {
3515
- data: []
3516
- };
3517
- };
3518
- var generateNextId = (existingIds, startFrom = 1) => {
3519
- if (!existingIds || existingIds.length === 0) {
3520
- return startFrom;
3521
- }
3522
- const maxId = Math.max(...existingIds, startFrom - 1);
3523
- return maxId + 1;
3524
- };
3525
- var loadSnapshot = async ({
3526
- modelName
3527
- }) => {
3528
- try {
3529
- const snapshot = await loadModelData(modelName);
3530
- if (!snapshot || typeof snapshot !== "object") {
3531
- console.warn("invalid snapshot, creating new one");
3532
- return createEmptySnapshot();
3533
- }
3534
- return {
3535
- data: Array.isArray(snapshot.data) ? snapshot.data : []
3536
- };
3537
- } catch (error) {
3538
- console.error("Failed to load snapshot:", error);
3539
- return createEmptySnapshot();
3540
- }
3541
- };
3542
- var getExistingIds = (snapshot) => {
3543
- return snapshot.data.map((order) => order.id).filter((id) => typeof id === "number");
3544
- };
3545
- var saveSnapshot = async ({
3546
- snapshot,
3547
- modelName
3548
- }) => {
3549
- try {
3550
- await import_snapshot_default({
3551
- data: JSON.stringify({
3552
- [modelName]: snapshot
3553
- })
3554
- });
3555
- return true;
3556
- } catch (error) {
3557
- console.error("failed to save snapshot:", error);
3558
- return false;
3559
- }
3560
- };
3561
- var addRecordResponseHandler = ({
3562
- modelName,
3563
- id,
3564
- data
3565
- }) => {
3566
- if (modelName === "restaurant.floor" /* RESTAURANT_FLOOR */ || modelName === "res.partner" /* RES_PARTNER */) {
3567
- return [[id, ""]];
3568
- }
3569
- return data;
3570
- };
3571
-
3572
- // src/services/filesystem-service/model-repository.ts
3573
- var ModelRepository = class {
3574
- getAll = async ({ modelName }) => {
3575
- try {
3576
- const snapshot = await loadSnapshot({
3577
- modelName
3578
- });
3579
- return snapshot.data;
3580
- } catch (error) {
3581
- console.error("failed to get all records:", error);
3582
- return [];
3583
- }
3584
- };
3585
- getRecord = async ({
3586
- id,
3587
- modelName
3588
- }) => {
3589
- try {
3590
- const snapshot = await loadSnapshot({
3591
- modelName
3592
- });
3593
- return snapshot.data.find((record) => record.id === id) || null;
3594
- } catch (error) {
3595
- console.error("failed to get record:", error);
3596
- return null;
3597
- }
3598
- };
3599
- addRecord = async ({
3600
- newRecord,
3601
- modelName
3602
- }) => {
3603
- try {
3604
- const snapshot = await loadSnapshot({
3605
- modelName
3606
- });
3607
- const existingIds = getExistingIds(snapshot);
3608
- const newId = generateNextId(existingIds, snapshot.data.length);
3609
- snapshot.data.push({
3610
- ...newRecord,
3611
- id: newId
3612
- });
3613
- const saved = await saveSnapshot({
3614
- snapshot,
3615
- modelName
3616
- });
3617
- if (!saved) {
3618
- console.error("failed to add new record");
3619
- return [];
3620
- }
3621
- console.log("lib data:", snapshot.data);
3622
- const response = addRecordResponseHandler({
3623
- id: newId,
3624
- modelName,
3625
- data: snapshot.data
3626
- });
3627
- return response;
3628
- } catch (error) {
3629
- console.error("failed to add new record:", error);
3630
- return [];
3631
- }
3632
- };
3633
- updateRecord = async ({
3634
- id,
3635
- update,
3636
- modelName
3637
- }) => {
3638
- try {
3639
- const snapshot = await loadSnapshot({
3640
- modelName
3641
- });
3642
- const index = snapshot.data.findIndex((record) => record.id === id);
3643
- if (index === -1) {
3644
- console.error(`record with id ${id} not found`);
3645
- return false;
3646
- }
3647
- snapshot.data[index] = {
3648
- ...snapshot.data[index],
3649
- ...update
3650
- };
3651
- return await saveSnapshot({
3652
- snapshot,
3653
- modelName
3654
- });
3655
- } catch (error) {
3656
- console.error("error updating record:", error);
3657
- return false;
3658
- }
3659
- };
3660
- deleteRecord = async ({
3661
- id,
3662
- modelName
3663
- }) => {
3664
- try {
3665
- const snapshot = await loadSnapshot({
3666
- modelName
3667
- });
3668
- const before = snapshot.data.length;
3669
- snapshot.data = snapshot.data.filter((record) => record.id !== id);
3670
- if (snapshot.data.length === before) {
3671
- console.error(`record with id ${id} not found`);
3672
- return false;
3673
- }
3674
- return await saveSnapshot({
3675
- snapshot,
3676
- modelName
3677
- });
3678
- } catch (error) {
3679
- console.error("error deleting record:", error);
3680
- return false;
3681
- }
3682
- };
3683
- };
3684
-
3685
- // src/services/pos-service/add-entity.ts
3686
3196
  var addEntityService = (env) => {
3687
- const isLocalMode = env?.isLocalMode;
3688
- const repo = new ModelRepository();
3689
3197
  const addEntity = useCallback4(
3690
3198
  ({
3691
3199
  model,
@@ -3694,12 +3202,6 @@ var addEntityService = (env) => {
3694
3202
  service,
3695
3203
  isCreateEndpoint = false
3696
3204
  }) => {
3697
- if (isLocalMode) {
3698
- return repo.addRecord({
3699
- newRecord: values,
3700
- modelName: model
3701
- });
3702
- }
3703
3205
  const jsonData = {
3704
3206
  model,
3705
3207
  values
@@ -3716,7 +3218,7 @@ var addEntityService = (env) => {
3716
3218
  service
3717
3219
  );
3718
3220
  },
3719
- [env, isLocalMode]
3221
+ [env]
3720
3222
  );
3721
3223
  return {
3722
3224
  addEntity
@@ -3838,8 +3340,6 @@ var createEInvoiceService = (env) => {
3838
3340
  // src/services/pos-service/create-entity.ts
3839
3341
  import { useCallback as useCallback8 } from "react";
3840
3342
  var createEntityService = (env) => {
3841
- const isLocalMode = env?.isLocalMode;
3842
- const repo = new ModelRepository();
3843
3343
  const createEntity = useCallback8(
3844
3344
  ({
3845
3345
  model,
@@ -3847,12 +3347,6 @@ var createEntityService = (env) => {
3847
3347
  xNode,
3848
3348
  service
3849
3349
  }) => {
3850
- if (isLocalMode) {
3851
- return repo.addRecord({
3852
- newRecord: args[0],
3853
- modelName: model
3854
- });
3855
- }
3856
3350
  const jsonData = {
3857
3351
  model,
3858
3352
  method: "create" /* CREATE */,
@@ -3870,7 +3364,7 @@ var createEntityService = (env) => {
3870
3364
  service
3871
3365
  );
3872
3366
  },
3873
- [env, isLocalMode]
3367
+ [env]
3874
3368
  );
3875
3369
  return {
3876
3370
  createEntity
@@ -3955,8 +3449,6 @@ var createSessionService = (env) => {
3955
3449
  // src/services/pos-service/delete-entity.ts
3956
3450
  import { useCallback as useCallback11 } from "react";
3957
3451
  var deleteEntityService = (env) => {
3958
- const isLocalMode = env?.isLocalMode;
3959
- const repo = new ModelRepository();
3960
3452
  const deleteEntity = useCallback11(
3961
3453
  ({
3962
3454
  model,
@@ -3965,14 +3457,6 @@ var deleteEntityService = (env) => {
3965
3457
  service,
3966
3458
  method
3967
3459
  }) => {
3968
- if (isLocalMode) {
3969
- const id = ids[0];
3970
- if (!id) return;
3971
- return repo.deleteRecord({
3972
- modelName: model,
3973
- id
3974
- });
3975
- }
3976
3460
  const jsonData = {
3977
3461
  model,
3978
3462
  ids,
@@ -3990,7 +3474,7 @@ var deleteEntityService = (env) => {
3990
3474
  service
3991
3475
  );
3992
3476
  },
3993
- [env, isLocalMode]
3477
+ [env]
3994
3478
  );
3995
3479
  return {
3996
3480
  deleteEntity
@@ -4067,8 +3551,6 @@ var getCurrentUserService = (env) => {
4067
3551
  // src/services/pos-service/get-list.ts
4068
3552
  import { useCallback as useCallback14 } from "react";
4069
3553
  var getListService = (env) => {
4070
- const isLocalMode = env?.isLocalMode;
4071
- const repo = new ModelRepository();
4072
3554
  const getList = useCallback14(
4073
3555
  async ({
4074
3556
  model,
@@ -4079,12 +3561,6 @@ var getListService = (env) => {
4079
3561
  offset,
4080
3562
  limit
4081
3563
  }) => {
4082
- if (isLocalMode) {
4083
- const data = await repo.getAll({
4084
- modelName: model
4085
- });
4086
- return data;
4087
- }
4088
3564
  const jsonData = {
4089
3565
  model,
4090
3566
  method: "web_search_read" /* WEB_SEARCH_READ */,
@@ -4107,7 +3583,7 @@ var getListService = (env) => {
4107
3583
  service
4108
3584
  );
4109
3585
  },
4110
- [env, isLocalMode]
3586
+ [env]
4111
3587
  );
4112
3588
  return {
4113
3589
  getList
@@ -4436,8 +3912,41 @@ var handleClosingSessionService = (env) => {
4436
3912
 
4437
3913
  // src/services/pos-service/load-data-pos-session.ts
4438
3914
  import { useCallback as useCallback23 } from "react";
3915
+
3916
+ // src/provider/supabase-provider.tsx
3917
+ import { createContext as createContext2, useContext as useContext2, useMemo } from "react";
3918
+ import { createClient } from "@supabase/supabase-js";
3919
+ import { jsx as jsx6 } from "react/jsx-runtime";
3920
+ var SupabaseContext = createContext2(null);
3921
+ var useSupabase = () => {
3922
+ const context = useContext2(SupabaseContext);
3923
+ if (!context) {
3924
+ throw new Error(
3925
+ "useSupabase must be used within a SupabaseProvider or check your env config"
3926
+ );
3927
+ }
3928
+ return context;
3929
+ };
3930
+
3931
+ // src/services/pos-service/load-data-pos-session.ts
3932
+ var MODEL_TO_TABLE = {
3933
+ ["account.tax" /* ACCOUNT_TAX */]: "account_taxes",
3934
+ ["res.company" /* RES_COMPANY */]: "companies",
3935
+ ["res.partner" /* RES_PARTNER */]: "customers",
3936
+ ["res.users" /* RES_USERS */]: "employees",
3937
+ ["loyalty.program" /* LOYALTY_PROGRAM */]: "loyalty_programs",
3938
+ ["loyalty.rule" /* LOYALTY_RULE */]: "loyalty_rules",
3939
+ ["pos.order.line" /* POS_ORDER_LINE */]: "order_lines",
3940
+ ["pos.order" /* POS_ORDER */]: "orders",
3941
+ ["pos.payment.method" /* POS_PAYMENT_METHOD */]: "payment_methods",
3942
+ ["pos.payment" /* POS_PAYMENT */]: "payments",
3943
+ ["product.category" /* PRODUCT_CATEGORY */]: "product_categories",
3944
+ ["product.product" /* PRODUCT_PRODUCT */]: "products",
3945
+ ["restaurant.floor" /* RESTAURANT_FLOOR */]: "restaurant_floors",
3946
+ ["restaurant.table" /* RESTAURANT_TABLE */]: "restaurant_tables"
3947
+ };
4439
3948
  var loadDataPosSessionService = (env) => {
4440
- const isLocalMode = env?.isLocalMode;
3949
+ const supabase = useSupabase();
4441
3950
  const loadDataPosSession = useCallback23(
4442
3951
  async ({
4443
3952
  model,
@@ -4448,10 +3957,6 @@ var loadDataPosSessionService = (env) => {
4448
3957
  modelsToLoad = [],
4449
3958
  searchParams
4450
3959
  }) => {
4451
- if (isLocalMode) {
4452
- const data = await loadData();
4453
- return data;
4454
- }
4455
3960
  const jsonData = {
4456
3961
  model,
4457
3962
  method: "load_data" /* LOAD_DATA */,
@@ -4478,10 +3983,59 @@ var loadDataPosSessionService = (env) => {
4478
3983
  service
4479
3984
  );
4480
3985
  },
4481
- [env, isLocalMode]
3986
+ [env]
4482
3987
  );
3988
+ const loadDataPosSessionSupabase = useCallback23(async () => {
3989
+ try {
3990
+ const allModels = Object.values(LoadDataModel);
3991
+ const promises = allModels.map(async (modelName) => {
3992
+ const tableName = MODEL_TO_TABLE[modelName];
3993
+ if (!tableName) {
3994
+ return {
3995
+ modelName,
3996
+ data: [],
3997
+ fields: {},
3998
+ relations: {}
3999
+ };
4000
+ }
4001
+ const { data, error } = await supabase.from(tableName).select("*");
4002
+ if (error) {
4003
+ console.error(`Error loading ${modelName}:`, error);
4004
+ return {
4005
+ modelName,
4006
+ data: [],
4007
+ fields: {},
4008
+ relations: {}
4009
+ };
4010
+ }
4011
+ return {
4012
+ modelName,
4013
+ data: data || [],
4014
+ fields: {},
4015
+ relations: {}
4016
+ };
4017
+ });
4018
+ const results = await Promise.all(promises);
4019
+ const response = results.reduce(
4020
+ (acc, { modelName, data, fields, relations }) => {
4021
+ acc[modelName] = {
4022
+ data,
4023
+ fields,
4024
+ relations
4025
+ };
4026
+ return acc;
4027
+ },
4028
+ {}
4029
+ );
4030
+ return response;
4031
+ } catch (error) {
4032
+ console.error("Error loading data from Supabase:", error);
4033
+ return {};
4034
+ }
4035
+ }, [supabase]);
4483
4036
  return {
4484
- loadDataPosSession
4037
+ loadDataPosSession,
4038
+ loadDataPosSessionSupabase
4485
4039
  };
4486
4040
  };
4487
4041
 
@@ -4703,8 +4257,6 @@ var updateClosedSessionService = (env) => {
4703
4257
  // src/services/pos-service/update-entity.ts
4704
4258
  import { useCallback as useCallback30 } from "react";
4705
4259
  var updateEntityService = (env) => {
4706
- const isLocalMode = env?.isLocalMode;
4707
- const repo = new ModelRepository();
4708
4260
  const updateEntity = useCallback30(
4709
4261
  ({
4710
4262
  model,
@@ -4714,15 +4266,6 @@ var updateEntityService = (env) => {
4714
4266
  xNode,
4715
4267
  service
4716
4268
  }) => {
4717
- if (isLocalMode) {
4718
- const id = extractIdFromDomain(domain);
4719
- if (!id) return;
4720
- return repo.updateRecord({
4721
- update: values,
4722
- modelName: model,
4723
- id
4724
- });
4725
- }
4726
4269
  const jsonData = {
4727
4270
  model,
4728
4271
  domain,
@@ -4740,7 +4283,7 @@ var updateEntityService = (env) => {
4740
4283
  service
4741
4284
  );
4742
4285
  },
4743
- [env, isLocalMode]
4286
+ [env]
4744
4287
  );
4745
4288
  return {
4746
4289
  updateEntity
@@ -4780,6 +4323,49 @@ var updateOrderStatusService = (env) => {
4780
4323
  };
4781
4324
  };
4782
4325
 
4326
+ // src/services/pos-service/complete-current-stage.ts
4327
+ import { useCallback as useCallback32 } from "react";
4328
+ var completeCurrentStageService = (env) => {
4329
+ const completeCurrentStage = useCallback32(
4330
+ ({
4331
+ ids,
4332
+ withContext,
4333
+ xNode,
4334
+ service,
4335
+ requestStageId
4336
+ }) => {
4337
+ const jsonData = {
4338
+ model: "pos_preparation_display.orderline" /* POS_PREPARATION_ORDER_LINE */,
4339
+ method: "complete_current_stage" /* COMPLETE_CURRENT_STAGE */,
4340
+ ids,
4341
+ kwargs: {
4342
+ request_stage_id: requestStageId
4343
+ },
4344
+ with_context: withContext || {
4345
+ lang: "vi_VN",
4346
+ tz: "Asia/Ho_Chi_Minh",
4347
+ uid: 2
4348
+ }
4349
+ };
4350
+ return env?.requests.post(
4351
+ "/call" /* CALL_PATH */,
4352
+ jsonData,
4353
+ {
4354
+ headers: {
4355
+ "Content-Type": "application/json",
4356
+ ...xNode ? { "X-Node": xNode } : {}
4357
+ }
4358
+ },
4359
+ service
4360
+ );
4361
+ },
4362
+ [env]
4363
+ );
4364
+ return {
4365
+ completeCurrentStage
4366
+ };
4367
+ };
4368
+
4783
4369
  // src/services/pos-service/index.ts
4784
4370
  var serviceFactories = [
4785
4371
  addEntityService,
@@ -4810,7 +4396,8 @@ var serviceFactories = [
4810
4396
  searchJournalService,
4811
4397
  updateClosedSessionService,
4812
4398
  updateEntityService,
4813
- updateOrderStatusService
4399
+ updateOrderStatusService,
4400
+ completeCurrentStageService
4814
4401
  ];
4815
4402
  var usePosService = () => {
4816
4403
  const { env } = useEnv();
@@ -4906,21 +4493,21 @@ import { useMutation as useMutation84 } from "@tanstack/react-query";
4906
4493
  // src/hooks/pos/use-update-order-status.ts
4907
4494
  import { useMutation as useMutation85 } from "@tanstack/react-query";
4908
4495
 
4909
- // src/hooks/pos/use-init-snapshot.ts
4496
+ // src/hooks/pos/use-complete-current-stage.ts
4910
4497
  import { useMutation as useMutation86 } from "@tanstack/react-query";
4911
4498
 
4912
4499
  // src/provider/service-provider.tsx
4913
- import { jsx as jsx6 } from "react/jsx-runtime";
4914
- var ServiceContext = createContext2(null);
4500
+ import { jsx as jsx7 } from "react/jsx-runtime";
4501
+ var ServiceContext = createContext3(null);
4915
4502
 
4916
4503
  // src/provider/meta-provider.tsx
4917
4504
  import { useEffect as useEffect3 } from "react";
4918
- import { Fragment as Fragment2, jsx as jsx7 } from "react/jsx-runtime";
4505
+ import { Fragment as Fragment2, jsx as jsx8 } from "react/jsx-runtime";
4919
4506
 
4920
4507
  // src/services/action-service/index.ts
4921
4508
  function useActionService() {
4922
4509
  const { env } = useEnv();
4923
- const loadAction = useCallback32(
4510
+ const loadAction = useCallback33(
4924
4511
  async ({
4925
4512
  idAction,
4926
4513
  context,
@@ -4944,7 +4531,7 @@ function useActionService() {
4944
4531
  },
4945
4532
  [env]
4946
4533
  );
4947
- const callButton = useCallback32(
4534
+ const callButton = useCallback33(
4948
4535
  async ({
4949
4536
  model,
4950
4537
  ids = [],
@@ -4978,7 +4565,7 @@ function useActionService() {
4978
4565
  },
4979
4566
  [env]
4980
4567
  );
4981
- const removeRows = useCallback32(
4568
+ const removeRows = useCallback33(
4982
4569
  async ({
4983
4570
  model,
4984
4571
  ids,
@@ -5004,7 +4591,7 @@ function useActionService() {
5004
4591
  },
5005
4592
  [env]
5006
4593
  );
5007
- const duplicateRecord = useCallback32(
4594
+ const duplicateRecord = useCallback33(
5008
4595
  async ({
5009
4596
  model,
5010
4597
  id,
@@ -5030,7 +4617,7 @@ function useActionService() {
5030
4617
  },
5031
4618
  [env]
5032
4619
  );
5033
- const getPrintReportName = useCallback32(
4620
+ const getPrintReportName = useCallback33(
5034
4621
  async ({ id }) => {
5035
4622
  const jsonData = {
5036
4623
  model: "ir.actions.report",
@@ -5048,7 +4635,7 @@ function useActionService() {
5048
4635
  },
5049
4636
  [env]
5050
4637
  );
5051
- const print = useCallback32(
4638
+ const print = useCallback33(
5052
4639
  async ({ id, report, db }) => {
5053
4640
  const jsonData = {
5054
4641
  report,
@@ -5066,7 +4653,7 @@ function useActionService() {
5066
4653
  },
5067
4654
  [env]
5068
4655
  );
5069
- const runAction = useCallback32(
4656
+ const runAction = useCallback33(
5070
4657
  async ({
5071
4658
  idAction,
5072
4659
  context,
@@ -5093,7 +4680,7 @@ function useActionService() {
5093
4680
  },
5094
4681
  [env]
5095
4682
  );
5096
- const generateSerialNumber = useCallback32(
4683
+ const generateSerialNumber = useCallback33(
5097
4684
  async ({
5098
4685
  kwargs,
5099
4686
  context,
@@ -5131,10 +4718,10 @@ function useActionService() {
5131
4718
  }
5132
4719
 
5133
4720
  // src/services/auth-service/index.ts
5134
- import { useCallback as useCallback33 } from "react";
4721
+ import { useCallback as useCallback34 } from "react";
5135
4722
  function useAuthService() {
5136
4723
  const { env } = useEnv();
5137
- const login = useCallback33(
4724
+ const login = useCallback34(
5138
4725
  async (body) => {
5139
4726
  const payload = Object.fromEntries(
5140
4727
  Object.entries({
@@ -5159,7 +4746,7 @@ function useAuthService() {
5159
4746
  },
5160
4747
  [env]
5161
4748
  );
5162
- const forgotPassword = useCallback33(
4749
+ const forgotPassword = useCallback34(
5163
4750
  async (email) => {
5164
4751
  const bodyData = {
5165
4752
  login: email,
@@ -5173,7 +4760,7 @@ function useAuthService() {
5173
4760
  },
5174
4761
  [env]
5175
4762
  );
5176
- const forgotPasswordSSO = useCallback33(
4763
+ const forgotPasswordSSO = useCallback34(
5177
4764
  async ({
5178
4765
  email,
5179
4766
  with_context,
@@ -5196,7 +4783,7 @@ function useAuthService() {
5196
4783
  },
5197
4784
  [env]
5198
4785
  );
5199
- const resetPassword = useCallback33(
4786
+ const resetPassword = useCallback34(
5200
4787
  async (data, token) => {
5201
4788
  const bodyData = {
5202
4789
  token,
@@ -5211,7 +4798,7 @@ function useAuthService() {
5211
4798
  },
5212
4799
  [env]
5213
4800
  );
5214
- const resetPasswordSSO = useCallback33(
4801
+ const resetPasswordSSO = useCallback34(
5215
4802
  async ({
5216
4803
  method,
5217
4804
  password,
@@ -5234,7 +4821,7 @@ function useAuthService() {
5234
4821
  },
5235
4822
  [env]
5236
4823
  );
5237
- const updatePassword = useCallback33(
4824
+ const updatePassword = useCallback34(
5238
4825
  async (data, token) => {
5239
4826
  const bodyData = {
5240
4827
  token,
@@ -5249,7 +4836,7 @@ function useAuthService() {
5249
4836
  },
5250
4837
  [env]
5251
4838
  );
5252
- const isValidToken = useCallback33(
4839
+ const isValidToken = useCallback34(
5253
4840
  async (token) => {
5254
4841
  const bodyData = {
5255
4842
  token
@@ -5262,7 +4849,7 @@ function useAuthService() {
5262
4849
  },
5263
4850
  [env]
5264
4851
  );
5265
- const isValidActionToken = useCallback33(
4852
+ const isValidActionToken = useCallback34(
5266
4853
  async (actionToken) => {
5267
4854
  const bodyData = {};
5268
4855
  return env?.requests?.post("/action-token/validate" /* VALIDATE_ACTION_TOKEN */, bodyData, {
@@ -5275,7 +4862,7 @@ function useAuthService() {
5275
4862
  },
5276
4863
  [env]
5277
4864
  );
5278
- const loginSocial = useCallback33(
4865
+ const loginSocial = useCallback34(
5279
4866
  async ({
5280
4867
  db,
5281
4868
  state,
@@ -5293,13 +4880,13 @@ function useAuthService() {
5293
4880
  },
5294
4881
  [env]
5295
4882
  );
5296
- const getProviders = useCallback33(
4883
+ const getProviders = useCallback34(
5297
4884
  async (db) => {
5298
4885
  return env?.requests?.get("/oauth/providers", { params: { db } });
5299
4886
  },
5300
4887
  [env]
5301
4888
  );
5302
- const getAccessByCode = useCallback33(
4889
+ const getAccessByCode = useCallback34(
5303
4890
  async (code) => {
5304
4891
  const data = new URLSearchParams();
5305
4892
  data.append("code", code);
@@ -5319,7 +4906,7 @@ function useAuthService() {
5319
4906
  },
5320
4907
  [env]
5321
4908
  );
5322
- const logout = useCallback33(
4909
+ const logout = useCallback34(
5323
4910
  async (service) => {
5324
4911
  return env?.requests?.post(
5325
4912
  "/logout" /* LOGOUT */,
@@ -5336,7 +4923,7 @@ function useAuthService() {
5336
4923
  },
5337
4924
  [env]
5338
4925
  );
5339
- const getTenantMapping = useCallback33(
4926
+ const getTenantMapping = useCallback34(
5340
4927
  async ({ shortName, service }) => {
5341
4928
  const bodyData = {
5342
4929
  short_name: shortName
@@ -5354,7 +4941,7 @@ function useAuthService() {
5354
4941
  },
5355
4942
  [env]
5356
4943
  );
5357
- const getToken = useCallback33(
4944
+ const getToken = useCallback34(
5358
4945
  async ({
5359
4946
  phone,
5360
4947
  name,
@@ -5398,10 +4985,10 @@ function useAuthService() {
5398
4985
  }
5399
4986
 
5400
4987
  // src/services/company-service/index.ts
5401
- import { useCallback as useCallback34 } from "react";
4988
+ import { useCallback as useCallback35 } from "react";
5402
4989
  function useCompanyService() {
5403
4990
  const { env } = useEnv();
5404
- const getCurrentCompany = useCallback34(
4991
+ const getCurrentCompany = useCallback35(
5405
4992
  async (service, extraHeaders) => {
5406
4993
  return await env.requests.get(
5407
4994
  "/company" /* COMPANY_PATH */,
@@ -5418,7 +5005,7 @@ function useCompanyService() {
5418
5005
  },
5419
5006
  [env]
5420
5007
  );
5421
- const getInfoCompany = useCallback34(
5008
+ const getInfoCompany = useCallback35(
5422
5009
  async (id, service) => {
5423
5010
  const jsonData = {
5424
5011
  ids: [id],
@@ -5454,10 +5041,10 @@ function useCompanyService() {
5454
5041
  }
5455
5042
 
5456
5043
  // src/services/excel-service/index.ts
5457
- import { useCallback as useCallback35 } from "react";
5044
+ import { useCallback as useCallback36 } from "react";
5458
5045
  function useExcelService() {
5459
5046
  const { env } = useEnv();
5460
- const uploadFileExcel = useCallback35(
5047
+ const uploadFileExcel = useCallback36(
5461
5048
  async ({
5462
5049
  formData,
5463
5050
  service,
@@ -5474,7 +5061,7 @@ function useExcelService() {
5474
5061
  },
5475
5062
  [env]
5476
5063
  );
5477
- const uploadIdFile = useCallback35(
5064
+ const uploadIdFile = useCallback36(
5478
5065
  async ({
5479
5066
  formData,
5480
5067
  service,
@@ -5491,7 +5078,7 @@ function useExcelService() {
5491
5078
  },
5492
5079
  [env]
5493
5080
  );
5494
- const parsePreview = useCallback35(
5081
+ const parsePreview = useCallback36(
5495
5082
  async ({
5496
5083
  id,
5497
5084
  selectedSheet,
@@ -5540,7 +5127,7 @@ function useExcelService() {
5540
5127
  },
5541
5128
  [env]
5542
5129
  );
5543
- const executeImport = useCallback35(
5130
+ const executeImport = useCallback36(
5544
5131
  async ({
5545
5132
  columns,
5546
5133
  fields,
@@ -5574,7 +5161,7 @@ function useExcelService() {
5574
5161
  },
5575
5162
  [env]
5576
5163
  );
5577
- const getFileExcel = useCallback35(
5164
+ const getFileExcel = useCallback36(
5578
5165
  async ({
5579
5166
  model,
5580
5167
  service,
@@ -5598,7 +5185,7 @@ function useExcelService() {
5598
5185
  },
5599
5186
  [env]
5600
5187
  );
5601
- const getFieldExport = useCallback35(
5188
+ const getFieldExport = useCallback36(
5602
5189
  async ({
5603
5190
  ids,
5604
5191
  model,
@@ -5638,7 +5225,7 @@ function useExcelService() {
5638
5225
  },
5639
5226
  [env]
5640
5227
  );
5641
- const exportExcel = useCallback35(
5228
+ const exportExcel = useCallback36(
5642
5229
  async ({
5643
5230
  model,
5644
5231
  domain,
@@ -5686,10 +5273,10 @@ function useExcelService() {
5686
5273
  }
5687
5274
 
5688
5275
  // src/services/form-service/index.ts
5689
- import { useCallback as useCallback36 } from "react";
5276
+ import { useCallback as useCallback37 } from "react";
5690
5277
  function useFormService() {
5691
5278
  const { env } = useEnv();
5692
- const getComment = useCallback36(
5279
+ const getComment = useCallback37(
5693
5280
  async ({ data }) => {
5694
5281
  const jsonData = {
5695
5282
  thread_id: data.thread_id,
@@ -5707,7 +5294,7 @@ function useFormService() {
5707
5294
  },
5708
5295
  [env]
5709
5296
  );
5710
- const getThreadData = useCallback36(
5297
+ const getThreadData = useCallback37(
5711
5298
  async ({
5712
5299
  data,
5713
5300
  xNode,
@@ -5734,7 +5321,7 @@ function useFormService() {
5734
5321
  },
5735
5322
  [env]
5736
5323
  );
5737
- const getThreadMessages = useCallback36(
5324
+ const getThreadMessages = useCallback37(
5738
5325
  async ({
5739
5326
  data,
5740
5327
  xNode,
@@ -5760,7 +5347,7 @@ function useFormService() {
5760
5347
  },
5761
5348
  [env]
5762
5349
  );
5763
- const sentComment = useCallback36(
5350
+ const sentComment = useCallback37(
5764
5351
  async ({ data }) => {
5765
5352
  const jsonData = {
5766
5353
  context: {
@@ -5788,7 +5375,7 @@ function useFormService() {
5788
5375
  },
5789
5376
  [env]
5790
5377
  );
5791
- const deleteComment = useCallback36(
5378
+ const deleteComment = useCallback37(
5792
5379
  async ({ data }) => {
5793
5380
  const jsonData = {
5794
5381
  attachment_ids: [],
@@ -5804,7 +5391,7 @@ function useFormService() {
5804
5391
  },
5805
5392
  [env]
5806
5393
  );
5807
- const getImage = useCallback36(
5394
+ const getImage = useCallback37(
5808
5395
  async ({ data }) => {
5809
5396
  return env.requests.get(
5810
5397
  `${"/web/image" /* IMAGE_PATH */}?filename=${data.filename}&unique=${data.checksum}&width=1920&height=300`,
@@ -5817,7 +5404,7 @@ function useFormService() {
5817
5404
  },
5818
5405
  [env]
5819
5406
  );
5820
- const uploadImage = useCallback36(
5407
+ const uploadImage = useCallback37(
5821
5408
  async ({
5822
5409
  formData,
5823
5410
  service,
@@ -5836,7 +5423,7 @@ function useFormService() {
5836
5423
  },
5837
5424
  [env]
5838
5425
  );
5839
- const uploadFile = useCallback36(
5426
+ const uploadFile = useCallback37(
5840
5427
  async ({
5841
5428
  formData,
5842
5429
  service,
@@ -5856,7 +5443,7 @@ function useFormService() {
5856
5443
  },
5857
5444
  [env]
5858
5445
  );
5859
- const getFormView = useCallback36(
5446
+ const getFormView = useCallback37(
5860
5447
  async ({ data }) => {
5861
5448
  const jsonData = {
5862
5449
  model: data.model,
@@ -5872,7 +5459,7 @@ function useFormService() {
5872
5459
  },
5873
5460
  [env]
5874
5461
  );
5875
- const changeStatus = useCallback36(
5462
+ const changeStatus = useCallback37(
5876
5463
  async ({ data }) => {
5877
5464
  const vals = {
5878
5465
  [data.name]: data.stage_id
@@ -5901,7 +5488,7 @@ function useFormService() {
5901
5488
  },
5902
5489
  [env]
5903
5490
  );
5904
- const getExternalTab = useCallback36(
5491
+ const getExternalTab = useCallback37(
5905
5492
  async ({ method, context, service, xNode }) => {
5906
5493
  return env?.requests?.post(
5907
5494
  "/call" /* CALL_PATH */,
@@ -5936,10 +5523,10 @@ function useFormService() {
5936
5523
  }
5937
5524
 
5938
5525
  // src/services/kanban-service/index.ts
5939
- import { useCallback as useCallback37 } from "react";
5526
+ import { useCallback as useCallback38 } from "react";
5940
5527
  function useKanbanService() {
5941
5528
  const { env } = useEnv();
5942
- const getGroups = useCallback37(
5529
+ const getGroups = useCallback38(
5943
5530
  async ({ model, width_context }) => {
5944
5531
  const jsonData = {
5945
5532
  model,
@@ -5959,7 +5546,7 @@ function useKanbanService() {
5959
5546
  },
5960
5547
  [env]
5961
5548
  );
5962
- const getProgressBar = useCallback37(
5549
+ const getProgressBar = useCallback38(
5963
5550
  async ({ field, color, model, width_context }) => {
5964
5551
  const jsonData = {
5965
5552
  model,
@@ -5989,10 +5576,10 @@ function useKanbanService() {
5989
5576
  }
5990
5577
 
5991
5578
  // src/services/model-service/index.ts
5992
- import { useCallback as useCallback38 } from "react";
5579
+ import { useCallback as useCallback39 } from "react";
5993
5580
  function useModelService() {
5994
5581
  const { env } = useEnv();
5995
- const getListMyBankAccount = useCallback38(
5582
+ const getListMyBankAccount = useCallback39(
5996
5583
  async ({
5997
5584
  domain,
5998
5585
  spectification,
@@ -6016,7 +5603,7 @@ function useModelService() {
6016
5603
  },
6017
5604
  [env]
6018
5605
  );
6019
- const getCurrency = useCallback38(async () => {
5606
+ const getCurrency = useCallback39(async () => {
6020
5607
  const jsonData = {
6021
5608
  model: "res.currency",
6022
5609
  method: "web_search_read",
@@ -6036,7 +5623,7 @@ function useModelService() {
6036
5623
  }
6037
5624
  });
6038
5625
  }, [env]);
6039
- const getConversionRate = useCallback38(async () => {
5626
+ const getConversionRate = useCallback39(async () => {
6040
5627
  const jsonData = {
6041
5628
  model: "res.currency",
6042
5629
  method: "web_search_read",
@@ -6062,7 +5649,7 @@ function useModelService() {
6062
5649
  }
6063
5650
  });
6064
5651
  }, [env]);
6065
- const getAll = useCallback38(
5652
+ const getAll = useCallback39(
6066
5653
  async ({
6067
5654
  data,
6068
5655
  service,
@@ -6104,7 +5691,7 @@ function useModelService() {
6104
5691
  },
6105
5692
  [env]
6106
5693
  );
6107
- const getListCalendar = useCallback38(
5694
+ const getListCalendar = useCallback39(
6108
5695
  async ({ data }) => {
6109
5696
  const jsonReadGroup = data.type == "calendar" ? data?.fields : data.fields && data.fields.length > 0 && data.groupby && data.groupby.length > 0 && data.groupby[0] ? {
6110
5697
  fields: data.fields,
@@ -6135,7 +5722,7 @@ function useModelService() {
6135
5722
  },
6136
5723
  [env]
6137
5724
  );
6138
- const getList = useCallback38(
5725
+ const getList = useCallback39(
6139
5726
  async ({
6140
5727
  model,
6141
5728
  ids = [],
@@ -6167,7 +5754,7 @@ function useModelService() {
6167
5754
  },
6168
5755
  [env]
6169
5756
  );
6170
- const getDetail = useCallback38(
5757
+ const getDetail = useCallback39(
6171
5758
  async ({
6172
5759
  ids = [],
6173
5760
  model,
@@ -6199,7 +5786,7 @@ function useModelService() {
6199
5786
  },
6200
5787
  [env]
6201
5788
  );
6202
- const save = useCallback38(
5789
+ const save = useCallback39(
6203
5790
  async ({
6204
5791
  model,
6205
5792
  ids = [],
@@ -6234,7 +5821,7 @@ function useModelService() {
6234
5821
  },
6235
5822
  [env]
6236
5823
  );
6237
- const deleteApi = useCallback38(
5824
+ const deleteApi = useCallback39(
6238
5825
  async ({ ids = [], model, service }) => {
6239
5826
  const jsonData = {
6240
5827
  model,
@@ -6254,7 +5841,7 @@ function useModelService() {
6254
5841
  },
6255
5842
  [env]
6256
5843
  );
6257
- const onChange = useCallback38(
5844
+ const onChange = useCallback39(
6258
5845
  async ({
6259
5846
  ids = [],
6260
5847
  model,
@@ -6290,7 +5877,7 @@ function useModelService() {
6290
5877
  },
6291
5878
  [env]
6292
5879
  );
6293
- const getListFieldsOnchange = useCallback38(
5880
+ const getListFieldsOnchange = useCallback39(
6294
5881
  async ({
6295
5882
  model,
6296
5883
  service,
@@ -6314,7 +5901,7 @@ function useModelService() {
6314
5901
  },
6315
5902
  [env]
6316
5903
  );
6317
- const parseORMOdoo = useCallback38((data) => {
5904
+ const parseORMOdoo = useCallback39((data) => {
6318
5905
  for (const key in data) {
6319
5906
  if (key === "display_name") {
6320
5907
  delete data[key];
@@ -6325,7 +5912,7 @@ function useModelService() {
6325
5912
  }
6326
5913
  return { ...data };
6327
5914
  }, []);
6328
- const toDataJS = useCallback38(
5915
+ const toDataJS = useCallback39(
6329
5916
  (data, viewData, model) => {
6330
5917
  for (const key in data) {
6331
5918
  if (data[key] === false) {
@@ -6383,10 +5970,10 @@ function useModelService() {
6383
5970
  }
6384
5971
 
6385
5972
  // src/services/user-service/index.ts
6386
- import { useCallback as useCallback39 } from "react";
5973
+ import { useCallback as useCallback40 } from "react";
6387
5974
  function useUserService() {
6388
5975
  const { env } = useEnv();
6389
- const getProfile = useCallback39(
5976
+ const getProfile = useCallback40(
6390
5977
  async (service, path, extraHeaders) => {
6391
5978
  return env?.requests?.get(
6392
5979
  path || "/userinfo" /* PROFILE_PATH */,
@@ -6403,7 +5990,7 @@ function useUserService() {
6403
5990
  },
6404
5991
  [env]
6405
5992
  );
6406
- const getUser = useCallback39(
5993
+ const getUser = useCallback40(
6407
5994
  async ({ context, id }) => {
6408
5995
  const jsonData = {
6409
5996
  model: "res.users",
@@ -6441,7 +6028,7 @@ function useUserService() {
6441
6028
  },
6442
6029
  [env]
6443
6030
  );
6444
- const switchUserLocale = useCallback39(
6031
+ const switchUserLocale = useCallback40(
6445
6032
  async ({ id, values, service }) => {
6446
6033
  const jsonData = {
6447
6034
  model: "res.users",
@@ -6469,10 +6056,10 @@ function useUserService() {
6469
6056
  }
6470
6057
 
6471
6058
  // src/services/view-service/index.ts
6472
- import { useCallback as useCallback40 } from "react";
6059
+ import { useCallback as useCallback41 } from "react";
6473
6060
  function useViewService() {
6474
6061
  const { env } = useEnv();
6475
- const getView = useCallback40(
6062
+ const getView = useCallback41(
6476
6063
  async ({
6477
6064
  model,
6478
6065
  views,
@@ -6512,7 +6099,7 @@ function useViewService() {
6512
6099
  },
6513
6100
  [env]
6514
6101
  );
6515
- const getMenu = useCallback40(
6102
+ const getMenu = useCallback41(
6516
6103
  async (context, specification, domain, service) => {
6517
6104
  const jsonData = {
6518
6105
  model: "ir.ui.menu" /* MENU */,
@@ -6543,7 +6130,7 @@ function useViewService() {
6543
6130
  },
6544
6131
  [env]
6545
6132
  );
6546
- const getActionDetail = useCallback40(
6133
+ const getActionDetail = useCallback41(
6547
6134
  async (aid, context) => {
6548
6135
  const jsonData = {
6549
6136
  model: "ir.actions.act_window" /* WINDOW_ACTION */,
@@ -6573,7 +6160,7 @@ function useViewService() {
6573
6160
  },
6574
6161
  [env]
6575
6162
  );
6576
- const getResequence = useCallback40(
6163
+ const getResequence = useCallback41(
6577
6164
  async ({
6578
6165
  model,
6579
6166
  ids,
@@ -6603,7 +6190,7 @@ function useViewService() {
6603
6190
  },
6604
6191
  [env]
6605
6192
  );
6606
- const getSelectionItem = useCallback40(
6193
+ const getSelectionItem = useCallback41(
6607
6194
  async ({
6608
6195
  data,
6609
6196
  service,
@@ -6640,7 +6227,7 @@ function useViewService() {
6640
6227
  },
6641
6228
  [env]
6642
6229
  );
6643
- const loadMessages = useCallback40(async () => {
6230
+ const loadMessages = useCallback41(async () => {
6644
6231
  return env.requests.post(
6645
6232
  "/load_message_failures" /* LOAD_MESSAGE */,
6646
6233
  {},
@@ -6651,14 +6238,14 @@ function useViewService() {
6651
6238
  }
6652
6239
  );
6653
6240
  }, [env]);
6654
- const getVersion = useCallback40(async () => {
6241
+ const getVersion = useCallback41(async () => {
6655
6242
  return env?.requests?.get("", {
6656
6243
  headers: {
6657
6244
  "Content-Type": "application/json"
6658
6245
  }
6659
6246
  });
6660
6247
  }, [env]);
6661
- const grantAccess = useCallback40(
6248
+ const grantAccess = useCallback41(
6662
6249
  async ({
6663
6250
  redirect_uri,
6664
6251
  state,
@@ -6685,7 +6272,7 @@ function useViewService() {
6685
6272
  },
6686
6273
  [env]
6687
6274
  );
6688
- const removeTotpSetUp = useCallback40(
6275
+ const removeTotpSetUp = useCallback41(
6689
6276
  async ({ method, token }) => {
6690
6277
  const jsonData = {
6691
6278
  method,
@@ -6706,7 +6293,7 @@ function useViewService() {
6706
6293
  },
6707
6294
  [env]
6708
6295
  );
6709
- const requestSetupTotp = useCallback40(
6296
+ const requestSetupTotp = useCallback41(
6710
6297
  async ({ method, token }) => {
6711
6298
  const jsonData = {
6712
6299
  method,
@@ -6725,7 +6312,7 @@ function useViewService() {
6725
6312
  },
6726
6313
  [env]
6727
6314
  );
6728
- const settingsWebRead2fa = useCallback40(
6315
+ const settingsWebRead2fa = useCallback41(
6729
6316
  async ({
6730
6317
  method,
6731
6318
  model,
@@ -6753,7 +6340,7 @@ function useViewService() {
6753
6340
  },
6754
6341
  [env]
6755
6342
  );
6756
- const signInSSO = useCallback40(
6343
+ const signInSSO = useCallback41(
6757
6344
  async ({
6758
6345
  redirect_uri,
6759
6346
  state,
@@ -6785,7 +6372,7 @@ function useViewService() {
6785
6372
  },
6786
6373
  [env]
6787
6374
  );
6788
- const verify2FA = useCallback40(
6375
+ const verify2FA = useCallback41(
6789
6376
  ({
6790
6377
  method,
6791
6378
  with_context,
@@ -6818,7 +6405,7 @@ function useViewService() {
6818
6405
  },
6819
6406
  [env]
6820
6407
  );
6821
- const get2FAMethods = useCallback40(
6408
+ const get2FAMethods = useCallback41(
6822
6409
  ({ method, with_context }) => {
6823
6410
  const jsonData = {
6824
6411
  method,
@@ -6837,7 +6424,7 @@ function useViewService() {
6837
6424
  },
6838
6425
  [env]
6839
6426
  );
6840
- const verifyTotp = useCallback40(
6427
+ const verifyTotp = useCallback41(
6841
6428
  ({
6842
6429
  method,
6843
6430
  action_token,
@@ -6862,7 +6449,7 @@ function useViewService() {
6862
6449
  },
6863
6450
  [env]
6864
6451
  );
6865
- const getNotifications = useCallback40(
6452
+ const getNotifications = useCallback41(
6866
6453
  async ({
6867
6454
  service,
6868
6455
  xNode,
@@ -6882,7 +6469,7 @@ function useViewService() {
6882
6469
  },
6883
6470
  [env]
6884
6471
  );
6885
- const getCountry = useCallback40(
6472
+ const getCountry = useCallback41(
6886
6473
  async ({
6887
6474
  service,
6888
6475
  xNode,
@@ -6909,7 +6496,7 @@ function useViewService() {
6909
6496
  },
6910
6497
  [env]
6911
6498
  );
6912
- const getCity = useCallback40(
6499
+ const getCity = useCallback41(
6913
6500
  async ({
6914
6501
  service,
6915
6502
  xNode,
@@ -6936,7 +6523,7 @@ function useViewService() {
6936
6523
  },
6937
6524
  [env]
6938
6525
  );
6939
- const getWard = useCallback40(
6526
+ const getWard = useCallback41(
6940
6527
  async ({
6941
6528
  service,
6942
6529
  xNode,
@@ -6961,7 +6548,7 @@ function useViewService() {
6961
6548
  },
6962
6549
  [env]
6963
6550
  );
6964
- const getPartnerTitle = useCallback40(
6551
+ const getPartnerTitle = useCallback41(
6965
6552
  async ({
6966
6553
  service,
6967
6554
  xNode,
@@ -7013,10 +6600,10 @@ function useViewService() {
7013
6600
  }
7014
6601
 
7015
6602
  // src/services/dashboard-service/index.ts
7016
- import { useCallback as useCallback41 } from "react";
6603
+ import { useCallback as useCallback42 } from "react";
7017
6604
  function useDashboardService() {
7018
6605
  const { env } = useEnv();
7019
- const readGroup = useCallback41(
6606
+ const readGroup = useCallback42(
7020
6607
  async ({
7021
6608
  service,
7022
6609
  xNode,
@@ -7033,7 +6620,7 @@ function useDashboardService() {
7033
6620
  },
7034
6621
  [env]
7035
6622
  );
7036
- const getDataChart = useCallback41(
6623
+ const getDataChart = useCallback42(
7037
6624
  async ({
7038
6625
  service,
7039
6626
  xNode,
@@ -7067,57 +6654,12 @@ function useDashboardService() {
7067
6654
  );
7068
6655
  return { readGroup, getDataChart };
7069
6656
  }
7070
-
7071
- // src/services/filesystem-service/init-snapshot.ts
7072
- var isSnapshotReady = async () => {
7073
- try {
7074
- const raw = await fileService.read("pos/manifest.json");
7075
- if (!raw) return false;
7076
- const manifest = JSON.parse(raw);
7077
- if (!manifest.models || typeof manifest.models !== "object") {
7078
- return false;
7079
- }
7080
- const modelEntries = Object.values(manifest.models);
7081
- if (modelEntries.length === 0) return false;
7082
- const firstModel = modelEntries[0];
7083
- if (!firstModel.file) return false;
7084
- const modelExists = await fileService.exists(firstModel.file);
7085
- return modelExists;
7086
- } catch {
7087
- return false;
7088
- }
7089
- };
7090
- async function initSnapshot(onProgress) {
7091
- const ready = await isSnapshotReady();
7092
- if (ready) {
7093
- console.log("skip initialization.");
7094
- return;
7095
- }
7096
- console.log("initializing from data.json...");
7097
- const jsonData = await fetch("/data.json").then((r) => r.text());
7098
- if (!jsonData) {
7099
- console.error("cannot load data.json");
7100
- return;
7101
- }
7102
- await import_snapshot_default({
7103
- data: jsonData,
7104
- onProgress
7105
- });
7106
- }
7107
-
7108
- // src/services/filesystem-service/index.ts
7109
- var useFileSystemService = () => {
7110
- return {
7111
- initSnapshot
7112
- };
7113
- };
7114
6657
  export {
7115
6658
  useActionService,
7116
6659
  useAuthService,
7117
6660
  useCompanyService,
7118
6661
  useDashboardService,
7119
6662
  useExcelService,
7120
- useFileSystemService,
7121
6663
  useFormService,
7122
6664
  useKanbanService,
7123
6665
  useModelService,