@seedprotocol/sdk 0.1.41 → 0.1.42
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/{index-BvH0sjnH.js → index-CQMUGXEO.js} +53 -39
- package/dist/index-CQMUGXEO.js.map +1 -0
- package/dist/{index-ClKB3DC-.js → index-CRxO3Kq1.js} +2 -2
- package/dist/index-CRxO3Kq1.js.map +1 -0
- package/dist/main.js +1 -1
- package/dist/{seed-Bj6wb5Jr.js → seed-CZTfFPC0.js} +3 -3
- package/dist/{seed-Bj6wb5Jr.js.map → seed-CZTfFPC0.js.map} +1 -1
- package/dist/{seed-DJoW3qHO.js → seed-Du6tH8GQ.js} +2 -2
- package/dist/{seed-DJoW3qHO.js.map → seed-Du6tH8GQ.js.map} +1 -1
- package/dist/{seed-BpJsAlzT.js → seed-X5AZrDlF.js} +3 -3
- package/dist/{seed-BpJsAlzT.js.map → seed-X5AZrDlF.js.map} +1 -1
- package/dist/{seed.schema.config-CtfrG9dk.js → seed.schema.config-C1msLpdD.js} +3 -3
- package/dist/{seed.schema.config-CtfrG9dk.js.map → seed.schema.config-C1msLpdD.js.map} +1 -1
- package/dist/types/src/browser/db/read/getItems.d.ts +7 -1
- package/dist/types/src/browser/db/read/getItems.d.ts.map +1 -1
- package/dist/types/src/browser/db/write/deleteItem.d.ts +8 -0
- package/dist/types/src/browser/db/write/deleteItem.d.ts.map +1 -0
- package/dist/types/src/browser/db/write/recoverDeletedItem.d.ts +5 -0
- package/dist/types/src/browser/db/write/recoverDeletedItem.d.ts.map +1 -0
- package/dist/types/src/browser/db/write.d.ts +0 -3
- package/dist/types/src/browser/db/write.d.ts.map +1 -1
- package/dist/types/src/browser/item/class.d.ts +1 -1
- package/dist/types/src/browser/item/class.d.ts.map +1 -1
- package/dist/types/src/browser/react/index.d.ts +1 -0
- package/dist/types/src/browser/react/index.d.ts.map +1 -1
- package/dist/types/src/browser/react/item.d.ts +3 -7
- package/dist/types/src/browser/react/item.d.ts.map +1 -1
- package/dist/types/src/browser/react/trash.d.ts +6 -0
- package/dist/types/src/browser/react/trash.d.ts.map +1 -0
- package/package.json +1 -1
- package/dist/index-BvH0sjnH.js.map +0 -1
- package/dist/index-ClKB3DC-.js.map +0 -1
|
@@ -3,7 +3,7 @@ import path, { basename } from 'path';
|
|
|
3
3
|
import 'reflect-metadata';
|
|
4
4
|
import { Type } from '@sinclair/typebox';
|
|
5
5
|
import { fromCallback, setup, assign, createActor, waitFor, emit, raise } from 'xstate';
|
|
6
|
-
import { sql, relations, and, eq, max, or, count, isNull, like } from 'drizzle-orm';
|
|
6
|
+
import { sql, relations, and, eq, max, or, count, isNotNull, isNull, like } from 'drizzle-orm';
|
|
7
7
|
import { fs, configureSingle } from '@zenfs/core';
|
|
8
8
|
import 'dayjs';
|
|
9
9
|
import { customAlphabet } from 'nanoid';
|
|
@@ -984,7 +984,7 @@ const hydrateFromDb = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
984
984
|
renderValue: refResolvedDisplayValue,
|
|
985
985
|
});
|
|
986
986
|
if (propertyNameFromDb === 'storageTransactionId') {
|
|
987
|
-
const { Item } = yield import('./index-
|
|
987
|
+
const { Item } = yield import('./index-CRxO3Kq1.js');
|
|
988
988
|
const item = yield Item.find({
|
|
989
989
|
seedLocalId,
|
|
990
990
|
modelName: itemModelName,
|
|
@@ -1139,12 +1139,6 @@ const createNewItem = (_a) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
1139
1139
|
versionLocalId: newVersionId,
|
|
1140
1140
|
};
|
|
1141
1141
|
});
|
|
1142
|
-
const deleteItem = (_a) => __awaiter(void 0, [_a], void 0, function* ({ seedLocalId }) {
|
|
1143
|
-
const appDb = getAppDb();
|
|
1144
|
-
yield appDb.run(sql.raw(`UPDATE seeds
|
|
1145
|
-
SET _marked_for_deletion = 1
|
|
1146
|
-
WHERE local_id = '${seedLocalId}';`));
|
|
1147
|
-
});
|
|
1148
1142
|
const updateItemPropertyValue = (_a) => __awaiter(void 0, [_a], void 0, function* ({ propertyLocalId, propertyName, newValue, seedUid, seedLocalId, modelName, refSeedType, refResolvedValue, refResolvedDisplayValue, versionLocalId, versionUid, schemaUid, }) {
|
|
1149
1143
|
if (!propertyLocalId && !seedLocalId) {
|
|
1150
1144
|
logger$k(`[db/write] [updateItemPropertyValue] no propertyLocalId or seedLocalId for property: ${propertyName}`);
|
|
@@ -3103,9 +3097,9 @@ const itemMachineSingle = setup({
|
|
|
3103
3097
|
},
|
|
3104
3098
|
});
|
|
3105
3099
|
|
|
3106
|
-
const getItemsData = (
|
|
3100
|
+
const getItemsData = (_a) => __awaiter(void 0, [_a], void 0, function* ({ modelName, deleted, }) {
|
|
3107
3101
|
const appDb = getAppDb();
|
|
3108
|
-
|
|
3102
|
+
let query = appDb
|
|
3109
3103
|
.select({
|
|
3110
3104
|
seedLocalId: seeds.localId,
|
|
3111
3105
|
seedUid: seeds.uid,
|
|
@@ -3118,8 +3112,17 @@ const getItemsData = (modelName) => __awaiter(void 0, void 0, void 0, function*
|
|
|
3118
3112
|
})
|
|
3119
3113
|
.from(seeds)
|
|
3120
3114
|
.leftJoin(versions, eq(seeds.localId, versions.seedLocalId))
|
|
3121
|
-
|
|
3122
|
-
|
|
3115
|
+
.$dynamic();
|
|
3116
|
+
if (modelName) {
|
|
3117
|
+
query = query.where(eq(seeds.type, modelName.toLowerCase()));
|
|
3118
|
+
}
|
|
3119
|
+
if (deleted) {
|
|
3120
|
+
query = query.where(or(isNotNull(seeds._markedForDeletion), eq(seeds._markedForDeletion, 1)));
|
|
3121
|
+
}
|
|
3122
|
+
if (!deleted) {
|
|
3123
|
+
query = query.where(or(isNull(seeds._markedForDeletion), eq(seeds._markedForDeletion, 0)));
|
|
3124
|
+
}
|
|
3125
|
+
const itemsData = (yield query.groupBy(seeds.localId));
|
|
3123
3126
|
return itemsData;
|
|
3124
3127
|
});
|
|
3125
3128
|
|
|
@@ -3406,9 +3409,9 @@ class Item {
|
|
|
3406
3409
|
return Item.create(Object.assign(Object.assign({}, itemData), { modelName }));
|
|
3407
3410
|
});
|
|
3408
3411
|
}
|
|
3409
|
-
static all(modelName) {
|
|
3412
|
+
static all(modelName, deleted) {
|
|
3410
3413
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3411
|
-
const itemsData = yield getItemsData(modelName);
|
|
3414
|
+
const itemsData = yield getItemsData({ modelName, deleted });
|
|
3412
3415
|
const itemInstances = [];
|
|
3413
3416
|
for (const itemData of itemsData) {
|
|
3414
3417
|
itemInstances.push(yield Item.create(Object.assign(Object.assign({}, itemData), { modelName })));
|
|
@@ -4368,7 +4371,7 @@ const addModelsToDb = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
4368
4371
|
if (!models$1) {
|
|
4369
4372
|
return;
|
|
4370
4373
|
}
|
|
4371
|
-
const { models: SeedModels } = yield import('./seed.schema.config-
|
|
4374
|
+
const { models: SeedModels } = yield import('./seed.schema.config-C1msLpdD.js');
|
|
4372
4375
|
const allModels = Object.assign(Object.assign({}, SeedModels), models$1);
|
|
4373
4376
|
let hasModelsInDb = false;
|
|
4374
4377
|
const schemaDefsByModelName = new Map();
|
|
@@ -5844,11 +5847,11 @@ const globalMachine = setup({
|
|
|
5844
5847
|
(_a) => __awaiter(void 0, [_a], void 0, function* ({ context }) {
|
|
5845
5848
|
let SeedClass;
|
|
5846
5849
|
if (context.environment === 'node') {
|
|
5847
|
-
const { SeedNode } = yield import('./seed-
|
|
5850
|
+
const { SeedNode } = yield import('./seed-CZTfFPC0.js');
|
|
5848
5851
|
SeedClass = SeedNode;
|
|
5849
5852
|
}
|
|
5850
5853
|
else {
|
|
5851
|
-
const { SeedBrowser } = yield import('./seed-
|
|
5854
|
+
const { SeedBrowser } = yield import('./seed-X5AZrDlF.js');
|
|
5852
5855
|
SeedClass = SeedBrowser;
|
|
5853
5856
|
}
|
|
5854
5857
|
return SeedClass;
|
|
@@ -6180,7 +6183,7 @@ const useItem = ({ modelName, seedLocalId, seedUid }) => {
|
|
|
6180
6183
|
itemStatus,
|
|
6181
6184
|
};
|
|
6182
6185
|
};
|
|
6183
|
-
const useItems = ({ modelName,
|
|
6186
|
+
const useItems = ({ modelName, deleted }) => {
|
|
6184
6187
|
const [items, setItems] = useImmer([]);
|
|
6185
6188
|
const [isReadingDb, setIsReadingDb] = useState(false);
|
|
6186
6189
|
const [isInitialized, setIsInitialized] = useState(false);
|
|
@@ -6194,7 +6197,7 @@ const useItems = ({ modelName, options }) => {
|
|
|
6194
6197
|
return;
|
|
6195
6198
|
}
|
|
6196
6199
|
setIsReadingDb(true);
|
|
6197
|
-
const allItems = yield Item.all(modelNameRef.current);
|
|
6200
|
+
const allItems = yield Item.all(modelNameRef.current, deleted);
|
|
6198
6201
|
setItems(() => allItems);
|
|
6199
6202
|
setIsReadingDb(false);
|
|
6200
6203
|
}), [modelName, isReadingDb]);
|
|
@@ -6266,24 +6269,6 @@ const useCreateItem = (modelName) => {
|
|
|
6266
6269
|
isCreatingItem,
|
|
6267
6270
|
};
|
|
6268
6271
|
};
|
|
6269
|
-
const useDeleteItem = () => {
|
|
6270
|
-
const [isDeletingItem, setIsDeletingItem] = useState(false);
|
|
6271
|
-
const destroy = useCallback((item) => __awaiter(void 0, void 0, void 0, function* () {
|
|
6272
|
-
if (!item) {
|
|
6273
|
-
return;
|
|
6274
|
-
}
|
|
6275
|
-
setIsDeletingItem(true);
|
|
6276
|
-
const { modelName } = item.getService().getSnapshot().context;
|
|
6277
|
-
yield deleteItem({ seedLocalId: item.seedLocalId });
|
|
6278
|
-
eventEmitter.emit('item.requestAll', { modelName });
|
|
6279
|
-
setIsDeletingItem(false);
|
|
6280
|
-
}), [isDeletingItem]);
|
|
6281
|
-
useEffect(() => { }, []);
|
|
6282
|
-
return {
|
|
6283
|
-
deleteItem: destroy,
|
|
6284
|
-
isDeletingItem,
|
|
6285
|
-
};
|
|
6286
|
-
};
|
|
6287
6272
|
|
|
6288
6273
|
const logger$1 = debug('app:react:property');
|
|
6289
6274
|
const useItemProperty = ({ propertyName, seedLocalId, seedUid, }) => {
|
|
@@ -6394,6 +6379,35 @@ const useItemProperties = (item) => {
|
|
|
6394
6379
|
|
|
6395
6380
|
debug('app:react:db');
|
|
6396
6381
|
|
|
6382
|
+
const deleteItem = (_a) => __awaiter(void 0, [_a], void 0, function* ({ seedLocalId, seedUid }) {
|
|
6383
|
+
const appDb = getAppDb();
|
|
6384
|
+
yield appDb
|
|
6385
|
+
.update(seeds)
|
|
6386
|
+
.set({
|
|
6387
|
+
_markedForDeletion: 1,
|
|
6388
|
+
})
|
|
6389
|
+
.where(or(eq(seeds.localId, seedLocalId), eq(seeds.uid, seedUid)));
|
|
6390
|
+
});
|
|
6391
|
+
|
|
6392
|
+
const useDeleteItem = () => {
|
|
6393
|
+
const [isDeletingItem, setIsDeletingItem] = useState(false);
|
|
6394
|
+
const destroy = useCallback((item) => __awaiter(void 0, void 0, void 0, function* () {
|
|
6395
|
+
if (!item) {
|
|
6396
|
+
return;
|
|
6397
|
+
}
|
|
6398
|
+
setIsDeletingItem(true);
|
|
6399
|
+
const { modelName } = item.getService().getSnapshot().context;
|
|
6400
|
+
yield deleteItem({ seedLocalId: item.seedLocalId });
|
|
6401
|
+
eventEmitter.emit('item.requestAll', { modelName });
|
|
6402
|
+
setIsDeletingItem(false);
|
|
6403
|
+
}), [isDeletingItem]);
|
|
6404
|
+
useEffect(() => { }, []);
|
|
6405
|
+
return {
|
|
6406
|
+
deleteItem: destroy,
|
|
6407
|
+
isDeletingItem,
|
|
6408
|
+
};
|
|
6409
|
+
};
|
|
6410
|
+
|
|
6397
6411
|
const logger = debug('app:services:events');
|
|
6398
6412
|
const handleServiceSaveState = (event) => {
|
|
6399
6413
|
const { state, serviceId } = event;
|
|
@@ -6684,7 +6698,7 @@ const client = {
|
|
|
6684
6698
|
console.error('fs listeners not ready during init');
|
|
6685
6699
|
}
|
|
6686
6700
|
globalService.send({ type: 'init', endpoints, models, addresses });
|
|
6687
|
-
import('./seed.schema.config-
|
|
6701
|
+
import('./seed.schema.config-C1msLpdD.js').then(({ models }) => {
|
|
6688
6702
|
for (const [key, value] of Object.entries(models)) {
|
|
6689
6703
|
setModel(key, value);
|
|
6690
6704
|
}
|
|
@@ -6741,4 +6755,4 @@ if (isNode()) {
|
|
|
6741
6755
|
}
|
|
6742
6756
|
|
|
6743
6757
|
export { CHILD_SNAPSHOT as C, GET_SCHEMAS as G, Item as I, Json as J, List as L, Model as M, Property as P, Relation as R, Text as T, GET_SEEDS as a, GET_SEED_IDS as b, GET_STORAGE_TRANSACTION_ID as c, GET_VERSIONS as d, GET_PROPERTIES as e, GET_ALL_PROPERTIES_FOR_ALL_VERSIONS as f, itemMachineAll as g, internalMachine as h, itemMachineSingle as i, isNode as j, isBrowser as k, isReactNative as l, ImageSrc as m, ItemProperty as n, useItem as o, useItemProperties as p, useCreateItem as q, useItemProperty as r, useDeleteItem as s, useGlobalServiceStatus as t, useItems as u, useServices as v, withSeed as w, getGlobalService as x, client as y, getCorrectId as z };
|
|
6744
|
-
//# sourceMappingURL=index-
|
|
6758
|
+
//# sourceMappingURL=index-CQMUGXEO.js.map
|