nolo-cli 0.54.0 → 0.61.0-alpha.2
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/README.md +3 -3
- package/{_executeModel-OPTKYHJA.js → _executeModel-CKT6RGTL.js} +48 -45
- package/{action-ORXWW2ZG.js → action-76JX3JX3.js} +7 -6
- package/{addContentAction-53BZ34AE.js → addContentAction-V3NAZRTJ.js} +6 -5
- package/{addDialogAgentAction-JRYUS54Y.js → addDialogAgentAction-RZOAF46K.js} +5 -4
- package/{agentDeleteCommand-FJIWU2BS.js → agentDeleteCommand-VN7NPXQ4.js} +30 -27
- package/{agentEmailCommands-CE32L43B.js → agentEmailCommands-F2TNAV4A.js} +59 -56
- package/{agentGrantCommands-2LEZDADN.js → agentGrantCommands-R3VQEZJR.js} +1 -1
- package/{agentListCommands-VJNKULIK.js → agentListCommands-OSM2ANI3.js} +61 -31
- package/{agentMachineCommands-HCJ3WQXL.js → agentMachineCommands-MTPWYVRV.js} +31 -28
- package/{agentPullCommand-M552CYSI.js → agentPullCommand-N7L2CT7L.js} +2 -2
- package/{agentRecordCommands-QFWERED4.js → agentRecordCommands-VWAWTVVC.js} +57 -54
- package/{agentRunCommand-G3GQMUNN.js → agentRunCommand-PLZOBNVK.js} +61 -58
- package/{agentRunControl-INKFDXDA.js → agentRunControl-WECMOO6O.js} +11 -6
- package/{agentRuntimeLocal-K327ELSL.js → agentRuntimeLocal-XCJLRWQE.js} +26 -23
- package/{agentSlice-ODKF4J6M.js → agentSlice-F6DOP4IW.js} +8 -7
- package/{appDeleteCommands-XUXMFDI4.js → appDeleteCommands-3BCFTRFJ.js} +30 -27
- package/{appDeployCommands-37F4GPCU.js → appDeployCommands-B4GMHCYA.js} +30 -27
- package/{appDeployStatusCommands-WSPU7TUK.js → appDeployStatusCommands-4MN36WIG.js} +30 -27
- package/{appGetCommands-YLOBA3EM.js → appGetCommands-4GJIEUAX.js} +30 -27
- package/{appListCommands-UD62R5ME.js → appListCommands-CHU53GSX.js} +30 -27
- package/{authCommand-OK6HLHGS.js → authCommand-WOTWLJNF.js} +35 -29
- package/{authCommands-2DUIUEMT.js → authCommands-ILTBI6JV.js} +7 -5
- package/{chatQueueReduxAdapter-TV2TUOQS.js → chatQueueReduxAdapter-HNSQXNIR.js} +20 -18
- package/{chunk-HPW5MNDQ.js → chunk-22BTGNSP.js} +113 -57
- package/{chunk-TR4DXUYX.js → chunk-2HPRMEEZ.js} +1180 -736
- package/{chunk-UNZDCI3O.js → chunk-2KDR4CWE.js} +35 -4
- package/{chunk-3ZTR7ZO4.js → chunk-2PGGC63K.js} +1 -1
- package/{chunk-JXIP6ZWH.js → chunk-37QVS7BU.js} +18 -5
- package/{chunk-EA5OYZVD.js → chunk-37XDGCY7.js} +1 -1
- package/chunk-3BLB7QKO.js +433 -0
- package/{chunk-CS6TCJ7E.js → chunk-3JQ2NRYU.js} +30 -7
- package/{chunk-RHMDMTDK.js → chunk-3JWKQDA4.js} +2 -2
- package/{chunk-3LKZRP7E.js → chunk-3QGUVVX5.js} +2 -2
- package/{chunk-SSXTSPSG.js → chunk-45YO6H7P.js} +71 -30
- package/{chunk-EJE33XNR.js → chunk-4C4ST2YE.js} +1521 -565
- package/{chunk-YLCUU3WM.js → chunk-4NJEIGBQ.js} +5 -5
- package/{chunk-K4NISKOR.js → chunk-5ZYA4JJ3.js} +47 -17
- package/{chunk-3Y2K5O2R.js → chunk-7A3RRUCQ.js} +125 -40
- package/{chunk-5FCIPEKT.js → chunk-7O7KH4X5.js} +1051 -926
- package/{chunk-6HDYSFLO.js → chunk-7UF7CQ6B.js} +3 -3
- package/{chunk-SUEIAK5N.js → chunk-AQMVUA7N.js} +1 -0
- package/{chunk-WQHGJHAL.js → chunk-AVE2YR4F.js} +732 -726
- package/{chunk-6COJEAYH.js → chunk-B7DXRX7F.js} +44 -37
- package/chunk-BFU6C242.js +66 -0
- package/{chunk-IA3A5373.js → chunk-C3FZR5EC.js} +1 -1
- package/{chunk-IWUMSAQF.js → chunk-CJCJF5XB.js} +26 -3
- package/{chunk-UGBHDMHI.js → chunk-CP7VIDZ7.js} +1 -1
- package/{chunk-JON2PHYT.js → chunk-CTCW7U7N.js} +1 -1
- package/{chunk-YBFJQC2M.js → chunk-D5XKNNUV.js} +65 -42
- package/{chunk-7NYDJAQ7.js → chunk-DNNSCSA2.js} +5 -5
- package/{chunk-NI2BS6UD.js → chunk-DWUCB2A3.js} +1 -1
- package/{chunk-AA564GBL.js → chunk-DZZL7UBV.js} +1 -1
- package/{chunk-75MSWWUE.js → chunk-E6RGHPDR.js} +5 -3
- package/chunk-EDKF7RX4.js +30 -0
- package/{chunk-FJHMLRDQ.js → chunk-ES6CVKVD.js} +21 -27
- package/{chunk-SYYUU7EV.js → chunk-FHAGENAS.js} +2 -3
- package/{chunk-NJUQBYFJ.js → chunk-FKFMIBTT.js} +3 -1
- package/{chunk-INZZJSQF.js → chunk-FZGV4FGK.js} +24 -12
- package/{chunk-YQBXOHE6.js → chunk-GAL47RNP.js} +1 -1
- package/{chunk-UOWXD4VN.js → chunk-HBPV76EK.js} +335 -243
- package/{chunk-MLEZPE3U.js → chunk-HLU5Q2GV.js} +4 -4
- package/{chunk-TC6P4NDR.js → chunk-HQP7HJDL.js} +6 -6
- package/{chunk-7FAS3NEF.js → chunk-IYCUMIYS.js} +19 -15
- package/{chunk-AUVFJGPC.js → chunk-JX5PJCWS.js} +7 -5
- package/{chunk-LYGNQHUW.js → chunk-JYYZCK2Z.js} +2 -4
- package/{chunk-XOJRZUPF.js → chunk-KWSQR2KK.js} +14 -29
- package/{chunk-2WBFJHQA.js → chunk-L7B47JXR.js} +34 -39
- package/{chunk-EICIFHVS.js → chunk-LAFC3B2I.js} +1 -1
- package/{chunk-N4JKMCY3.js → chunk-LJKICKVC.js} +2 -2
- package/chunk-M3JEW6N6.js +193 -0
- package/{chunk-LRGKOI5Y.js → chunk-MBOEV4L2.js} +7 -3
- package/{chunk-SVDMVX4G.js → chunk-MMZ6ZTVO.js} +112 -73
- package/{chunk-JDSUTNYY.js → chunk-MP64VFGD.js} +2 -2
- package/{chunk-NFLA6GSU.js → chunk-MXUDQZXQ.js} +44 -5
- package/chunk-N4G4PKQ6.js +23 -0
- package/{chunk-KXKQO4Q6.js → chunk-NTW5GWDM.js} +58 -1
- package/chunk-ONXOABJR.js +215 -0
- package/{chunk-TY3ADTX5.js → chunk-OZX2IPKM.js} +7 -2
- package/{chunk-Q4XZVZPN.js → chunk-P7OOB7QP.js} +1 -1
- package/{chunk-XIJZOCSP.js → chunk-PEZJEQAO.js} +1 -1
- package/{chunk-SWJGJMTW.js → chunk-PQDIDWGX.js} +1 -1
- package/chunk-PSCNXBYA.js +11 -0
- package/{chunk-BY2FF2C4.js → chunk-QEFJJS2I.js} +55 -73
- package/{chunk-BG7J6Y5X.js → chunk-QEW2MFDQ.js} +1 -1
- package/{chunk-KLIBF3BY.js → chunk-RDBARW6T.js} +8 -3
- package/{chunk-ZVOHVJI3.js → chunk-RJ2SAFB5.js} +82 -35
- package/{chunk-MYMBBB6Q.js → chunk-RVWRKFUB.js} +5 -3
- package/{chunk-43CXXVJD.js → chunk-RXX4GDIH.js} +1 -1
- package/chunk-SEJ5OS6F.js +49 -0
- package/{chunk-SAJSBPI2.js → chunk-SOJM57FX.js} +5 -2
- package/{chunk-EKLRRZIN.js → chunk-SPAQ4PVV.js} +0 -5
- package/{chunk-L7NG2M6H.js → chunk-TRV2MIDW.js} +89 -74
- package/{chunk-5UAYZEXO.js → chunk-UZPQSVM6.js} +1 -1
- package/{chunk-SVC3GGUA.js → chunk-VMWYBIXG.js} +7 -5
- package/{chunk-ZHXJ6M7T.js → chunk-W7XHHYWM.js} +4 -0
- package/{chunk-UR66XPVF.js → chunk-XAVSS3KE.js} +21 -3
- package/{chunk-A65UV3M5.js → chunk-XOKOSO35.js} +10 -19
- package/{chunk-VZMUOPYG.js → chunk-XTJTN3RW.js} +46 -3
- package/{chunk-T5HJEUQN.js → chunk-YCDWJX45.js} +1 -1
- package/{chunk-BBTN4NQD.js → chunk-Z4QSJILV.js} +85 -13
- package/{chunk-O5FLGN2L.js → chunk-ZRSJ3JEH.js} +6 -2
- package/{cliExecutor-BBUVQU4L.js → cliExecutor-HG3S345O.js} +1 -1
- package/{codingSkills-BCQXRZOI.js → codingSkills-VDXQYWX4.js} +2 -2
- package/{contentThunks-KNI6VXLT.js → contentThunks-7YG2ZYQC.js} +21 -19
- package/{cooldownCommands-GI5NNWGL.js → cooldownCommands-BSCH2W7P.js} +2 -2
- package/{createAgentAutomationAction-OK4L33KF.js → createAgentAutomationAction-PJQSCAIO.js} +23 -21
- package/{createDialogAction-JDSMY4AY.js → createDialogAction-SFEJX6SP.js} +23 -21
- package/{createPageAction-T7RA3HCG.js → createPageAction-B7WRHOQO.js} +24 -22
- package/{dbSlice-TVX6SN2T.js → dbSlice-IBVOBVMS.js} +5 -4
- package/{deleteFile-JYKRT7C3.js → deleteFile-FWP2PSBG.js} +3 -2
- package/{dialogCommands-UQZYWOOV.js → dialogCommands-VL2X22QC.js} +30 -27
- package/{dialogSlice-TYW2G7IL.js → dialogSlice-ANMACABO.js} +20 -18
- package/{docCreateCommands-OA6HZBWO.js → docCreateCommands-ITLGZ5YI.js} +29 -26
- package/{docDeleteCommands-KBB3YQI2.js → docDeleteCommands-LH3YNL4C.js} +30 -27
- package/{docReadCommands-ZLMFVC67.js → docReadCommands-YAJ77F36.js} +29 -26
- package/{docStore-2URPBVCS.js → docStore-D4HGHPWI.js} +6 -5
- package/{docUpdateCommands-HMH5KUON.js → docUpdateCommands-DQBOMH2G.js} +29 -26
- package/{getPricing-RFOPUWHY.js → getPricing-NM3NUTAS.js} +4 -4
- package/handleSendMessageAction-DF2OABGW.js +675 -0
- package/index.js +79 -88
- package/{lib-2ZTNRXR4.js → lib-FRRS27KN.js} +63 -28
- package/{localRuntimeAuthority-KQDAE64E.js → localRuntimeAuthority-R5UBODT3.js} +6 -4
- package/{localRuntimeDb-PF7CFKDL.js → localRuntimeDb-P37ZTX55.js} +1 -1
- package/{machineCommands-RK6L7ZWL.js → machineCommands-JXDYQ5LB.js} +296 -79
- package/{machineWsRunDispatch-3X64DW2Z.js → machineWsRunDispatch-3QHI7JX5.js} +55 -52
- package/{memberThunks-THZYZFSN.js → memberThunks-VZI6G7YZ.js} +10 -8
- package/{models-JVKUEER5.js → models-FAMINFZ7.js} +2 -2
- package/package.json +3 -2
- package/{read-K4JU4MQC.js → read-2BYWW7AA.js} +3 -2
- package/{readDocTool-LQGR6FUN.js → readDocTool-LC3A7QTB.js} +1 -1
- package/{readlineWorkspace-XUFJV3RS.js → readlineWorkspace-KVZTEAHB.js} +4365 -2795
- package/{removeDialogAgentAction-ECHCFB7N.js → removeDialogAgentAction-SFYZXHNK.js} +8 -7
- package/{runAgentClientLoop-24GQ2AW6.js → runAgentClientLoop-KGTEL7ZP.js} +49 -45
- package/{runtimeDoctorCommands-JKTTN723.js → runtimeDoctorCommands-CROTMULY.js} +7 -5
- package/{setDialogExtraReferencesAction-KCVJNGMB.js → setDialogExtraReferencesAction-Q32RGFTA.js} +6 -5
- package/{setPrimaryDialogAgentAction-VDOBOMKC.js → setPrimaryDialogAgentAction-BFYJHUJS.js} +8 -7
- package/{settingSlice-VR2IJSXC.js → settingSlice-IRUU4VFB.js} +6 -5
- package/{skillDiscovery-2QTZINON.js → skillDiscovery-NTRLM6KP.js} +1 -1
- package/{spaceCommands-S5YJJXL7.js → spaceCommands-KNAYWMCZ.js} +33 -215
- package/{streamAgentChatTurn-QHKP3ABO.js → streamAgentChatTurn-FLYPTXKZ.js} +105 -73
- package/{switchDialogAgentAction-5L4UP7VI.js → switchDialogAgentAction-L2KOKCGG.js} +5 -4
- package/{tableCommands-R6WFRDYF.js → tableCommands-SUNTHAYX.js} +1 -1
- package/{toolApiClient-53U4UDFF.js → toolApiClient-VGYUB4P5.js} +2 -1
- package/{tools-SSXSTC3O.js → tools-CVLUXK6P.js} +37 -34
- package/{tuiSummaryLlmCaller-URFJHFC5.js → tuiSummaryLlmCaller-F3DPFFZM.js} +15 -13
- package/{updateCommands-IYKLF3JX.js → updateCommands-AJYSD73Y.js} +2 -2
- package/{updateDialogTitleAction-YFYAEW3T.js → updateDialogTitleAction-HWJIZEIV.js} +23 -21
- package/agentSuperviseCommands-5AR3DKNN.js +0 -640
- package/chunk-6IGD47IC.js +0 -19
- package/chunk-FD36SCCD.js +0 -105
- package/chunk-GRFK2XP4.js +0 -230
- package/chunk-HJTAGT3W.js +0 -370
- package/handleSendMessageAction-GO53TY7U.js +0 -409
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
import {
|
|
7
7
|
deleteDialog,
|
|
8
8
|
toast
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-D5XKNNUV.js";
|
|
10
10
|
import {
|
|
11
11
|
require_date_fns
|
|
12
12
|
} from "./chunk-M76ECQRD.js";
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
} from "./chunk-YDH3FDFQ.js";
|
|
16
16
|
import {
|
|
17
17
|
isSystemAdmin
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-VMWYBIXG.js";
|
|
19
19
|
import {
|
|
20
20
|
asRecordOrEmpty
|
|
21
21
|
} from "./chunk-KX6YBIHG.js";
|
|
@@ -24,7 +24,7 @@ import {
|
|
|
24
24
|
addContentAction,
|
|
25
25
|
checkSpaceMembership,
|
|
26
26
|
localSpaceAuthorityPatchStamp
|
|
27
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-RVWRKFUB.js";
|
|
28
28
|
import {
|
|
29
29
|
createSpaceKey,
|
|
30
30
|
normalizeSpaceId
|
|
@@ -38,7 +38,7 @@ import {
|
|
|
38
38
|
uploadFileAction,
|
|
39
39
|
upsertSSREntity,
|
|
40
40
|
write
|
|
41
|
-
} from "./chunk-
|
|
41
|
+
} from "./chunk-DNNSCSA2.js";
|
|
42
42
|
import {
|
|
43
43
|
SEPARATOR,
|
|
44
44
|
createKey,
|
|
@@ -61,19 +61,19 @@ import {
|
|
|
61
61
|
} from "./chunk-BJIRLHJR.js";
|
|
62
62
|
import {
|
|
63
63
|
DEVICE_LOCAL_OWNER_ID,
|
|
64
|
-
asyncThunkCreator,
|
|
65
|
-
buildCreateSlice,
|
|
66
64
|
createAsyncThunk,
|
|
67
65
|
getRuntimeServerContext,
|
|
68
66
|
isDeviceLocalSpaceBody,
|
|
69
67
|
resolveReplicationServers,
|
|
70
68
|
scheduleDeleteReplication,
|
|
71
|
-
scheduleWriteReplication
|
|
72
|
-
|
|
73
|
-
} from "./chunk-XOJRZUPF.js";
|
|
69
|
+
scheduleWriteReplication
|
|
70
|
+
} from "./chunk-KWSQR2KK.js";
|
|
74
71
|
import {
|
|
75
72
|
createClientLogger
|
|
76
73
|
} from "./chunk-QOKAKDPE.js";
|
|
74
|
+
import {
|
|
75
|
+
selectIdentityUserId
|
|
76
|
+
} from "./chunk-SEJ5OS6F.js";
|
|
77
77
|
import {
|
|
78
78
|
buildTombstoneRecord
|
|
79
79
|
} from "./chunk-GBRG75BQ.js";
|
|
@@ -207,7 +207,8 @@ var require_html_parse_stringify = __commonJS({
|
|
|
207
207
|
}
|
|
208
208
|
});
|
|
209
209
|
|
|
210
|
-
// packages/render/table/
|
|
210
|
+
// packages/render/table/tableStore.ts
|
|
211
|
+
var import_react9 = __toESM(require_react(), 1);
|
|
211
212
|
var import_date_fns2 = __toESM(require_date_fns(), 1);
|
|
212
213
|
import { ulid as ulid3 } from "ulid";
|
|
213
214
|
|
|
@@ -3148,8 +3149,8 @@ var createTableAction = async ({
|
|
|
3148
3149
|
columns,
|
|
3149
3150
|
withDefaultRows = true
|
|
3150
3151
|
} = {}, { dispatch, getState }) => {
|
|
3151
|
-
const
|
|
3152
|
-
const userId = selectIdentityUserId(
|
|
3152
|
+
const state3 = getState();
|
|
3153
|
+
const userId = selectIdentityUserId(state3);
|
|
3153
3154
|
if (!userId) throw new Error("User ID not found.");
|
|
3154
3155
|
const spaceId = customSpaceId ?? getCurrentSpaceId();
|
|
3155
3156
|
const tableId = ulid2();
|
|
@@ -3279,8 +3280,8 @@ var deleteTableAction = async ({ dbKey }, {
|
|
|
3279
3280
|
extra
|
|
3280
3281
|
}) => {
|
|
3281
3282
|
const { db } = extra;
|
|
3282
|
-
const
|
|
3283
|
-
const { currentServer, syncServers } = getRuntimeServerContext(
|
|
3283
|
+
const state3 = getState();
|
|
3284
|
+
const { currentServer, syncServers } = getRuntimeServerContext(state3);
|
|
3284
3285
|
const { tenantId, tableId } = parseMetaKey(dbKey);
|
|
3285
3286
|
const nowIso = (/* @__PURE__ */ new Date()).toISOString();
|
|
3286
3287
|
const rowPrefix = createKey("row", tenantId, tableId, "");
|
|
@@ -3335,726 +3336,732 @@ var deleteTableAction = async ({ dbKey }, {
|
|
|
3335
3336
|
syncServers,
|
|
3336
3337
|
dbKey,
|
|
3337
3338
|
deleteOptions: { type: "table" },
|
|
3338
|
-
state:
|
|
3339
|
+
state: state3
|
|
3339
3340
|
});
|
|
3340
3341
|
return dbKey;
|
|
3341
3342
|
};
|
|
3342
3343
|
|
|
3343
|
-
// packages/render/table/
|
|
3344
|
-
|
|
3344
|
+
// packages/render/table/tableStore.ts
|
|
3345
|
+
async function safeDispatch(dispatch, action) {
|
|
3346
|
+
if (!dispatch) return void 0;
|
|
3347
|
+
const res = await dispatch(action);
|
|
3348
|
+
if (res && typeof res.unwrap === "function") {
|
|
3349
|
+
return await res.unwrap();
|
|
3350
|
+
}
|
|
3351
|
+
return res?.payload ?? res;
|
|
3352
|
+
}
|
|
3353
|
+
var createInitialState = () => ({
|
|
3345
3354
|
currentTable: null,
|
|
3346
3355
|
isLoading: false,
|
|
3347
3356
|
isInitialized: false,
|
|
3348
3357
|
error: null,
|
|
3349
3358
|
rows: [],
|
|
3350
3359
|
focusContext: null
|
|
3351
|
-
};
|
|
3352
|
-
var createSliceWithThunks = buildCreateSlice({
|
|
3353
|
-
creators: { asyncThunk: asyncThunkCreator }
|
|
3354
3360
|
});
|
|
3355
|
-
var
|
|
3356
|
-
|
|
3357
|
-
|
|
3358
|
-
|
|
3359
|
-
|
|
3360
|
-
|
|
3361
|
-
|
|
3362
|
-
|
|
3363
|
-
|
|
3364
|
-
|
|
3365
|
-
|
|
3366
|
-
|
|
3367
|
-
|
|
3368
|
-
|
|
3369
|
-
|
|
3370
|
-
|
|
3371
|
-
|
|
3372
|
-
|
|
3373
|
-
|
|
3374
|
-
|
|
3375
|
-
|
|
3376
|
-
|
|
3361
|
+
var listeners = /* @__PURE__ */ new Set();
|
|
3362
|
+
var version = 0;
|
|
3363
|
+
var state = createInitialState();
|
|
3364
|
+
var notify = () => {
|
|
3365
|
+
for (const listener of listeners) {
|
|
3366
|
+
try {
|
|
3367
|
+
listener();
|
|
3368
|
+
} catch {
|
|
3369
|
+
}
|
|
3370
|
+
}
|
|
3371
|
+
};
|
|
3372
|
+
var bump = () => {
|
|
3373
|
+
version += 1;
|
|
3374
|
+
notify();
|
|
3375
|
+
};
|
|
3376
|
+
var setState = (updater) => {
|
|
3377
|
+
state = typeof updater === "function" ? updater(state) : updater;
|
|
3378
|
+
bump();
|
|
3379
|
+
};
|
|
3380
|
+
function getTableState() {
|
|
3381
|
+
return state;
|
|
3382
|
+
}
|
|
3383
|
+
function createTableCommand(name, fn) {
|
|
3384
|
+
const command = (args) => {
|
|
3385
|
+
return async (dispatch, getState, extra) => {
|
|
3386
|
+
try {
|
|
3387
|
+
const payload = await fn(args, { dispatch, getState, extra });
|
|
3388
|
+
return {
|
|
3389
|
+
type: `${name}/fulfilled`,
|
|
3390
|
+
payload,
|
|
3391
|
+
meta: { arg: args },
|
|
3392
|
+
unwrap: async () => payload
|
|
3393
|
+
};
|
|
3394
|
+
} catch (err2) {
|
|
3395
|
+
const message = err2?.message || String(err2);
|
|
3396
|
+
return {
|
|
3397
|
+
type: `${name}/rejected`,
|
|
3398
|
+
payload: message,
|
|
3399
|
+
error: { message },
|
|
3400
|
+
unwrap: async () => {
|
|
3401
|
+
throw err2 instanceof Error ? err2 : new Error(message);
|
|
3377
3402
|
}
|
|
3378
|
-
|
|
3379
|
-
return rejectWithValue(msg);
|
|
3380
|
-
} catch (e) {
|
|
3381
|
-
return rejectWithValue(e.message || `\u521D\u59CB\u5316\u8868 ${tableId} \u65F6\u51FA\u9519`);
|
|
3382
|
-
}
|
|
3383
|
-
},
|
|
3384
|
-
{
|
|
3385
|
-
pending: (state2) => {
|
|
3386
|
-
state2.isLoading = true;
|
|
3387
|
-
state2.error = null;
|
|
3388
|
-
state2.isInitialized = false;
|
|
3389
|
-
state2.currentTable = null;
|
|
3390
|
-
state2.rows = [];
|
|
3391
|
-
},
|
|
3392
|
-
fulfilled: (state2, action) => {
|
|
3393
|
-
state2.isLoading = false;
|
|
3394
|
-
state2.isInitialized = true;
|
|
3395
|
-
state2.currentTable = action.payload;
|
|
3396
|
-
state2.error = null;
|
|
3397
|
-
},
|
|
3398
|
-
rejected: (state2, action) => {
|
|
3399
|
-
state2.isLoading = false;
|
|
3400
|
-
state2.isInitialized = true;
|
|
3401
|
-
state2.currentTable = null;
|
|
3402
|
-
state2.error = action.payload || action.error.message || "\u521D\u59CB\u5316\u8868\u65F6\u53D1\u751F\u672A\u77E5\u9519\u8BEF";
|
|
3403
|
-
state2.rows = [];
|
|
3404
|
-
}
|
|
3403
|
+
};
|
|
3405
3404
|
}
|
|
3406
|
-
|
|
3407
|
-
|
|
3408
|
-
|
|
3409
|
-
|
|
3410
|
-
|
|
3411
|
-
|
|
3412
|
-
|
|
3413
|
-
|
|
3414
|
-
|
|
3415
|
-
|
|
3416
|
-
|
|
3417
|
-
|
|
3418
|
-
|
|
3419
|
-
|
|
3420
|
-
|
|
3421
|
-
|
|
3422
|
-
|
|
3423
|
-
|
|
3424
|
-
|
|
3425
|
-
|
|
3426
|
-
|
|
3427
|
-
|
|
3428
|
-
|
|
3429
|
-
|
|
3430
|
-
|
|
3431
|
-
|
|
3432
|
-
|
|
3433
|
-
|
|
3434
|
-
|
|
3435
|
-
|
|
3436
|
-
|
|
3437
|
-
|
|
3438
|
-
|
|
3405
|
+
};
|
|
3406
|
+
};
|
|
3407
|
+
command.fulfilled = {
|
|
3408
|
+
type: `${name}/fulfilled`,
|
|
3409
|
+
match: (action) => action?.type === `${name}/fulfilled`
|
|
3410
|
+
};
|
|
3411
|
+
command.rejected = {
|
|
3412
|
+
type: `${name}/rejected`,
|
|
3413
|
+
match: (action) => action?.type === `${name}/rejected`
|
|
3414
|
+
};
|
|
3415
|
+
command.pending = {
|
|
3416
|
+
type: `${name}/pending`,
|
|
3417
|
+
match: (action) => action?.type === `${name}/pending`
|
|
3418
|
+
};
|
|
3419
|
+
command.run = (args, context = {}) => fn(args, context);
|
|
3420
|
+
return command;
|
|
3421
|
+
}
|
|
3422
|
+
var initTable = createTableCommand(
|
|
3423
|
+
"table/initTable",
|
|
3424
|
+
async (args, { dispatch } = {}) => {
|
|
3425
|
+
const { tenantId, tableId } = args;
|
|
3426
|
+
const dbKey = metaKey(tenantId, tableId);
|
|
3427
|
+
setState((s) => ({
|
|
3428
|
+
...s,
|
|
3429
|
+
isLoading: true,
|
|
3430
|
+
error: null,
|
|
3431
|
+
isInitialized: false,
|
|
3432
|
+
currentTable: null,
|
|
3433
|
+
rows: []
|
|
3434
|
+
}));
|
|
3435
|
+
try {
|
|
3436
|
+
if (!dispatch) {
|
|
3437
|
+
throw new Error("dispatch is required to initialize table");
|
|
3439
3438
|
}
|
|
3440
|
-
|
|
3441
|
-
|
|
3442
|
-
|
|
3443
|
-
|
|
3444
|
-
|
|
3445
|
-
|
|
3446
|
-
|
|
3447
|
-
|
|
3448
|
-
|
|
3449
|
-
|
|
3450
|
-
|
|
3451
|
-
|
|
3452
|
-
tenantId,
|
|
3453
|
-
tableId,
|
|
3454
|
-
rowId,
|
|
3455
|
-
createdAt: nowIso,
|
|
3456
|
-
updatedAt: nowIso,
|
|
3457
|
-
type: "table_row" /* TABLE_ROW */,
|
|
3458
|
-
...values
|
|
3459
|
-
};
|
|
3460
|
-
await dispatch(
|
|
3461
|
-
write({
|
|
3462
|
-
data: row,
|
|
3463
|
-
customKey: dbKey
|
|
3464
|
-
})
|
|
3465
|
-
).unwrap();
|
|
3466
|
-
return row;
|
|
3467
|
-
} catch (e) {
|
|
3468
|
-
return rejectWithValue(e.message || "\u65B0\u589E\u8868\u884C\u5931\u8D25");
|
|
3469
|
-
}
|
|
3470
|
-
},
|
|
3471
|
-
{
|
|
3472
|
-
pending: (state2) => {
|
|
3473
|
-
state2.error = null;
|
|
3474
|
-
},
|
|
3475
|
-
fulfilled: (state2, action) => {
|
|
3476
|
-
const row = action.payload;
|
|
3477
|
-
const meta = state2.currentTable;
|
|
3478
|
-
if (meta && row?.tenantId === meta.tenantId && row?.tableId === meta.tableId) {
|
|
3479
|
-
state2.rows.push(row);
|
|
3480
|
-
}
|
|
3481
|
-
},
|
|
3482
|
-
rejected: (state2, action) => {
|
|
3483
|
-
state2.error = action.payload || action.error.message || "\u65B0\u589E\u8868\u884C\u65F6\u53D1\u751F\u672A\u77E5\u9519\u8BEF";
|
|
3484
|
-
}
|
|
3439
|
+
const readAction = await dispatch(readAndWait(dbKey));
|
|
3440
|
+
const isMatch = typeof readAndWait?.fulfilled?.match === "function" && readAndWait.fulfilled.match(readAction);
|
|
3441
|
+
const meta = isMatch && readAction.payload ? readAction.payload : readAction?.payload || readAction;
|
|
3442
|
+
if (meta && typeof meta === "object" && ("columns" in meta || "displayName" in meta || "tableId" in meta)) {
|
|
3443
|
+
setState((s) => ({
|
|
3444
|
+
...s,
|
|
3445
|
+
isLoading: false,
|
|
3446
|
+
isInitialized: true,
|
|
3447
|
+
currentTable: meta,
|
|
3448
|
+
error: null
|
|
3449
|
+
}));
|
|
3450
|
+
return meta;
|
|
3485
3451
|
}
|
|
3486
|
-
|
|
3487
|
-
|
|
3488
|
-
|
|
3489
|
-
|
|
3490
|
-
|
|
3491
|
-
|
|
3492
|
-
|
|
3493
|
-
|
|
3494
|
-
|
|
3495
|
-
|
|
3496
|
-
|
|
3497
|
-
|
|
3498
|
-
|
|
3499
|
-
|
|
3500
|
-
|
|
3501
|
-
|
|
3502
|
-
|
|
3503
|
-
|
|
3504
|
-
|
|
3505
|
-
|
|
3506
|
-
|
|
3507
|
-
|
|
3508
|
-
|
|
3509
|
-
|
|
3510
|
-
|
|
3511
|
-
|
|
3512
|
-
|
|
3513
|
-
|
|
3514
|
-
|
|
3515
|
-
|
|
3516
|
-
|
|
3517
|
-
|
|
3518
|
-
|
|
3519
|
-
|
|
3520
|
-
|
|
3521
|
-
|
|
3452
|
+
const msg = readAction.payload?.message || `\u65E0\u6CD5\u52A0\u8F7D\u8868 ${tableId}`;
|
|
3453
|
+
setState((s) => ({
|
|
3454
|
+
...s,
|
|
3455
|
+
isLoading: false,
|
|
3456
|
+
isInitialized: true,
|
|
3457
|
+
currentTable: null,
|
|
3458
|
+
error: msg,
|
|
3459
|
+
rows: []
|
|
3460
|
+
}));
|
|
3461
|
+
throw new Error(msg);
|
|
3462
|
+
} catch (e) {
|
|
3463
|
+
const msg = e?.message || `\u521D\u59CB\u5316\u8868 ${tableId} \u65F6\u51FA\u9519`;
|
|
3464
|
+
setState((s) => ({
|
|
3465
|
+
...s,
|
|
3466
|
+
isLoading: false,
|
|
3467
|
+
isInitialized: true,
|
|
3468
|
+
currentTable: null,
|
|
3469
|
+
error: msg,
|
|
3470
|
+
rows: []
|
|
3471
|
+
}));
|
|
3472
|
+
throw e;
|
|
3473
|
+
}
|
|
3474
|
+
}
|
|
3475
|
+
);
|
|
3476
|
+
var loadTableRows = createTableCommand(
|
|
3477
|
+
"table/loadTableRows",
|
|
3478
|
+
async (args, { getState, extra } = {}) => {
|
|
3479
|
+
const { tenantId, tableId } = args;
|
|
3480
|
+
const db = extra?.db;
|
|
3481
|
+
setState((s) => {
|
|
3482
|
+
if (s.currentTable && s.currentTable.tenantId === tenantId && s.currentTable.tableId === tableId) {
|
|
3483
|
+
return { ...s, error: null };
|
|
3484
|
+
}
|
|
3485
|
+
return s;
|
|
3486
|
+
});
|
|
3487
|
+
try {
|
|
3488
|
+
const stateObj = getState ? getState() : {};
|
|
3489
|
+
const { currentToken: token, remoteServers } = getRuntimeServerContext(stateObj);
|
|
3490
|
+
const rows = await fetchAndCacheTableRows({
|
|
3491
|
+
db,
|
|
3492
|
+
tenantId,
|
|
3493
|
+
tableId,
|
|
3494
|
+
token,
|
|
3495
|
+
remoteServers
|
|
3496
|
+
});
|
|
3497
|
+
setState((s) => {
|
|
3498
|
+
if (s.currentTable && s.currentTable.tenantId === tenantId && s.currentTable.tableId === tableId) {
|
|
3499
|
+
return { ...s, rows };
|
|
3522
3500
|
}
|
|
3523
|
-
|
|
3524
|
-
|
|
3525
|
-
|
|
3526
|
-
|
|
3527
|
-
|
|
3528
|
-
|
|
3529
|
-
|
|
3530
|
-
|
|
3531
|
-
},
|
|
3532
|
-
rejected: (state2, action) => {
|
|
3533
|
-
state2.error = action.payload || action.error.message || "\u5220\u9664\u8868\u884C\u65F6\u53D1\u751F\u672A\u77E5\u9519\u8BEF";
|
|
3501
|
+
return s;
|
|
3502
|
+
});
|
|
3503
|
+
return rows;
|
|
3504
|
+
} catch (e) {
|
|
3505
|
+
const msg = e?.message || "\u52A0\u8F7D\u8868\u884C\u5931\u8D25";
|
|
3506
|
+
setState((s) => {
|
|
3507
|
+
if (s.currentTable && s.currentTable.tenantId === tenantId && s.currentTable.tableId === tableId) {
|
|
3508
|
+
return { ...s, error: msg, rows: [] };
|
|
3534
3509
|
}
|
|
3510
|
+
return s;
|
|
3511
|
+
});
|
|
3512
|
+
throw e;
|
|
3513
|
+
}
|
|
3514
|
+
}
|
|
3515
|
+
);
|
|
3516
|
+
var addRow = createTableCommand(
|
|
3517
|
+
"table/addRow",
|
|
3518
|
+
async (args, { dispatch } = {}) => {
|
|
3519
|
+
const { tenantId, tableId, values } = args;
|
|
3520
|
+
setState((s) => {
|
|
3521
|
+
if (s.currentTable && s.currentTable.tenantId === tenantId && s.currentTable.tableId === tableId) {
|
|
3522
|
+
return { ...s, error: null };
|
|
3535
3523
|
}
|
|
3536
|
-
|
|
3537
|
-
|
|
3538
|
-
|
|
3539
|
-
|
|
3540
|
-
|
|
3541
|
-
|
|
3542
|
-
|
|
3543
|
-
|
|
3544
|
-
|
|
3545
|
-
|
|
3546
|
-
|
|
3547
|
-
|
|
3548
|
-
|
|
3549
|
-
|
|
3550
|
-
|
|
3551
|
-
|
|
3552
|
-
|
|
3553
|
-
|
|
3554
|
-
|
|
3555
|
-
|
|
3556
|
-
|
|
3524
|
+
return s;
|
|
3525
|
+
});
|
|
3526
|
+
try {
|
|
3527
|
+
const { dbKey, rowId } = rowKey.create(tenantId, tableId);
|
|
3528
|
+
const nowIso = (0, import_date_fns2.formatISO)(/* @__PURE__ */ new Date());
|
|
3529
|
+
const row = {
|
|
3530
|
+
dbKey,
|
|
3531
|
+
tenantId,
|
|
3532
|
+
tableId,
|
|
3533
|
+
rowId,
|
|
3534
|
+
createdAt: nowIso,
|
|
3535
|
+
updatedAt: nowIso,
|
|
3536
|
+
type: "table_row" /* TABLE_ROW */,
|
|
3537
|
+
...values
|
|
3538
|
+
};
|
|
3539
|
+
if (dispatch) {
|
|
3540
|
+
await safeDispatch(
|
|
3541
|
+
dispatch,
|
|
3542
|
+
write({
|
|
3543
|
+
data: row,
|
|
3544
|
+
customKey: dbKey
|
|
3545
|
+
})
|
|
3546
|
+
);
|
|
3557
3547
|
}
|
|
3558
|
-
|
|
3559
|
-
|
|
3560
|
-
|
|
3561
|
-
|
|
3562
|
-
addColumn: create.asyncThunk(
|
|
3563
|
-
async (args, { dispatch, getState, rejectWithValue }) => {
|
|
3564
|
-
const { tenantId, tableId, columnName } = args;
|
|
3565
|
-
const state2 = getState().table;
|
|
3566
|
-
const meta = state2.currentTable;
|
|
3567
|
-
if (!meta || meta.tenantId !== tenantId || meta.tableId !== tableId) {
|
|
3568
|
-
return rejectWithValue("\u5F53\u524D\u6CA1\u6709\u52A0\u8F7D\u5BF9\u5E94\u7684\u8868\u5B9A\u4E49");
|
|
3548
|
+
setState((s) => {
|
|
3549
|
+
const meta = s.currentTable;
|
|
3550
|
+
if (meta && row?.tenantId === meta.tenantId && row?.tableId === meta.tableId) {
|
|
3551
|
+
return { ...s, rows: [...s.rows, row] };
|
|
3569
3552
|
}
|
|
3570
|
-
|
|
3571
|
-
|
|
3572
|
-
|
|
3573
|
-
|
|
3574
|
-
|
|
3575
|
-
|
|
3576
|
-
|
|
3553
|
+
return s;
|
|
3554
|
+
});
|
|
3555
|
+
return row;
|
|
3556
|
+
} catch (e) {
|
|
3557
|
+
const msg = e?.message || "\u65B0\u589E\u8868\u884C\u5931\u8D25";
|
|
3558
|
+
setState((s) => {
|
|
3559
|
+
if (s.currentTable && s.currentTable.tenantId === tenantId && s.currentTable.tableId === tableId) {
|
|
3560
|
+
return { ...s, error: msg };
|
|
3577
3561
|
}
|
|
3562
|
+
return s;
|
|
3563
|
+
});
|
|
3564
|
+
throw e;
|
|
3565
|
+
}
|
|
3566
|
+
}
|
|
3567
|
+
);
|
|
3568
|
+
var deleteRow = createTableCommand(
|
|
3569
|
+
"table/deleteRow",
|
|
3570
|
+
async (dbKey, { dispatch, getState, extra } = {}) => {
|
|
3571
|
+
try {
|
|
3572
|
+
let row = state.rows.find((item) => item?.dbKey === dbKey);
|
|
3573
|
+
if (!row && extra?.db && typeof extra.db.get === "function") {
|
|
3578
3574
|
try {
|
|
3579
|
-
await
|
|
3580
|
-
|
|
3581
|
-
dbKey: meta.dbKey,
|
|
3582
|
-
changes: result.value.metaChanges
|
|
3583
|
-
})
|
|
3584
|
-
).unwrap();
|
|
3585
|
-
return result.value.meta;
|
|
3586
|
-
} catch (e) {
|
|
3587
|
-
return rejectWithValue(e.message || "\u6DFB\u52A0\u5B57\u6BB5\u5931\u8D25");
|
|
3588
|
-
}
|
|
3589
|
-
},
|
|
3590
|
-
{
|
|
3591
|
-
pending: (state2) => {
|
|
3592
|
-
state2.error = null;
|
|
3593
|
-
},
|
|
3594
|
-
fulfilled: (state2, action) => {
|
|
3595
|
-
state2.currentTable = action.payload;
|
|
3596
|
-
state2.isInitialized = true;
|
|
3597
|
-
},
|
|
3598
|
-
rejected: (state2, action) => {
|
|
3599
|
-
state2.error = action.payload || action.error.message || "\u4E3A\u8868\u65B0\u589E\u5B57\u6BB5\u65F6\u53D1\u751F\u672A\u77E5\u9519\u8BEF";
|
|
3575
|
+
row = await extra.db.get(dbKey);
|
|
3576
|
+
} catch {
|
|
3600
3577
|
}
|
|
3601
3578
|
}
|
|
3602
|
-
|
|
3603
|
-
/* --------------------------------------
|
|
3604
|
-
* 4.1 删除字段:deleteColumn
|
|
3605
|
-
* ------------------------------------*/
|
|
3606
|
-
deleteColumn: create.asyncThunk(
|
|
3607
|
-
async (args, { dispatch, getState, rejectWithValue }) => {
|
|
3608
|
-
const { tenantId, tableId, columnName } = args;
|
|
3609
|
-
const state2 = getState().table;
|
|
3610
|
-
const meta = state2.currentTable;
|
|
3611
|
-
if (!meta || meta.tenantId !== tenantId || meta.tableId !== tableId) {
|
|
3612
|
-
return rejectWithValue("\u5F53\u524D\u6CA1\u6709\u52A0\u8F7D\u5BF9\u5E94\u7684\u8868\u5B9A\u4E49");
|
|
3613
|
-
}
|
|
3614
|
-
const result = deleteColumnFromMeta(
|
|
3615
|
-
meta,
|
|
3616
|
-
state2.rows,
|
|
3617
|
-
{ columnName },
|
|
3618
|
-
{ nowIso: (0, import_date_fns2.formatISO)(/* @__PURE__ */ new Date()) }
|
|
3619
|
-
);
|
|
3620
|
-
if (!result.ok) {
|
|
3621
|
-
return rejectWithValue(result.error);
|
|
3622
|
-
}
|
|
3623
|
-
const { meta: nextMeta, metaChanges, rows: newRows, rowPatches } = result.value;
|
|
3579
|
+
if (!row && dispatch) {
|
|
3624
3580
|
try {
|
|
3625
|
-
await
|
|
3626
|
-
|
|
3627
|
-
|
|
3628
|
-
await dispatch(
|
|
3629
|
-
patch({ dbKey: meta.dbKey, changes: metaChanges })
|
|
3630
|
-
).unwrap();
|
|
3631
|
-
return { meta: nextMeta, rows: newRows };
|
|
3632
|
-
} catch (e) {
|
|
3633
|
-
return rejectWithValue(e.message || "\u5220\u9664\u5B57\u6BB5\u5931\u8D25");
|
|
3581
|
+
const readAction = await safeDispatch(dispatch, readAndWait(dbKey));
|
|
3582
|
+
row = readAction?.payload || readAction;
|
|
3583
|
+
} catch {
|
|
3634
3584
|
}
|
|
3635
|
-
}
|
|
3636
|
-
{
|
|
3637
|
-
|
|
3638
|
-
|
|
3639
|
-
|
|
3640
|
-
|
|
3641
|
-
|
|
3642
|
-
|
|
3643
|
-
|
|
3585
|
+
}
|
|
3586
|
+
if (!row) {
|
|
3587
|
+
throw new Error(`\u5F53\u524D\u8868\u4E2D\u627E\u4E0D\u5230\u8981\u5220\u9664\u7684\u884C\uFF1A${dbKey}`);
|
|
3588
|
+
}
|
|
3589
|
+
const nowIso = (0, import_date_fns2.formatISO)(/* @__PURE__ */ new Date());
|
|
3590
|
+
const tombstoneRow = {
|
|
3591
|
+
...row,
|
|
3592
|
+
deletedAt: nowIso,
|
|
3593
|
+
updatedAt: nowIso,
|
|
3594
|
+
type: "table_row" /* TABLE_ROW */
|
|
3595
|
+
};
|
|
3596
|
+
if (extra?.db && typeof extra.db.put === "function") {
|
|
3597
|
+
await extra.db.put(dbKey, tombstoneRow);
|
|
3598
|
+
}
|
|
3599
|
+
if (dispatch) {
|
|
3600
|
+
dispatch(upsertSSREntity(tombstoneRow));
|
|
3601
|
+
}
|
|
3602
|
+
const stateObj = getState ? getState() : {};
|
|
3603
|
+
const { currentServer, syncServers } = getRuntimeServerContext(stateObj);
|
|
3604
|
+
const servers = resolveReplicationServers(currentServer, syncServers);
|
|
3605
|
+
scheduleWriteReplication(
|
|
3606
|
+
servers,
|
|
3607
|
+
{
|
|
3608
|
+
data: tombstoneRow,
|
|
3609
|
+
customKey: dbKey
|
|
3644
3610
|
},
|
|
3645
|
-
|
|
3646
|
-
|
|
3611
|
+
stateObj
|
|
3612
|
+
);
|
|
3613
|
+
setState((s) => ({
|
|
3614
|
+
...s,
|
|
3615
|
+
rows: s.rows.filter((r) => r.dbKey !== dbKey)
|
|
3616
|
+
}));
|
|
3617
|
+
return dbKey;
|
|
3618
|
+
} catch (e) {
|
|
3619
|
+
const msg = e?.message || "\u5220\u9664\u8868\u884C\u5931\u8D25";
|
|
3620
|
+
setState((s) => ({ ...s, error: msg }));
|
|
3621
|
+
throw e;
|
|
3622
|
+
}
|
|
3623
|
+
}
|
|
3624
|
+
);
|
|
3625
|
+
var createTable = createTableCommand(
|
|
3626
|
+
"table/createTable",
|
|
3627
|
+
async (args, context = {}) => {
|
|
3628
|
+
return await createTableAction(args, context);
|
|
3629
|
+
}
|
|
3630
|
+
);
|
|
3631
|
+
var deleteTable = createTableCommand(
|
|
3632
|
+
"table/deleteTable",
|
|
3633
|
+
async (args, context = {}) => {
|
|
3634
|
+
setState((s) => ({ ...s, error: null }));
|
|
3635
|
+
try {
|
|
3636
|
+
const deletedKey = await deleteTableAction(args, context);
|
|
3637
|
+
setState((s) => {
|
|
3638
|
+
if (s.currentTable?.dbKey === deletedKey) {
|
|
3639
|
+
return {
|
|
3640
|
+
...s,
|
|
3641
|
+
currentTable: null,
|
|
3642
|
+
rows: [],
|
|
3643
|
+
isInitialized: false
|
|
3644
|
+
};
|
|
3647
3645
|
}
|
|
3646
|
+
return s;
|
|
3647
|
+
});
|
|
3648
|
+
return deletedKey;
|
|
3649
|
+
} catch (e) {
|
|
3650
|
+
const msg = e?.message || "\u5220\u9664\u8868\u65F6\u53D1\u751F\u672A\u77E5\u9519\u8BEF";
|
|
3651
|
+
setState((s) => ({ ...s, error: msg }));
|
|
3652
|
+
throw e;
|
|
3653
|
+
}
|
|
3654
|
+
}
|
|
3655
|
+
);
|
|
3656
|
+
var addColumn = createTableCommand(
|
|
3657
|
+
"table/addColumn",
|
|
3658
|
+
async (args, { dispatch } = {}) => {
|
|
3659
|
+
const { tenantId, tableId, columnName } = args;
|
|
3660
|
+
const meta = state.currentTable;
|
|
3661
|
+
if (!meta || meta.tenantId !== tenantId || meta.tableId !== tableId) {
|
|
3662
|
+
throw new Error("\u5F53\u524D\u6CA1\u6709\u52A0\u8F7D\u5BF9\u5E94\u7684\u8868\u5B9A\u4E49");
|
|
3663
|
+
}
|
|
3664
|
+
const result = addColumnToMeta(
|
|
3665
|
+
meta,
|
|
3666
|
+
{ columnName },
|
|
3667
|
+
{ id: ulid3(), nowIso: (0, import_date_fns2.formatISO)(/* @__PURE__ */ new Date()) }
|
|
3668
|
+
);
|
|
3669
|
+
if (!result.ok) {
|
|
3670
|
+
throw new Error(result.error);
|
|
3671
|
+
}
|
|
3672
|
+
setState((s) => ({ ...s, error: null }));
|
|
3673
|
+
try {
|
|
3674
|
+
if (dispatch) {
|
|
3675
|
+
await safeDispatch(
|
|
3676
|
+
dispatch,
|
|
3677
|
+
patch({
|
|
3678
|
+
dbKey: meta.dbKey,
|
|
3679
|
+
changes: result.value.metaChanges
|
|
3680
|
+
})
|
|
3681
|
+
);
|
|
3648
3682
|
}
|
|
3649
|
-
|
|
3650
|
-
|
|
3651
|
-
|
|
3652
|
-
|
|
3653
|
-
|
|
3654
|
-
|
|
3655
|
-
|
|
3656
|
-
|
|
3657
|
-
|
|
3658
|
-
|
|
3659
|
-
|
|
3660
|
-
|
|
3661
|
-
|
|
3662
|
-
|
|
3663
|
-
|
|
3664
|
-
|
|
3683
|
+
setState((s) => ({
|
|
3684
|
+
...s,
|
|
3685
|
+
currentTable: result.value.meta,
|
|
3686
|
+
isInitialized: true
|
|
3687
|
+
}));
|
|
3688
|
+
return result.value.meta;
|
|
3689
|
+
} catch (e) {
|
|
3690
|
+
const msg = e?.message || "\u6DFB\u52A0\u5B57\u6BB5\u5931\u8D25";
|
|
3691
|
+
setState((s) => ({ ...s, error: msg }));
|
|
3692
|
+
throw e;
|
|
3693
|
+
}
|
|
3694
|
+
}
|
|
3695
|
+
);
|
|
3696
|
+
var deleteColumn = createTableCommand(
|
|
3697
|
+
"table/deleteColumn",
|
|
3698
|
+
async (args, { dispatch } = {}) => {
|
|
3699
|
+
const { tenantId, tableId, columnName } = args;
|
|
3700
|
+
const meta = state.currentTable;
|
|
3701
|
+
if (!meta || meta.tenantId !== tenantId || meta.tableId !== tableId) {
|
|
3702
|
+
throw new Error("\u5F53\u524D\u6CA1\u6709\u52A0\u8F7D\u5BF9\u5E94\u7684\u8868\u5B9A\u4E49");
|
|
3703
|
+
}
|
|
3704
|
+
const result = deleteColumnFromMeta(
|
|
3705
|
+
meta,
|
|
3706
|
+
state.rows,
|
|
3707
|
+
{ columnName },
|
|
3708
|
+
{ nowIso: (0, import_date_fns2.formatISO)(/* @__PURE__ */ new Date()) }
|
|
3709
|
+
);
|
|
3710
|
+
if (!result.ok) {
|
|
3711
|
+
throw new Error(result.error);
|
|
3712
|
+
}
|
|
3713
|
+
const { meta: nextMeta, metaChanges, rows: newRows, rowPatches } = result.value;
|
|
3714
|
+
setState((s) => ({ ...s, error: null }));
|
|
3715
|
+
try {
|
|
3716
|
+
if (dispatch) {
|
|
3717
|
+
await Promise.all(
|
|
3718
|
+
rowPatches.map((p) => safeDispatch(dispatch, patch(p)))
|
|
3719
|
+
);
|
|
3720
|
+
await safeDispatch(
|
|
3721
|
+
dispatch,
|
|
3722
|
+
patch({ dbKey: meta.dbKey, changes: metaChanges })
|
|
3665
3723
|
);
|
|
3666
|
-
if (!result.ok) {
|
|
3667
|
-
return rejectWithValue(result.error);
|
|
3668
|
-
}
|
|
3669
|
-
if (result.value.noop) {
|
|
3670
|
-
return meta;
|
|
3671
|
-
}
|
|
3672
|
-
const { meta: nextMeta, metaChanges } = result.value;
|
|
3673
|
-
try {
|
|
3674
|
-
await dispatch(
|
|
3675
|
-
patch({ dbKey: meta.dbKey, changes: metaChanges })
|
|
3676
|
-
).unwrap();
|
|
3677
|
-
return nextMeta;
|
|
3678
|
-
} catch (e) {
|
|
3679
|
-
return rejectWithValue(e.message || "\u8C03\u6574\u5217\u987A\u5E8F\u5931\u8D25");
|
|
3680
|
-
}
|
|
3681
|
-
},
|
|
3682
|
-
{
|
|
3683
|
-
pending: (state2) => {
|
|
3684
|
-
state2.error = null;
|
|
3685
|
-
},
|
|
3686
|
-
fulfilled: (state2, action) => {
|
|
3687
|
-
state2.currentTable = action.payload;
|
|
3688
|
-
state2.isInitialized = true;
|
|
3689
|
-
},
|
|
3690
|
-
rejected: (state2, action) => {
|
|
3691
|
-
state2.error = action.payload || action.error.message || "\u8C03\u6574\u5217\u987A\u5E8F\u65F6\u53D1\u751F\u672A\u77E5\u9519\u8BEF";
|
|
3692
|
-
}
|
|
3693
3724
|
}
|
|
3694
|
-
|
|
3695
|
-
|
|
3696
|
-
|
|
3697
|
-
|
|
3698
|
-
|
|
3699
|
-
|
|
3700
|
-
|
|
3701
|
-
|
|
3702
|
-
|
|
3703
|
-
|
|
3704
|
-
|
|
3705
|
-
|
|
3706
|
-
|
|
3707
|
-
|
|
3708
|
-
|
|
3709
|
-
|
|
3710
|
-
|
|
3711
|
-
|
|
3712
|
-
|
|
3725
|
+
setState((s) => ({
|
|
3726
|
+
...s,
|
|
3727
|
+
currentTable: nextMeta,
|
|
3728
|
+
rows: newRows,
|
|
3729
|
+
isInitialized: true
|
|
3730
|
+
}));
|
|
3731
|
+
return { meta: nextMeta, rows: newRows };
|
|
3732
|
+
} catch (e) {
|
|
3733
|
+
const msg = e?.message || "\u5220\u9664\u5B57\u6BB5\u5931\u8D25";
|
|
3734
|
+
setState((s) => ({ ...s, error: msg }));
|
|
3735
|
+
throw e;
|
|
3736
|
+
}
|
|
3737
|
+
}
|
|
3738
|
+
);
|
|
3739
|
+
var reorderColumn = createTableCommand(
|
|
3740
|
+
"table/reorderColumn",
|
|
3741
|
+
async (args, { dispatch } = {}) => {
|
|
3742
|
+
const { tenantId, tableId, fromIndex, toIndex } = args;
|
|
3743
|
+
const meta = state.currentTable;
|
|
3744
|
+
if (!meta || meta.tenantId !== tenantId || meta.tableId !== tableId) {
|
|
3745
|
+
throw new Error("\u5F53\u524D\u6CA1\u6709\u52A0\u8F7D\u5BF9\u5E94\u7684\u8868\u5B9A\u4E49");
|
|
3746
|
+
}
|
|
3747
|
+
const result = reorderColumnInMeta(
|
|
3748
|
+
meta,
|
|
3749
|
+
{ fromIndex, toIndex },
|
|
3750
|
+
{ nowIso: (0, import_date_fns2.formatISO)(/* @__PURE__ */ new Date()) }
|
|
3751
|
+
);
|
|
3752
|
+
if (!result.ok) {
|
|
3753
|
+
throw new Error(result.error);
|
|
3754
|
+
}
|
|
3755
|
+
if (result.value.noop) {
|
|
3756
|
+
return meta;
|
|
3757
|
+
}
|
|
3758
|
+
const { meta: nextMeta, metaChanges } = result.value;
|
|
3759
|
+
setState((s) => ({ ...s, error: null }));
|
|
3760
|
+
try {
|
|
3761
|
+
if (dispatch) {
|
|
3762
|
+
await safeDispatch(
|
|
3763
|
+
dispatch,
|
|
3764
|
+
patch({ dbKey: meta.dbKey, changes: metaChanges })
|
|
3713
3765
|
);
|
|
3714
|
-
if (!result.ok) {
|
|
3715
|
-
return rejectWithValue(result.error);
|
|
3716
|
-
}
|
|
3717
|
-
const { meta: nextMeta, metaChanges, rows: newRows, rowPatches } = result.value;
|
|
3718
|
-
try {
|
|
3719
|
-
await Promise.all(
|
|
3720
|
-
rowPatches.map((p) => dispatch(patch(p)).unwrap())
|
|
3721
|
-
);
|
|
3722
|
-
await dispatch(
|
|
3723
|
-
patch({ dbKey: meta.dbKey, changes: metaChanges })
|
|
3724
|
-
).unwrap();
|
|
3725
|
-
return { meta: nextMeta, rows: newRows };
|
|
3726
|
-
} catch (e) {
|
|
3727
|
-
return rejectWithValue(e.message || "\u91CD\u547D\u540D\u5B57\u6BB5\u5931\u8D25");
|
|
3728
|
-
}
|
|
3729
|
-
},
|
|
3730
|
-
{
|
|
3731
|
-
pending: (state2) => {
|
|
3732
|
-
state2.error = null;
|
|
3733
|
-
},
|
|
3734
|
-
fulfilled: (state2, action) => {
|
|
3735
|
-
state2.currentTable = action.payload.meta;
|
|
3736
|
-
state2.rows = action.payload.rows;
|
|
3737
|
-
state2.isInitialized = true;
|
|
3738
|
-
},
|
|
3739
|
-
rejected: (state2, action) => {
|
|
3740
|
-
state2.error = action.payload || action.error.message || "\u91CD\u547D\u540D\u5B57\u6BB5\u65F6\u53D1\u751F\u672A\u77E5\u9519\u8BEF";
|
|
3741
|
-
}
|
|
3742
3766
|
}
|
|
3743
|
-
|
|
3744
|
-
|
|
3745
|
-
|
|
3746
|
-
|
|
3747
|
-
|
|
3748
|
-
|
|
3749
|
-
|
|
3750
|
-
|
|
3751
|
-
|
|
3752
|
-
|
|
3753
|
-
|
|
3754
|
-
|
|
3755
|
-
|
|
3756
|
-
|
|
3757
|
-
|
|
3758
|
-
|
|
3759
|
-
|
|
3760
|
-
|
|
3767
|
+
setState((s) => ({
|
|
3768
|
+
...s,
|
|
3769
|
+
currentTable: nextMeta,
|
|
3770
|
+
isInitialized: true
|
|
3771
|
+
}));
|
|
3772
|
+
return nextMeta;
|
|
3773
|
+
} catch (e) {
|
|
3774
|
+
const msg = e?.message || "\u8C03\u6574\u5217\u987A\u5E8F\u5931\u8D25";
|
|
3775
|
+
setState((s) => ({ ...s, error: msg }));
|
|
3776
|
+
throw e;
|
|
3777
|
+
}
|
|
3778
|
+
}
|
|
3779
|
+
);
|
|
3780
|
+
var renameColumn = createTableCommand(
|
|
3781
|
+
"table/renameColumn",
|
|
3782
|
+
async (args, { dispatch } = {}) => {
|
|
3783
|
+
const { tenantId, tableId, oldName, newName } = args;
|
|
3784
|
+
const meta = state.currentTable;
|
|
3785
|
+
if (!meta || meta.tenantId !== tenantId || meta.tableId !== tableId) {
|
|
3786
|
+
throw new Error("\u5F53\u524D\u6CA1\u6709\u52A0\u8F7D\u5BF9\u5E94\u7684\u8868\u5B9A\u4E49");
|
|
3787
|
+
}
|
|
3788
|
+
const result = renameColumnInMeta(
|
|
3789
|
+
meta,
|
|
3790
|
+
state.rows,
|
|
3791
|
+
{ oldName, newName },
|
|
3792
|
+
{ nowIso: (0, import_date_fns2.formatISO)(/* @__PURE__ */ new Date()) }
|
|
3793
|
+
);
|
|
3794
|
+
if (!result.ok) {
|
|
3795
|
+
throw new Error(result.error);
|
|
3796
|
+
}
|
|
3797
|
+
const { meta: nextMeta, metaChanges, rows: newRows, rowPatches } = result.value;
|
|
3798
|
+
setState((s) => ({ ...s, error: null }));
|
|
3799
|
+
try {
|
|
3800
|
+
if (dispatch) {
|
|
3801
|
+
await Promise.all(
|
|
3802
|
+
rowPatches.map((p) => safeDispatch(dispatch, patch(p)))
|
|
3803
|
+
);
|
|
3804
|
+
await safeDispatch(
|
|
3805
|
+
dispatch,
|
|
3806
|
+
patch({ dbKey: meta.dbKey, changes: metaChanges })
|
|
3761
3807
|
);
|
|
3762
|
-
if (!result.ok) {
|
|
3763
|
-
return rejectWithValue(result.error);
|
|
3764
|
-
}
|
|
3765
|
-
const { meta: nextMeta, metaChanges } = result.value;
|
|
3766
|
-
try {
|
|
3767
|
-
await dispatch(
|
|
3768
|
-
patch({ dbKey: meta.dbKey, changes: metaChanges })
|
|
3769
|
-
).unwrap();
|
|
3770
|
-
return nextMeta;
|
|
3771
|
-
} catch (e) {
|
|
3772
|
-
return rejectWithValue(e.message || "\u91CD\u547D\u540D\u5B57\u6BB5\u663E\u793A\u540D\u5931\u8D25");
|
|
3773
|
-
}
|
|
3774
|
-
},
|
|
3775
|
-
{
|
|
3776
|
-
pending: (state2) => {
|
|
3777
|
-
state2.error = null;
|
|
3778
|
-
},
|
|
3779
|
-
fulfilled: (state2, action) => {
|
|
3780
|
-
state2.currentTable = action.payload;
|
|
3781
|
-
state2.isInitialized = true;
|
|
3782
|
-
},
|
|
3783
|
-
rejected: (state2, action) => {
|
|
3784
|
-
state2.error = action.payload || action.error.message || "\u91CD\u547D\u540D\u5B57\u6BB5\u663E\u793A\u540D\u65F6\u53D1\u751F\u672A\u77E5\u9519\u8BEF";
|
|
3785
|
-
}
|
|
3786
3808
|
}
|
|
3787
|
-
|
|
3788
|
-
|
|
3789
|
-
|
|
3790
|
-
|
|
3791
|
-
|
|
3792
|
-
|
|
3793
|
-
|
|
3794
|
-
|
|
3795
|
-
|
|
3796
|
-
|
|
3797
|
-
|
|
3798
|
-
|
|
3799
|
-
|
|
3800
|
-
|
|
3801
|
-
|
|
3802
|
-
|
|
3803
|
-
|
|
3809
|
+
setState((s) => ({
|
|
3810
|
+
...s,
|
|
3811
|
+
currentTable: nextMeta,
|
|
3812
|
+
rows: newRows,
|
|
3813
|
+
isInitialized: true
|
|
3814
|
+
}));
|
|
3815
|
+
return { meta: nextMeta, rows: newRows };
|
|
3816
|
+
} catch (e) {
|
|
3817
|
+
const msg = e?.message || "\u91CD\u547D\u540D\u5B57\u6BB5\u5931\u8D25";
|
|
3818
|
+
setState((s) => ({ ...s, error: msg }));
|
|
3819
|
+
throw e;
|
|
3820
|
+
}
|
|
3821
|
+
}
|
|
3822
|
+
);
|
|
3823
|
+
var renameColumnLabel = createTableCommand(
|
|
3824
|
+
"table/renameColumnLabel",
|
|
3825
|
+
async (args, { dispatch } = {}) => {
|
|
3826
|
+
const { tenantId, tableId, columnId, newLabel } = args;
|
|
3827
|
+
const meta = state.currentTable;
|
|
3828
|
+
if (!meta || meta.tenantId !== tenantId || meta.tableId !== tableId) {
|
|
3829
|
+
throw new Error("\u5F53\u524D\u6CA1\u6709\u52A0\u8F7D\u5BF9\u5E94\u7684\u8868\u5B9A\u4E49");
|
|
3830
|
+
}
|
|
3831
|
+
const result = renameColumnLabelInMeta(
|
|
3832
|
+
meta,
|
|
3833
|
+
{ columnId, label: newLabel },
|
|
3834
|
+
{ nowIso: (0, import_date_fns2.formatISO)(/* @__PURE__ */ new Date()) }
|
|
3835
|
+
);
|
|
3836
|
+
if (!result.ok) {
|
|
3837
|
+
throw new Error(result.error);
|
|
3838
|
+
}
|
|
3839
|
+
const { meta: nextMeta, metaChanges } = result.value;
|
|
3840
|
+
setState((s) => ({ ...s, error: null }));
|
|
3841
|
+
try {
|
|
3842
|
+
if (dispatch) {
|
|
3843
|
+
await safeDispatch(
|
|
3844
|
+
dispatch,
|
|
3845
|
+
patch({ dbKey: meta.dbKey, changes: metaChanges })
|
|
3804
3846
|
);
|
|
3805
|
-
if (!result.ok) {
|
|
3806
|
-
return rejectWithValue(result.error);
|
|
3807
|
-
}
|
|
3808
|
-
const { meta: nextMeta, metaChanges } = result.value;
|
|
3809
|
-
try {
|
|
3810
|
-
await dispatch(
|
|
3811
|
-
patch({ dbKey: meta.dbKey, changes: metaChanges })
|
|
3812
|
-
).unwrap();
|
|
3813
|
-
return nextMeta;
|
|
3814
|
-
} catch (e) {
|
|
3815
|
-
return rejectWithValue(e.message || "\u66F4\u65B0\u5B57\u6BB5\u5BBD\u5EA6\u5931\u8D25");
|
|
3816
|
-
}
|
|
3817
|
-
},
|
|
3818
|
-
{
|
|
3819
|
-
pending: (state2) => {
|
|
3820
|
-
state2.error = null;
|
|
3821
|
-
},
|
|
3822
|
-
fulfilled: (state2, action) => {
|
|
3823
|
-
state2.currentTable = action.payload;
|
|
3824
|
-
state2.isInitialized = true;
|
|
3825
|
-
},
|
|
3826
|
-
rejected: (state2, action) => {
|
|
3827
|
-
state2.error = action.payload || action.error.message || "\u66F4\u65B0\u5B57\u6BB5\u5BBD\u5EA6\u65F6\u53D1\u751F\u672A\u77E5\u9519\u8BEF";
|
|
3828
|
-
}
|
|
3829
3847
|
}
|
|
3830
|
-
|
|
3831
|
-
|
|
3832
|
-
|
|
3833
|
-
|
|
3834
|
-
|
|
3835
|
-
|
|
3836
|
-
|
|
3837
|
-
|
|
3838
|
-
|
|
3839
|
-
|
|
3840
|
-
|
|
3841
|
-
|
|
3842
|
-
|
|
3843
|
-
|
|
3844
|
-
|
|
3845
|
-
|
|
3846
|
-
|
|
3847
|
-
|
|
3848
|
+
setState((s) => ({
|
|
3849
|
+
...s,
|
|
3850
|
+
currentTable: nextMeta,
|
|
3851
|
+
isInitialized: true
|
|
3852
|
+
}));
|
|
3853
|
+
return nextMeta;
|
|
3854
|
+
} catch (e) {
|
|
3855
|
+
const msg = e?.message || "\u91CD\u547D\u540D\u5B57\u6BB5\u663E\u793A\u540D\u5931\u8D25";
|
|
3856
|
+
setState((s) => ({ ...s, error: msg }));
|
|
3857
|
+
throw e;
|
|
3858
|
+
}
|
|
3859
|
+
}
|
|
3860
|
+
);
|
|
3861
|
+
var updateColumnWidth = createTableCommand(
|
|
3862
|
+
"table/updateColumnWidth",
|
|
3863
|
+
async (args, { dispatch } = {}) => {
|
|
3864
|
+
const { tenantId, tableId, columnId, width } = args;
|
|
3865
|
+
const meta = state.currentTable;
|
|
3866
|
+
if (!meta || meta.tenantId !== tenantId || meta.tableId !== tableId) {
|
|
3867
|
+
throw new Error("\u5F53\u524D\u6CA1\u6709\u52A0\u8F7D\u5BF9\u5E94\u7684\u8868\u5B9A\u4E49");
|
|
3868
|
+
}
|
|
3869
|
+
const result = updateColumnWidthInMeta(
|
|
3870
|
+
meta,
|
|
3871
|
+
{ columnId, width },
|
|
3872
|
+
{ nowIso: (0, import_date_fns2.formatISO)(/* @__PURE__ */ new Date()) }
|
|
3873
|
+
);
|
|
3874
|
+
if (!result.ok) {
|
|
3875
|
+
throw new Error(result.error);
|
|
3876
|
+
}
|
|
3877
|
+
const { meta: nextMeta, metaChanges } = result.value;
|
|
3878
|
+
setState((s) => ({ ...s, error: null }));
|
|
3879
|
+
try {
|
|
3880
|
+
if (dispatch) {
|
|
3881
|
+
await safeDispatch(
|
|
3882
|
+
dispatch,
|
|
3883
|
+
patch({ dbKey: meta.dbKey, changes: metaChanges })
|
|
3848
3884
|
);
|
|
3849
|
-
if (!result.ok) {
|
|
3850
|
-
return rejectWithValue(result.error);
|
|
3851
|
-
}
|
|
3852
|
-
if (result.value.noop) {
|
|
3853
|
-
return meta;
|
|
3854
|
-
}
|
|
3855
|
-
const { meta: nextMeta, metaChanges } = result.value;
|
|
3856
|
-
try {
|
|
3857
|
-
await dispatch(
|
|
3858
|
-
patch({ dbKey: meta.dbKey, changes: metaChanges })
|
|
3859
|
-
).unwrap();
|
|
3860
|
-
return nextMeta;
|
|
3861
|
-
} catch (e) {
|
|
3862
|
-
return rejectWithValue(e.message || "\u65B0\u589E\u9009\u9879\u5931\u8D25");
|
|
3863
|
-
}
|
|
3864
|
-
},
|
|
3865
|
-
{
|
|
3866
|
-
pending: (state2) => {
|
|
3867
|
-
state2.error = null;
|
|
3868
|
-
},
|
|
3869
|
-
fulfilled: (state2, action) => {
|
|
3870
|
-
state2.currentTable = action.payload;
|
|
3871
|
-
state2.isInitialized = true;
|
|
3872
|
-
},
|
|
3873
|
-
rejected: (state2, action) => {
|
|
3874
|
-
state2.error = action.payload || action.error.message || "\u65B0\u589E\u9009\u9879\u65F6\u53D1\u751F\u672A\u77E5\u9519\u8BEF";
|
|
3875
|
-
}
|
|
3876
3885
|
}
|
|
3877
|
-
|
|
3878
|
-
|
|
3879
|
-
|
|
3880
|
-
|
|
3881
|
-
|
|
3882
|
-
|
|
3883
|
-
|
|
3884
|
-
|
|
3885
|
-
|
|
3886
|
-
|
|
3887
|
-
|
|
3888
|
-
|
|
3889
|
-
|
|
3890
|
-
|
|
3891
|
-
|
|
3892
|
-
|
|
3893
|
-
|
|
3894
|
-
|
|
3895
|
-
|
|
3896
|
-
|
|
3897
|
-
|
|
3898
|
-
|
|
3899
|
-
|
|
3900
|
-
|
|
3901
|
-
|
|
3902
|
-
|
|
3903
|
-
|
|
3904
|
-
|
|
3905
|
-
|
|
3906
|
-
|
|
3907
|
-
|
|
3908
|
-
|
|
3909
|
-
|
|
3910
|
-
|
|
3911
|
-
|
|
3912
|
-
|
|
3913
|
-
|
|
3914
|
-
|
|
3915
|
-
|
|
3916
|
-
|
|
3917
|
-
},
|
|
3918
|
-
fulfilled: (state2, action) => {
|
|
3919
|
-
state2.currentTable = action.payload;
|
|
3920
|
-
},
|
|
3921
|
-
rejected: (state2, action) => {
|
|
3922
|
-
state2.error = action.payload || action.error.message || "\u91CD\u547D\u540D\u8868\u65F6\u53D1\u751F\u672A\u77E5\u9519\u8BEF";
|
|
3923
|
-
}
|
|
3886
|
+
setState((s) => ({
|
|
3887
|
+
...s,
|
|
3888
|
+
currentTable: nextMeta,
|
|
3889
|
+
isInitialized: true
|
|
3890
|
+
}));
|
|
3891
|
+
return nextMeta;
|
|
3892
|
+
} catch (e) {
|
|
3893
|
+
const msg = e?.message || "\u66F4\u65B0\u5B57\u6BB5\u5BBD\u5EA6\u5931\u8D25";
|
|
3894
|
+
setState((s) => ({ ...s, error: msg }));
|
|
3895
|
+
throw e;
|
|
3896
|
+
}
|
|
3897
|
+
}
|
|
3898
|
+
);
|
|
3899
|
+
var addColumnOption = createTableCommand(
|
|
3900
|
+
"table/addColumnOption",
|
|
3901
|
+
async (args, { dispatch } = {}) => {
|
|
3902
|
+
const { tenantId, tableId, columnId, option } = args;
|
|
3903
|
+
const meta = state.currentTable;
|
|
3904
|
+
if (!meta || meta.tenantId !== tenantId || meta.tableId !== tableId) {
|
|
3905
|
+
throw new Error("\u5F53\u524D\u6CA1\u6709\u52A0\u8F7D\u5BF9\u5E94\u7684\u8868\u5B9A\u4E49");
|
|
3906
|
+
}
|
|
3907
|
+
const result = addColumnOptionInMeta(
|
|
3908
|
+
meta,
|
|
3909
|
+
{ columnId, option },
|
|
3910
|
+
{ nowIso: (0, import_date_fns2.formatISO)(/* @__PURE__ */ new Date()) }
|
|
3911
|
+
);
|
|
3912
|
+
if (!result.ok) {
|
|
3913
|
+
throw new Error(result.error);
|
|
3914
|
+
}
|
|
3915
|
+
if (result.value.noop) {
|
|
3916
|
+
return meta;
|
|
3917
|
+
}
|
|
3918
|
+
const { meta: nextMeta, metaChanges } = result.value;
|
|
3919
|
+
setState((s) => ({ ...s, error: null }));
|
|
3920
|
+
try {
|
|
3921
|
+
if (dispatch) {
|
|
3922
|
+
await safeDispatch(
|
|
3923
|
+
dispatch,
|
|
3924
|
+
patch({ dbKey: meta.dbKey, changes: metaChanges })
|
|
3925
|
+
);
|
|
3924
3926
|
}
|
|
3925
|
-
|
|
3926
|
-
|
|
3927
|
-
|
|
3928
|
-
|
|
3929
|
-
|
|
3930
|
-
|
|
3931
|
-
|
|
3932
|
-
|
|
3933
|
-
|
|
3934
|
-
|
|
3935
|
-
|
|
3936
|
-
|
|
3937
|
-
|
|
3938
|
-
|
|
3939
|
-
|
|
3940
|
-
|
|
3941
|
-
|
|
3942
|
-
|
|
3943
|
-
|
|
3944
|
-
|
|
3945
|
-
|
|
3946
|
-
|
|
3947
|
-
|
|
3948
|
-
|
|
3949
|
-
|
|
3950
|
-
|
|
3951
|
-
|
|
3952
|
-
|
|
3953
|
-
|
|
3954
|
-
|
|
3955
|
-
|
|
3956
|
-
|
|
3957
|
-
|
|
3958
|
-
|
|
3959
|
-
|
|
3960
|
-
|
|
3961
|
-
|
|
3962
|
-
|
|
3963
|
-
|
|
3964
|
-
}
|
|
3927
|
+
setState((s) => ({
|
|
3928
|
+
...s,
|
|
3929
|
+
currentTable: nextMeta,
|
|
3930
|
+
isInitialized: true
|
|
3931
|
+
}));
|
|
3932
|
+
return nextMeta;
|
|
3933
|
+
} catch (e) {
|
|
3934
|
+
const msg = e?.message || "\u65B0\u589E\u9009\u9879\u5931\u8D25";
|
|
3935
|
+
setState((s) => ({ ...s, error: msg }));
|
|
3936
|
+
throw e;
|
|
3937
|
+
}
|
|
3938
|
+
}
|
|
3939
|
+
);
|
|
3940
|
+
var renameTable = createTableCommand(
|
|
3941
|
+
"table/renameTable",
|
|
3942
|
+
async (args, { dispatch } = {}) => {
|
|
3943
|
+
const { tenantId, tableId, newName } = args;
|
|
3944
|
+
const trimmedName = newName.trim();
|
|
3945
|
+
if (!trimmedName) {
|
|
3946
|
+
throw new Error("\u8868\u540D\u4E0D\u80FD\u4E3A\u7A7A");
|
|
3947
|
+
}
|
|
3948
|
+
const meta = state.currentTable;
|
|
3949
|
+
if (!meta || meta.tenantId !== tenantId || meta.tableId !== tableId) {
|
|
3950
|
+
throw new Error("\u5F53\u524D\u6CA1\u6709\u52A0\u8F7D\u5BF9\u5E94\u7684\u8868\u5B9A\u4E49");
|
|
3951
|
+
}
|
|
3952
|
+
const nowIso = (0, import_date_fns2.formatISO)(/* @__PURE__ */ new Date());
|
|
3953
|
+
setState((s) => ({ ...s, error: null }));
|
|
3954
|
+
try {
|
|
3955
|
+
if (dispatch) {
|
|
3956
|
+
await safeDispatch(
|
|
3957
|
+
dispatch,
|
|
3958
|
+
patch({
|
|
3959
|
+
dbKey: meta.dbKey,
|
|
3960
|
+
changes: {
|
|
3961
|
+
displayName: trimmedName,
|
|
3962
|
+
updatedAt: nowIso
|
|
3963
|
+
}
|
|
3964
|
+
})
|
|
3965
|
+
);
|
|
3965
3966
|
}
|
|
3966
|
-
|
|
3967
|
-
|
|
3968
|
-
|
|
3969
|
-
|
|
3970
|
-
|
|
3971
|
-
|
|
3972
|
-
|
|
3973
|
-
|
|
3974
|
-
|
|
3975
|
-
|
|
3976
|
-
|
|
3977
|
-
|
|
3978
|
-
|
|
3979
|
-
|
|
3980
|
-
|
|
3981
|
-
|
|
3982
|
-
|
|
3983
|
-
|
|
3984
|
-
|
|
3985
|
-
|
|
3986
|
-
|
|
3987
|
-
|
|
3988
|
-
|
|
3989
|
-
|
|
3990
|
-
|
|
3991
|
-
|
|
3992
|
-
|
|
3993
|
-
|
|
3994
|
-
|
|
3995
|
-
|
|
3996
|
-
|
|
3997
|
-
|
|
3998
|
-
|
|
3999
|
-
|
|
4000
|
-
|
|
4001
|
-
|
|
4002
|
-
|
|
4003
|
-
|
|
3967
|
+
const nextMeta = {
|
|
3968
|
+
...meta,
|
|
3969
|
+
displayName: trimmedName,
|
|
3970
|
+
updatedAt: nowIso
|
|
3971
|
+
};
|
|
3972
|
+
setState((s) => ({
|
|
3973
|
+
...s,
|
|
3974
|
+
currentTable: nextMeta,
|
|
3975
|
+
isInitialized: true
|
|
3976
|
+
}));
|
|
3977
|
+
return nextMeta;
|
|
3978
|
+
} catch (e) {
|
|
3979
|
+
const msg = e?.message || "\u91CD\u547D\u540D\u8868\u5931\u8D25";
|
|
3980
|
+
setState((s) => ({ ...s, error: msg }));
|
|
3981
|
+
throw e;
|
|
3982
|
+
}
|
|
3983
|
+
}
|
|
3984
|
+
);
|
|
3985
|
+
var updateTableIcon = createTableCommand(
|
|
3986
|
+
"table/updateTableIcon",
|
|
3987
|
+
async (args, { dispatch } = {}) => {
|
|
3988
|
+
const { tenantId, tableId, icon } = args;
|
|
3989
|
+
const meta = state.currentTable;
|
|
3990
|
+
if (!meta || meta.tenantId !== tenantId || meta.tableId !== tableId) {
|
|
3991
|
+
throw new Error("\u5F53\u524D\u6CA1\u6709\u52A0\u8F7D\u5BF9\u5E94\u7684\u8868\u5B9A\u4E49");
|
|
3992
|
+
}
|
|
3993
|
+
const nowIso = (0, import_date_fns2.formatISO)(/* @__PURE__ */ new Date());
|
|
3994
|
+
setState((s) => ({ ...s, error: null }));
|
|
3995
|
+
try {
|
|
3996
|
+
if (dispatch) {
|
|
3997
|
+
await safeDispatch(
|
|
3998
|
+
dispatch,
|
|
3999
|
+
patch({
|
|
4000
|
+
dbKey: meta.dbKey,
|
|
4001
|
+
changes: {
|
|
4002
|
+
icon: icon ?? null,
|
|
4003
|
+
updatedAt: nowIso
|
|
4004
|
+
}
|
|
4005
|
+
})
|
|
4006
|
+
);
|
|
4004
4007
|
}
|
|
4005
|
-
|
|
4006
|
-
|
|
4007
|
-
|
|
4008
|
-
|
|
4009
|
-
|
|
4010
|
-
(
|
|
4011
|
-
|
|
4008
|
+
const nextMeta = {
|
|
4009
|
+
...meta,
|
|
4010
|
+
icon: icon ?? null,
|
|
4011
|
+
updatedAt: nowIso
|
|
4012
|
+
};
|
|
4013
|
+
setState((s) => ({
|
|
4014
|
+
...s,
|
|
4015
|
+
currentTable: nextMeta
|
|
4016
|
+
}));
|
|
4017
|
+
return nextMeta;
|
|
4018
|
+
} catch (e) {
|
|
4019
|
+
const msg = e?.message || "\u66F4\u65B0\u8868\u683C\u56FE\u6807\u5931\u8D25";
|
|
4020
|
+
setState((s) => ({ ...s, error: msg }));
|
|
4021
|
+
throw e;
|
|
4022
|
+
}
|
|
4023
|
+
}
|
|
4024
|
+
);
|
|
4025
|
+
var updateCell = createTableCommand(
|
|
4026
|
+
"table/updateCell",
|
|
4027
|
+
async (args, { dispatch } = {}) => {
|
|
4028
|
+
const { dbKey, columnName, value } = args;
|
|
4029
|
+
setState((s) => ({ ...s, error: null }));
|
|
4030
|
+
try {
|
|
4031
|
+
const nowIso = (0, import_date_fns2.formatISO)(/* @__PURE__ */ new Date());
|
|
4032
|
+
if (dispatch) {
|
|
4033
|
+
await safeDispatch(
|
|
4034
|
+
dispatch,
|
|
4035
|
+
patch({
|
|
4036
|
+
dbKey,
|
|
4037
|
+
changes: {
|
|
4038
|
+
[columnName]: value,
|
|
4039
|
+
updatedAt: nowIso
|
|
4040
|
+
}
|
|
4041
|
+
})
|
|
4042
|
+
);
|
|
4012
4043
|
}
|
|
4013
|
-
|
|
4014
|
-
|
|
4015
|
-
|
|
4016
|
-
|
|
4017
|
-
|
|
4018
|
-
|
|
4019
|
-
|
|
4020
|
-
|
|
4021
|
-
|
|
4022
|
-
|
|
4023
|
-
|
|
4024
|
-
|
|
4025
|
-
|
|
4044
|
+
setState((s) => ({
|
|
4045
|
+
...s,
|
|
4046
|
+
rows: s.rows.map((r) => {
|
|
4047
|
+
if (r.dbKey === dbKey) {
|
|
4048
|
+
return {
|
|
4049
|
+
...r,
|
|
4050
|
+
[columnName]: value,
|
|
4051
|
+
updatedAt: nowIso
|
|
4052
|
+
};
|
|
4053
|
+
}
|
|
4054
|
+
return r;
|
|
4055
|
+
})
|
|
4056
|
+
}));
|
|
4057
|
+
return { dbKey, columnName, value, updatedAt: nowIso };
|
|
4058
|
+
} catch (e) {
|
|
4059
|
+
const msg = e?.message || "\u66F4\u65B0\u5355\u5143\u683C\u5931\u8D25";
|
|
4060
|
+
setState((s) => ({ ...s, error: msg }));
|
|
4061
|
+
throw e;
|
|
4062
|
+
}
|
|
4026
4063
|
}
|
|
4027
|
-
|
|
4028
|
-
var {
|
|
4029
|
-
createTable,
|
|
4030
|
-
initTable,
|
|
4031
|
-
addRow,
|
|
4032
|
-
deleteRow,
|
|
4033
|
-
deleteTable,
|
|
4034
|
-
addColumn,
|
|
4035
|
-
deleteColumn,
|
|
4036
|
-
renameColumn,
|
|
4037
|
-
renameColumnLabel,
|
|
4038
|
-
renameTable,
|
|
4039
|
-
updateTableIcon,
|
|
4040
|
-
resetTable,
|
|
4041
|
-
loadTableRows,
|
|
4042
|
-
updateCell,
|
|
4043
|
-
reorderColumn,
|
|
4044
|
-
updateColumnWidth,
|
|
4045
|
-
addColumnOption,
|
|
4046
|
-
setTableFocusContext
|
|
4047
|
-
} = tableSlice.actions;
|
|
4048
|
-
var {
|
|
4049
|
-
selectCurrentTable,
|
|
4050
|
-
selectTableIsLoading,
|
|
4051
|
-
selectTableIsInitialized,
|
|
4052
|
-
selectTableError,
|
|
4053
|
-
selectTableColumns,
|
|
4054
|
-
selectTableRows,
|
|
4055
|
-
selectTableFocusContext
|
|
4056
|
-
} = tableSlice.selectors;
|
|
4057
|
-
var tableSlice_default = tableSlice.reducer;
|
|
4064
|
+
);
|
|
4058
4065
|
|
|
4059
4066
|
// packages/create/space/content/deleteContentFromSpaceAction.ts
|
|
4060
4067
|
var nextSpaceUpdatedAt = (value) => {
|
|
@@ -4090,11 +4097,11 @@ var ENTITY_DELETE_STRATEGIES = {
|
|
|
4090
4097
|
await dispatch(deleteTable({ dbKey: key })).unwrap();
|
|
4091
4098
|
},
|
|
4092
4099
|
file: async (key, { thunkAPI }) => {
|
|
4093
|
-
const { deleteFileAction } = await import("./deleteFile-
|
|
4100
|
+
const { deleteFileAction } = await import("./deleteFile-FWP2PSBG.js");
|
|
4094
4101
|
await deleteFileAction(key, thunkAPI);
|
|
4095
4102
|
},
|
|
4096
4103
|
image: async (key, { thunkAPI }) => {
|
|
4097
|
-
const { deleteFileAction } = await import("./deleteFile-
|
|
4104
|
+
const { deleteFileAction } = await import("./deleteFile-FWP2PSBG.js");
|
|
4098
4105
|
await deleteFileAction(key, thunkAPI);
|
|
4099
4106
|
},
|
|
4100
4107
|
agent: async (key, { dispatch, userId, sourceServerOrigin }) => {
|
|
@@ -4199,8 +4206,8 @@ var moveContentAction = async (input, thunkAPI) => {
|
|
|
4199
4206
|
targetCategoryId: rawTargetCategoryId
|
|
4200
4207
|
} = input;
|
|
4201
4208
|
const { dispatch, getState } = thunkAPI;
|
|
4202
|
-
const
|
|
4203
|
-
const userId = selectIdentityUserId(
|
|
4209
|
+
const state3 = getState();
|
|
4210
|
+
const userId = selectIdentityUserId(state3);
|
|
4204
4211
|
const now = Date.now();
|
|
4205
4212
|
logger.info({ ...input, userId }, "Initiating moveContentAction");
|
|
4206
4213
|
if (sourceSpaceId === targetSpaceId) {
|
|
@@ -4554,8 +4561,8 @@ var updateContentPinnedAction = async (input, thunkAPI) => {
|
|
|
4554
4561
|
var updateContentCategoryAction = async (input, thunkAPI) => {
|
|
4555
4562
|
const { spaceId, contentKey, categoryId: targetContainerId } = input;
|
|
4556
4563
|
const { dispatch, getState } = thunkAPI;
|
|
4557
|
-
const
|
|
4558
|
-
const userId = selectIdentityUserId(
|
|
4564
|
+
const state3 = getState();
|
|
4565
|
+
const userId = selectIdentityUserId(state3);
|
|
4559
4566
|
if (!userId) {
|
|
4560
4567
|
throw new Error("User is not logged in.");
|
|
4561
4568
|
}
|
|
@@ -4659,8 +4666,8 @@ var deleteMultipleContentAction = async (input, thunkAPI) => {
|
|
|
4659
4666
|
return { spaceId, updatedSpaceData: null };
|
|
4660
4667
|
}
|
|
4661
4668
|
const { dispatch, getState } = thunkAPI;
|
|
4662
|
-
const
|
|
4663
|
-
const userId = selectIdentityUserId(
|
|
4669
|
+
const state3 = getState();
|
|
4670
|
+
const userId = selectIdentityUserId(state3);
|
|
4664
4671
|
logger2.info(
|
|
4665
4672
|
{ count: contentKeys.length, spaceId, userId },
|
|
4666
4673
|
"Initiating deleteMultipleContentAction"
|
|
@@ -4731,8 +4738,8 @@ var deleteMultipleContentAction = async (input, thunkAPI) => {
|
|
|
4731
4738
|
var uploadAndAddFileToSpaceAction = async (payload, thunkAPI) => {
|
|
4732
4739
|
const { spaceId, file, categoryId } = payload;
|
|
4733
4740
|
const { dispatch, getState } = thunkAPI;
|
|
4734
|
-
const
|
|
4735
|
-
const userId = selectIdentityUserId(
|
|
4741
|
+
const state3 = getState();
|
|
4742
|
+
const userId = selectIdentityUserId(state3);
|
|
4736
4743
|
if (!userId) {
|
|
4737
4744
|
console.warn("[uploadAndAddFileToSpace] Warning: No userId found in state. Uploading as anonymous/unknown might cause issues.");
|
|
4738
4745
|
}
|
|
@@ -4820,7 +4827,7 @@ var writeStoredCollapsedCategories = (spaceId, collapsedCategories, storage) =>
|
|
|
4820
4827
|
};
|
|
4821
4828
|
|
|
4822
4829
|
// packages/create/space/spaceUiStore.ts
|
|
4823
|
-
var
|
|
4830
|
+
var import_react10 = __toESM(require_react(), 1);
|
|
4824
4831
|
var DEFAULT_COLLAPSED_CATEGORIES = {
|
|
4825
4832
|
[UNCATEGORIZED_ID]: false
|
|
4826
4833
|
};
|
|
@@ -4833,17 +4840,17 @@ var readStoredFavoritesCollapsed = () => {
|
|
|
4833
4840
|
return false;
|
|
4834
4841
|
}
|
|
4835
4842
|
};
|
|
4836
|
-
var
|
|
4843
|
+
var createInitialState2 = () => ({
|
|
4837
4844
|
favoritesCollapsed: readStoredFavoritesCollapsed(),
|
|
4838
4845
|
collapsedCategories: {},
|
|
4839
4846
|
collapsedCategoriesSpaceId: null
|
|
4840
4847
|
});
|
|
4841
|
-
var
|
|
4842
|
-
var
|
|
4843
|
-
var
|
|
4844
|
-
var
|
|
4845
|
-
|
|
4846
|
-
for (const listener of
|
|
4848
|
+
var state2 = createInitialState2();
|
|
4849
|
+
var listeners2 = /* @__PURE__ */ new Set();
|
|
4850
|
+
var version2 = 0;
|
|
4851
|
+
var notify2 = () => {
|
|
4852
|
+
version2 += 1;
|
|
4853
|
+
for (const listener of listeners2) {
|
|
4847
4854
|
try {
|
|
4848
4855
|
listener();
|
|
4849
4856
|
} catch {
|
|
@@ -4851,44 +4858,44 @@ var notify = () => {
|
|
|
4851
4858
|
}
|
|
4852
4859
|
};
|
|
4853
4860
|
function getCollapsedCategories() {
|
|
4854
|
-
return
|
|
4861
|
+
return state2.collapsedCategories;
|
|
4855
4862
|
}
|
|
4856
4863
|
function setCollapsedCategories(categories, spaceId) {
|
|
4857
|
-
|
|
4858
|
-
...
|
|
4864
|
+
state2 = {
|
|
4865
|
+
...state2,
|
|
4859
4866
|
collapsedCategories: categories,
|
|
4860
4867
|
collapsedCategoriesSpaceId: spaceId
|
|
4861
4868
|
};
|
|
4862
|
-
|
|
4869
|
+
notify2();
|
|
4863
4870
|
}
|
|
4864
4871
|
function toggleCategoryCollapse(categoryId) {
|
|
4865
|
-
const current =
|
|
4866
|
-
|
|
4867
|
-
...
|
|
4872
|
+
const current = state2.collapsedCategories[categoryId] ?? (DEFAULT_COLLAPSED_CATEGORIES[categoryId] ?? true);
|
|
4873
|
+
state2 = {
|
|
4874
|
+
...state2,
|
|
4868
4875
|
collapsedCategories: {
|
|
4869
|
-
...
|
|
4876
|
+
...state2.collapsedCategories,
|
|
4870
4877
|
[categoryId]: !current
|
|
4871
4878
|
}
|
|
4872
4879
|
};
|
|
4873
|
-
|
|
4880
|
+
notify2();
|
|
4874
4881
|
}
|
|
4875
4882
|
function expandCategoryInCollapsed(categoryId, spaceId) {
|
|
4876
4883
|
if (!categoryId || categoryId === UNCATEGORIZED_ID) return;
|
|
4877
|
-
|
|
4878
|
-
...
|
|
4884
|
+
state2 = {
|
|
4885
|
+
...state2,
|
|
4879
4886
|
collapsedCategories: {
|
|
4880
|
-
...
|
|
4887
|
+
...state2.collapsedCategories,
|
|
4881
4888
|
[categoryId]: false
|
|
4882
4889
|
}
|
|
4883
4890
|
};
|
|
4884
4891
|
if (typeof window !== "undefined") {
|
|
4885
4892
|
writeStoredCollapsedCategories(
|
|
4886
4893
|
spaceId,
|
|
4887
|
-
|
|
4894
|
+
state2.collapsedCategories,
|
|
4888
4895
|
window.localStorage
|
|
4889
4896
|
);
|
|
4890
4897
|
}
|
|
4891
|
-
|
|
4898
|
+
notify2();
|
|
4892
4899
|
}
|
|
4893
4900
|
|
|
4894
4901
|
// packages/create/space/content/contentThunks.ts
|
|
@@ -5032,12 +5039,11 @@ export {
|
|
|
5032
5039
|
i18nBaseConfig,
|
|
5033
5040
|
fetchAndCacheTableRows,
|
|
5034
5041
|
client_default,
|
|
5035
|
-
|
|
5042
|
+
getTableState,
|
|
5043
|
+
loadTableRows,
|
|
5036
5044
|
addRow,
|
|
5045
|
+
createTable,
|
|
5037
5046
|
deleteTable,
|
|
5038
|
-
loadTableRows,
|
|
5039
|
-
selectCurrentTable,
|
|
5040
|
-
selectTableRows,
|
|
5041
5047
|
readStoredCollapsedCategories,
|
|
5042
5048
|
writeStoredCollapsedCategories,
|
|
5043
5049
|
DEFAULT_COLLAPSED_CATEGORIES,
|