@noya-app/noya-api-client-react 0.1.37 → 0.1.39
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/.turbo/turbo-build.log +9 -9
- package/CHANGELOG.md +17 -0
- package/dist/index.d.mts +23 -1
- package/dist/index.d.ts +23 -1
- package/dist/index.js +145 -104
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +130 -90
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
- package/src/react/tableHooks.ts +69 -9
package/dist/index.mjs
CHANGED
|
@@ -5255,8 +5255,20 @@ import { isDeepEqual } from "@noya-app/noya-utils";
|
|
|
5255
5255
|
import { Observable as Observable2 } from "@noya-app/observable";
|
|
5256
5256
|
|
|
5257
5257
|
// ../state-manager/src/AssetManager.ts
|
|
5258
|
-
import { Base64, uuid } from "@noya-app/noya-utils";
|
|
5258
|
+
import { Base64, memoize, uuid } from "@noya-app/noya-utils";
|
|
5259
5259
|
import { Observable as Observable3 } from "@noya-app/observable";
|
|
5260
|
+
var _toNoyaAsset = memoize(
|
|
5261
|
+
(asset) => ({
|
|
5262
|
+
id: asset.stableId,
|
|
5263
|
+
url: asset.url,
|
|
5264
|
+
createdAt: asset.createdAt,
|
|
5265
|
+
size: asset.size,
|
|
5266
|
+
contentType: asset.contentType,
|
|
5267
|
+
width: asset.width ?? null,
|
|
5268
|
+
height: asset.height ?? null,
|
|
5269
|
+
userId: asset.userId ?? null
|
|
5270
|
+
})
|
|
5271
|
+
);
|
|
5260
5272
|
|
|
5261
5273
|
// ../noya-schemas/src/nullable.ts
|
|
5262
5274
|
var Nullable = (schema) => Type.Union([Type.Null(), schema]);
|
|
@@ -5321,6 +5333,7 @@ var activityEventSchema = Type.Object({
|
|
|
5321
5333
|
// ../noya-schemas/src/asset.ts
|
|
5322
5334
|
var assetSchema = Type.Object({
|
|
5323
5335
|
id: Type.String(),
|
|
5336
|
+
stableId: Type.String(),
|
|
5324
5337
|
url: Type.String(),
|
|
5325
5338
|
createdAt: Type.String(),
|
|
5326
5339
|
size: Type.Number(),
|
|
@@ -6015,11 +6028,11 @@ function handleValue(target, handledSet, options) {
|
|
|
6015
6028
|
}
|
|
6016
6029
|
});
|
|
6017
6030
|
if (setMap) {
|
|
6018
|
-
const
|
|
6019
|
-
const values = Array.from(
|
|
6020
|
-
|
|
6031
|
+
const set4 = target;
|
|
6032
|
+
const values = Array.from(set4);
|
|
6033
|
+
set4.clear();
|
|
6021
6034
|
values.forEach((value) => {
|
|
6022
|
-
|
|
6035
|
+
set4.add(setMap.has(value) ? setMap.get(value) : value);
|
|
6023
6036
|
});
|
|
6024
6037
|
}
|
|
6025
6038
|
}
|
|
@@ -6852,7 +6865,7 @@ var makeCreator = (arg) => {
|
|
|
6852
6865
|
};
|
|
6853
6866
|
}
|
|
6854
6867
|
const base2 = arg0;
|
|
6855
|
-
const
|
|
6868
|
+
const mutate = arg1;
|
|
6856
6869
|
let options = arg2;
|
|
6857
6870
|
if (typeof arg1 !== "function") {
|
|
6858
6871
|
options = arg1;
|
|
@@ -6896,7 +6909,7 @@ var makeCreator = (arg) => {
|
|
|
6896
6909
|
}
|
|
6897
6910
|
let result;
|
|
6898
6911
|
try {
|
|
6899
|
-
result =
|
|
6912
|
+
result = mutate(draft);
|
|
6900
6913
|
} catch (error) {
|
|
6901
6914
|
revokeProxy(getProxyDraft(draft));
|
|
6902
6915
|
throw error;
|
|
@@ -7004,7 +7017,7 @@ function apply(state, patches, applyOptions) {
|
|
|
7004
7017
|
if (i > -1) {
|
|
7005
7018
|
patches = patches.slice(i + 1);
|
|
7006
7019
|
}
|
|
7007
|
-
const
|
|
7020
|
+
const mutate = (draft) => {
|
|
7008
7021
|
patches.forEach((patch) => {
|
|
7009
7022
|
const { path: _path, from: _fromPath, op } = patch;
|
|
7010
7023
|
const path2 = unescapePath(_path);
|
|
@@ -7124,17 +7137,17 @@ function apply(state, patches, applyOptions) {
|
|
|
7124
7137
|
console.warn('The "mutable" option is not allowed to be used with other options.');
|
|
7125
7138
|
}
|
|
7126
7139
|
}
|
|
7127
|
-
|
|
7140
|
+
mutate(state);
|
|
7128
7141
|
return void 0;
|
|
7129
7142
|
}
|
|
7130
7143
|
if (isDraft(state)) {
|
|
7131
7144
|
if (applyOptions !== void 0) {
|
|
7132
7145
|
throw new Error(`Cannot apply patches with options to a draft.`);
|
|
7133
7146
|
}
|
|
7134
|
-
|
|
7147
|
+
mutate(state);
|
|
7135
7148
|
return state;
|
|
7136
7149
|
}
|
|
7137
|
-
return create(state,
|
|
7150
|
+
return create(state, mutate, Object.assign(Object.assign({}, applyOptions), { enablePatches: false }));
|
|
7138
7151
|
}
|
|
7139
7152
|
var constructorString = Object.prototype.constructor.toString();
|
|
7140
7153
|
|
|
@@ -7247,6 +7260,10 @@ var import_fast_diff = __toESM(require_diff());
|
|
|
7247
7260
|
// ../state-manager/src/EvalManager.ts
|
|
7248
7261
|
import { uuid as uuid2 } from "@noya-app/noya-utils";
|
|
7249
7262
|
|
|
7263
|
+
// ../state-manager/src/FilePropertyManager.ts
|
|
7264
|
+
import { uuid as uuid3 } from "@noya-app/noya-utils";
|
|
7265
|
+
import { Observable as Observable6 } from "@noya-app/observable";
|
|
7266
|
+
|
|
7250
7267
|
// ../state-manager/src/historyEntries.ts
|
|
7251
7268
|
var HistoryEntries;
|
|
7252
7269
|
((HistoryEntries2) => {
|
|
@@ -7334,7 +7351,7 @@ var HistoryEntries;
|
|
|
7334
7351
|
})(HistoryEntries || (HistoryEntries = {}));
|
|
7335
7352
|
|
|
7336
7353
|
// ../state-manager/src/IOManager.ts
|
|
7337
|
-
import { Observable as
|
|
7354
|
+
import { Observable as Observable7 } from "@noya-app/observable";
|
|
7338
7355
|
|
|
7339
7356
|
// ../state-manager/src/jwt.ts
|
|
7340
7357
|
function base64UrlEncode(str) {
|
|
@@ -7436,31 +7453,30 @@ var jwt;
|
|
|
7436
7453
|
})(jwt || (jwt = {}));
|
|
7437
7454
|
|
|
7438
7455
|
// ../state-manager/src/MenuManager.ts
|
|
7439
|
-
import { Observable as
|
|
7456
|
+
import { Observable as Observable8 } from "@noya-app/observable";
|
|
7440
7457
|
|
|
7441
7458
|
// ../state-manager/src/multiplayer.ts
|
|
7442
|
-
import { Cache, hash, uuid as
|
|
7443
|
-
import {
|
|
7444
|
-
Observable as Observable8,
|
|
7445
|
-
get as get2,
|
|
7446
|
-
mutate
|
|
7447
|
-
} from "@noya-app/observable";
|
|
7459
|
+
import { Cache, hash, uuid as uuid4 } from "@noya-app/noya-utils";
|
|
7460
|
+
import { Observable as Observable10, get as get2, set as set2 } from "@noya-app/observable";
|
|
7448
7461
|
|
|
7449
7462
|
// ../state-manager/src/stateManager.ts
|
|
7450
|
-
import {
|
|
7463
|
+
import {
|
|
7464
|
+
Observable as Observable9,
|
|
7465
|
+
get as getPath2
|
|
7466
|
+
} from "@noya-app/observable";
|
|
7451
7467
|
|
|
7452
7468
|
// ../state-manager/src/multiplayer.ts
|
|
7453
|
-
var createHash = hash;
|
|
7469
|
+
var createHash = (value, options) => hash(value, { ...options, ignoreUndefinedProperties: true });
|
|
7454
7470
|
|
|
7455
7471
|
// ../state-manager/src/NoyaManager.ts
|
|
7456
|
-
import { uuid as
|
|
7457
|
-
import { Observable as
|
|
7472
|
+
import { uuid as uuid8 } from "@noya-app/noya-utils";
|
|
7473
|
+
import { Observable as Observable17, set as set3 } from "@noya-app/observable";
|
|
7458
7474
|
|
|
7459
7475
|
// ../noya-pipeline/src/graphToTasks.ts
|
|
7460
7476
|
import { get as get3 } from "@noya-app/observable";
|
|
7461
7477
|
|
|
7462
7478
|
// ../noya-pipeline/src/state.ts
|
|
7463
|
-
import { uuid as
|
|
7479
|
+
import { uuid as uuid5 } from "@noya-app/noya-utils";
|
|
7464
7480
|
var rectSchema = Type.Object({
|
|
7465
7481
|
x: Type.Number(),
|
|
7466
7482
|
y: Type.Number(),
|
|
@@ -7559,24 +7575,24 @@ var pipelineSchema = Type.Object(
|
|
|
7559
7575
|
);
|
|
7560
7576
|
|
|
7561
7577
|
// ../state-manager/src/PipelineManager.ts
|
|
7562
|
-
import { Observable as
|
|
7578
|
+
import { Observable as Observable11 } from "@noya-app/observable";
|
|
7563
7579
|
|
|
7564
7580
|
// ../state-manager/src/PublishingManager.ts
|
|
7565
|
-
import { Observable as
|
|
7581
|
+
import { Observable as Observable12 } from "@noya-app/observable";
|
|
7566
7582
|
|
|
7567
7583
|
// ../state-manager/src/ResourceManager.ts
|
|
7568
|
-
import { isDeepEqual as isDeepEqual2, uuid as
|
|
7569
|
-
import { Observable as
|
|
7584
|
+
import { isDeepEqual as isDeepEqual2, uuid as uuid6 } from "@noya-app/noya-utils";
|
|
7585
|
+
import { Observable as Observable13 } from "@noya-app/observable";
|
|
7570
7586
|
|
|
7571
7587
|
// ../state-manager/src/rpcManager.ts
|
|
7572
|
-
import { uuid as
|
|
7573
|
-
import { Observable as
|
|
7588
|
+
import { uuid as uuid7 } from "@noya-app/noya-utils";
|
|
7589
|
+
import { Observable as Observable14 } from "@noya-app/observable";
|
|
7574
7590
|
|
|
7575
7591
|
// ../state-manager/src/SecretManager.ts
|
|
7576
|
-
import { Observable as
|
|
7592
|
+
import { Observable as Observable15 } from "@noya-app/observable";
|
|
7577
7593
|
|
|
7578
7594
|
// ../state-manager/src/TaskManager.ts
|
|
7579
|
-
import { Observable as
|
|
7595
|
+
import { Observable as Observable16 } from "@noya-app/observable";
|
|
7580
7596
|
|
|
7581
7597
|
// ../state-manager/src/NoyaManager.ts
|
|
7582
7598
|
var createMutatorParametersSchema = Type.Object({
|
|
@@ -7698,12 +7714,15 @@ var MenuItemTree = (0, import_tree_visit3.defineTree)((node) => {
|
|
|
7698
7714
|
return node.type === "submenu" ? node.items : [];
|
|
7699
7715
|
});
|
|
7700
7716
|
|
|
7717
|
+
// ../state-manager/src/sync/parentLocalRpcBridge.ts
|
|
7718
|
+
import { Base64 as Base642 } from "@noya-app/noya-utils";
|
|
7719
|
+
|
|
7701
7720
|
// ../noya-multiplayer-react/src/ai.ts
|
|
7702
7721
|
import { useEffect as useEffect16 } from "react";
|
|
7703
7722
|
|
|
7704
7723
|
// ../noya-multiplayer-react/src/NoyaStateContext.tsx
|
|
7705
7724
|
import {
|
|
7706
|
-
Observable as
|
|
7725
|
+
Observable as Observable18
|
|
7707
7726
|
} from "@noya-app/observable";
|
|
7708
7727
|
|
|
7709
7728
|
// ../noya-react-utils/src/components/AutoSizer.tsx
|
|
@@ -8010,7 +8029,7 @@ function downloadBlob(...params) {
|
|
|
8010
8029
|
}
|
|
8011
8030
|
|
|
8012
8031
|
// ../noya-multiplayer-react/src/NoyaStateContext.tsx
|
|
8013
|
-
import
|
|
8032
|
+
import React34, {
|
|
8014
8033
|
createContext as createContext3,
|
|
8015
8034
|
useCallback as useCallback14,
|
|
8016
8035
|
useContext as useContext4,
|
|
@@ -8113,7 +8132,7 @@ import React31 from "react";
|
|
|
8113
8132
|
import { createRoot } from "react-dom/client";
|
|
8114
8133
|
|
|
8115
8134
|
// ../noya-multiplayer-react/src/inspector/StateInspector.tsx
|
|
8116
|
-
import { Base64 as
|
|
8135
|
+
import { Base64 as Base643, memoize as memoize2, uuid as uuid9 } from "@noya-app/noya-utils";
|
|
8117
8136
|
import React30, {
|
|
8118
8137
|
useCallback as useCallback12,
|
|
8119
8138
|
useEffect as useEffect13,
|
|
@@ -10452,19 +10471,17 @@ async function importAll(buffer, noyaManager, {
|
|
|
10452
10471
|
}
|
|
10453
10472
|
if (assets.length) {
|
|
10454
10473
|
await Promise.all(
|
|
10455
|
-
noyaManager.assetManager.assets$.get().map((asset) => noyaManager.assetManager.delete(asset.
|
|
10474
|
+
noyaManager.assetManager.assets$.get().map((asset) => noyaManager.assetManager.delete(asset.stableId))
|
|
10456
10475
|
);
|
|
10457
|
-
|
|
10476
|
+
await Promise.all(
|
|
10458
10477
|
assets.map(async (asset) => {
|
|
10459
|
-
|
|
10478
|
+
await noyaManager.assetManager.create({
|
|
10460
10479
|
data: assetMap[asset.id],
|
|
10461
|
-
contentType: asset.contentType
|
|
10480
|
+
contentType: asset.contentType,
|
|
10481
|
+
stableId: asset.stableId
|
|
10462
10482
|
});
|
|
10463
|
-
return [asset.id, newAsset.id];
|
|
10464
10483
|
})
|
|
10465
10484
|
);
|
|
10466
|
-
const replacementMap = Object.fromEntries(idPairs);
|
|
10467
|
-
state = replaceDeep(state, replacementMap);
|
|
10468
10485
|
}
|
|
10469
10486
|
noyaManager.initialState = state;
|
|
10470
10487
|
noyaManager.forceInit();
|
|
@@ -10497,27 +10514,6 @@ function decodeAll(buffer) {
|
|
|
10497
10514
|
}
|
|
10498
10515
|
return { state, schema, assets, assetMap };
|
|
10499
10516
|
}
|
|
10500
|
-
function replaceDeep(obj, replacementMap) {
|
|
10501
|
-
switch (typeof obj) {
|
|
10502
|
-
case "object":
|
|
10503
|
-
if (obj === null) {
|
|
10504
|
-
return obj;
|
|
10505
|
-
}
|
|
10506
|
-
if (Array.isArray(obj)) {
|
|
10507
|
-
return obj.map((item) => replaceDeep(item, replacementMap));
|
|
10508
|
-
}
|
|
10509
|
-
return Object.fromEntries(
|
|
10510
|
-
Object.entries(obj).map(([key, value]) => [
|
|
10511
|
-
key,
|
|
10512
|
-
replaceDeep(value, replacementMap)
|
|
10513
|
-
])
|
|
10514
|
-
);
|
|
10515
|
-
case "string":
|
|
10516
|
-
return replacementMap[obj] ?? obj;
|
|
10517
|
-
default:
|
|
10518
|
-
return obj;
|
|
10519
|
-
}
|
|
10520
|
-
}
|
|
10521
10517
|
|
|
10522
10518
|
// ../noya-multiplayer-react/src/inspector/StateInspectorTitleLabel.tsx
|
|
10523
10519
|
import React27 from "react";
|
|
@@ -10980,7 +10976,14 @@ var StateInspector = memoGeneric(function StateInspector2({
|
|
|
10980
10976
|
"Upload"
|
|
10981
10977
|
))
|
|
10982
10978
|
},
|
|
10983
|
-
/* @__PURE__ */ React30.createElement(StateInspectorDisclosureRowInner, null, assets.map((asset) => /* @__PURE__ */ React30.createElement(StateInspectorRow, { key: asset.id, colorScheme }, /* @__PURE__ */ React30.createElement(
|
|
10979
|
+
/* @__PURE__ */ React30.createElement(StateInspectorDisclosureRowInner, null, assets.map((asset) => /* @__PURE__ */ React30.createElement(StateInspectorRow, { key: asset.id, colorScheme }, /* @__PURE__ */ React30.createElement(
|
|
10980
|
+
themedObjectInspector,
|
|
10981
|
+
{
|
|
10982
|
+
name: asset.id,
|
|
10983
|
+
data: truncateAsset(asset),
|
|
10984
|
+
theme: theme3
|
|
10985
|
+
}
|
|
10986
|
+
), /* @__PURE__ */ React30.createElement(
|
|
10984
10987
|
StateInspectorButton,
|
|
10985
10988
|
{
|
|
10986
10989
|
theme: theme3,
|
|
@@ -11005,10 +11008,8 @@ var StateInspector = memoGeneric(function StateInspector2({
|
|
|
11005
11008
|
"Are you sure you want to delete all resources?"
|
|
11006
11009
|
);
|
|
11007
11010
|
if (!ok) return;
|
|
11008
|
-
await
|
|
11009
|
-
resources.map(
|
|
11010
|
-
(resource) => resourceManager.deleteResource({ id: resource.id })
|
|
11011
|
-
)
|
|
11011
|
+
await resourceManager.deleteResource(
|
|
11012
|
+
resources.map((resource) => ({ id: resource.id }))
|
|
11012
11013
|
);
|
|
11013
11014
|
}
|
|
11014
11015
|
},
|
|
@@ -11018,7 +11019,7 @@ var StateInspector = memoGeneric(function StateInspector2({
|
|
|
11018
11019
|
{
|
|
11019
11020
|
theme: theme3,
|
|
11020
11021
|
onClick: async () => {
|
|
11021
|
-
const path2 = prompt("Enter directory path") ||
|
|
11022
|
+
const path2 = prompt("Enter directory path") || uuid9();
|
|
11022
11023
|
await resourceManager.createResource({
|
|
11023
11024
|
type: "directory",
|
|
11024
11025
|
path: path2
|
|
@@ -11034,9 +11035,9 @@ var StateInspector = memoGeneric(function StateInspector2({
|
|
|
11034
11035
|
const file = await uploadFile();
|
|
11035
11036
|
resourceManager.createResource({
|
|
11036
11037
|
type: "asset",
|
|
11037
|
-
path: file.name ||
|
|
11038
|
+
path: file.name || uuid9(),
|
|
11038
11039
|
asset: {
|
|
11039
|
-
content:
|
|
11040
|
+
content: Base643.encode(await file.arrayBuffer()),
|
|
11040
11041
|
contentType: file.type,
|
|
11041
11042
|
encoding: "base64"
|
|
11042
11043
|
}
|
|
@@ -11221,6 +11222,12 @@ var StateInspector = memoGeneric(function StateInspector2({
|
|
|
11221
11222
|
)
|
|
11222
11223
|
);
|
|
11223
11224
|
});
|
|
11225
|
+
var truncateAsset = memoize2((asset) => {
|
|
11226
|
+
if (asset.url.startsWith("data:") || asset.url.startsWith("blob:")) {
|
|
11227
|
+
return { ...asset, url: ellipsis(asset.url, 40) };
|
|
11228
|
+
}
|
|
11229
|
+
return asset;
|
|
11230
|
+
});
|
|
11224
11231
|
|
|
11225
11232
|
// ../noya-multiplayer-react/src/hooks.ts
|
|
11226
11233
|
function useManagedHistory(stateManager) {
|
|
@@ -11231,10 +11238,11 @@ function useManagedHistory(stateManager) {
|
|
|
11231
11238
|
);
|
|
11232
11239
|
}
|
|
11233
11240
|
|
|
11241
|
+
// ../noya-multiplayer-react/src/singleton.tsx
|
|
11242
|
+
import React33 from "react";
|
|
11243
|
+
|
|
11234
11244
|
// ../noya-multiplayer-react/src/NoyaStateContext.tsx
|
|
11235
11245
|
var AnyNoyaStateContext = createContext3(void 0);
|
|
11236
|
-
var ConnectedUsersContext = createContext3(void 0);
|
|
11237
|
-
var AnyEphemeralUserDataManagerContext = createContext3(void 0);
|
|
11238
11246
|
var emptyArray = [];
|
|
11239
11247
|
function useActivityEventsForManager(streamFilter, activityEventsManager) {
|
|
11240
11248
|
const [streamId, setStreamId] = useState17(void 0);
|
|
@@ -11253,8 +11261,8 @@ function useActivityEventsForManager(streamFilter, activityEventsManager) {
|
|
|
11253
11261
|
}
|
|
11254
11262
|
|
|
11255
11263
|
// ../noya-multiplayer-react/src/components/UserPointersOverlay.tsx
|
|
11256
|
-
import { Observable as
|
|
11257
|
-
import
|
|
11264
|
+
import { Observable as Observable19 } from "@noya-app/observable";
|
|
11265
|
+
import React35, { useEffect as useEffect17, useMemo as useMemo12, useState as useState18 } from "react";
|
|
11258
11266
|
function shouldShow(hideAfter, updatedAt) {
|
|
11259
11267
|
return !!updatedAt && Date.now() - updatedAt < hideAfter;
|
|
11260
11268
|
}
|
|
@@ -11267,7 +11275,7 @@ var UserPointerInternal = memoGeneric(function UserPointerInternal2({
|
|
|
11267
11275
|
const observable = useMemo12(() => {
|
|
11268
11276
|
const metadata$ = ephemeralUserDataManager.metadata$.observePath([user.id]).throttle(50);
|
|
11269
11277
|
const data$ = ephemeralUserDataManager.data$.observePath([user.id]).throttle(50);
|
|
11270
|
-
return
|
|
11278
|
+
return Observable19.combine([metadata$, data$], ([metadata2, data2]) => {
|
|
11271
11279
|
return { metadata: metadata2, data: data2 };
|
|
11272
11280
|
});
|
|
11273
11281
|
}, [ephemeralUserDataManager, user.id]);
|
|
@@ -11297,9 +11305,9 @@ var UserPointersOverlay = memoGeneric(function UserPointers({
|
|
|
11297
11305
|
}) {
|
|
11298
11306
|
const currentUserId = useObservable2(ephemeralUserDataManager.currentUserId$);
|
|
11299
11307
|
const connectedUsers = useObservable2(connectedUsersManager.connectedUsers$);
|
|
11300
|
-
return /* @__PURE__ */
|
|
11308
|
+
return /* @__PURE__ */ React35.createElement(React35.Fragment, null, connectedUsers.map((user) => {
|
|
11301
11309
|
if (user.id === currentUserId) return null;
|
|
11302
|
-
return /* @__PURE__ */
|
|
11310
|
+
return /* @__PURE__ */ React35.createElement(
|
|
11303
11311
|
UserPointerInternal,
|
|
11304
11312
|
{
|
|
11305
11313
|
key: user.id,
|
|
@@ -11315,7 +11323,7 @@ var UserPointersOverlay = memoGeneric(function UserPointers({
|
|
|
11315
11323
|
import {
|
|
11316
11324
|
RefetchableObservable
|
|
11317
11325
|
} from "@noya-app/observable-store";
|
|
11318
|
-
import { useEffect as useEffect18, useMemo as useMemo13 } from "react";
|
|
11326
|
+
import { useCallback as useCallback15, useEffect as useEffect18, useMemo as useMemo13 } from "react";
|
|
11319
11327
|
function useTable(table, {
|
|
11320
11328
|
where,
|
|
11321
11329
|
select
|
|
@@ -11363,21 +11371,39 @@ function useTable(table, {
|
|
|
11363
11371
|
observable.start?.();
|
|
11364
11372
|
}, [observable]);
|
|
11365
11373
|
const { status, data } = useObservable2(observable);
|
|
11374
|
+
const optimisticUpdate = useCallback15(
|
|
11375
|
+
(entity, config) => {
|
|
11376
|
+
if (!table) return;
|
|
11377
|
+
table.optimisticUpdate(entity, config);
|
|
11378
|
+
},
|
|
11379
|
+
[table]
|
|
11380
|
+
);
|
|
11366
11381
|
return useMemo13(() => {
|
|
11367
11382
|
return {
|
|
11368
11383
|
status,
|
|
11369
11384
|
data,
|
|
11370
|
-
refetch: observable.refetch
|
|
11385
|
+
refetch: observable.refetch,
|
|
11386
|
+
optimisticUpdate
|
|
11371
11387
|
};
|
|
11372
|
-
}, [status, data, observable]);
|
|
11388
|
+
}, [status, data, observable, optimisticUpdate]);
|
|
11373
11389
|
}
|
|
11374
11390
|
function useFileList(select, options = {}) {
|
|
11375
11391
|
const client = useNoyaClientOrFallback();
|
|
11376
|
-
|
|
11392
|
+
const { status, data, refetch, optimisticUpdate } = useTable(
|
|
11393
|
+
client.fileList$,
|
|
11394
|
+
{ select },
|
|
11395
|
+
options
|
|
11396
|
+
);
|
|
11397
|
+
return {
|
|
11398
|
+
status,
|
|
11399
|
+
data,
|
|
11400
|
+
refetch,
|
|
11401
|
+
optimisticUpdate
|
|
11402
|
+
};
|
|
11377
11403
|
}
|
|
11378
11404
|
function useFileListItem(id, select, options = {}) {
|
|
11379
11405
|
const client = useNoyaClientOrFallback();
|
|
11380
|
-
const { status, data, refetch } = useTable(
|
|
11406
|
+
const { status, data, refetch, optimisticUpdate } = useTable(
|
|
11381
11407
|
client.fileList$,
|
|
11382
11408
|
{ where: { id: id ?? null }, select },
|
|
11383
11409
|
options
|
|
@@ -11386,21 +11412,28 @@ function useFileListItem(id, select, options = {}) {
|
|
|
11386
11412
|
return {
|
|
11387
11413
|
data: data.at(0),
|
|
11388
11414
|
status,
|
|
11389
|
-
refetch
|
|
11415
|
+
refetch,
|
|
11416
|
+
optimisticUpdate
|
|
11390
11417
|
};
|
|
11391
|
-
}, [data, status, refetch]);
|
|
11418
|
+
}, [data, status, refetch, optimisticUpdate]);
|
|
11392
11419
|
}
|
|
11393
11420
|
function useResourcesList(fileId, select, options = {}) {
|
|
11394
11421
|
const client = useNoyaClientOrFallback();
|
|
11395
|
-
|
|
11422
|
+
const { status, data, refetch, optimisticUpdate } = useTable(
|
|
11396
11423
|
client.resources$,
|
|
11397
11424
|
{ select, where: { accessibleByFileId: fileId } },
|
|
11398
11425
|
options
|
|
11399
11426
|
);
|
|
11427
|
+
return {
|
|
11428
|
+
status,
|
|
11429
|
+
data,
|
|
11430
|
+
refetch,
|
|
11431
|
+
optimisticUpdate
|
|
11432
|
+
};
|
|
11400
11433
|
}
|
|
11401
11434
|
function useUser(id, select, options = {}) {
|
|
11402
11435
|
const client = useNoyaClientOrFallback();
|
|
11403
|
-
const { status, data, refetch } = useTable(
|
|
11436
|
+
const { status, data, refetch, optimisticUpdate } = useTable(
|
|
11404
11437
|
client.users$,
|
|
11405
11438
|
{ select, where: { id: id ?? null } },
|
|
11406
11439
|
options
|
|
@@ -11409,17 +11442,24 @@ function useUser(id, select, options = {}) {
|
|
|
11409
11442
|
return {
|
|
11410
11443
|
status,
|
|
11411
11444
|
data: data.at(0),
|
|
11412
|
-
refetch
|
|
11445
|
+
refetch,
|
|
11446
|
+
optimisticUpdate
|
|
11413
11447
|
};
|
|
11414
|
-
}, [status, data, refetch]);
|
|
11448
|
+
}, [status, data, refetch, optimisticUpdate]);
|
|
11415
11449
|
}
|
|
11416
11450
|
function useActivityEventsList(fileId, select, options = {}) {
|
|
11417
11451
|
const client = useNoyaClientOrFallback();
|
|
11418
|
-
|
|
11452
|
+
const { status, data, refetch, optimisticUpdate } = useTable(
|
|
11419
11453
|
client.activityEvents$,
|
|
11420
11454
|
{ select, where: { fileId } },
|
|
11421
11455
|
options
|
|
11422
11456
|
);
|
|
11457
|
+
return {
|
|
11458
|
+
status,
|
|
11459
|
+
data,
|
|
11460
|
+
refetch,
|
|
11461
|
+
optimisticUpdate
|
|
11462
|
+
};
|
|
11423
11463
|
}
|
|
11424
11464
|
export {
|
|
11425
11465
|
NoyaAPIProvider,
|