@seedprotocol/sdk 0.1.73 → 0.1.74
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-Clo50o_L.js → index-3ASvLLXY.js} +8 -8
- package/dist/{index-Clo50o_L.js.map → index-3ASvLLXY.js.map} +1 -1
- package/dist/{index-BmDmbqJM.js → index-Br7jo_vg.js} +90 -64
- package/dist/index-Br7jo_vg.js.map +1 -0
- package/dist/main.js +6 -6
- package/dist/{seed.schema.config-DfD4DkGq.js → seed.schema.config-BHNlL53f.js} +8 -8
- package/dist/{seed.schema.config-DfD4DkGq.js.map → seed.schema.config-BHNlL53f.js.map} +1 -1
- package/dist/src/actors.ts +282 -7
- package/dist/src/getSchemaUidForModel.ts +27 -0
- package/dist/src/index.ts +62 -10
- package/dist/src/write.ts +8 -0
- package/dist/types/src/browser/db/read/getSchemaUidForModel.d.ts +2 -0
- package/dist/types/src/browser/db/read/getSchemaUidForModel.d.ts.map +1 -0
- package/dist/types/src/browser/db/write.d.ts.map +1 -1
- package/dist/types/src/browser/item/Item.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/index-BmDmbqJM.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { g as GET_ALL_PROPERTIES_FOR_ALL_VERSIONS, f as GET_PROPERTIES, G as GET_SCHEMAS, a as GET_SCHEMA_BY_NAME, b as GET_SEEDS, c as GET_SEED_IDS, d as GET_STORAGE_TRANSACTION_ID, e as GET_VERSIONS, I as Item, h as itemMachineAll, i as itemMachineSingle } from './index-
|
|
1
|
+
export { g as GET_ALL_PROPERTIES_FOR_ALL_VERSIONS, f as GET_PROPERTIES, G as GET_SCHEMAS, a as GET_SCHEMA_BY_NAME, b as GET_SEEDS, c as GET_SEED_IDS, d as GET_STORAGE_TRANSACTION_ID, e as GET_VERSIONS, I as Item, h as itemMachineAll, i as itemMachineSingle } from './index-Br7jo_vg.js';
|
|
2
2
|
import './constants-CtmwCBma.js';
|
|
3
3
|
import '@ethereum-attestation-service/eas-sdk';
|
|
4
4
|
import 'thirdweb';
|
|
@@ -15,18 +15,18 @@ import 'debug';
|
|
|
15
15
|
import 'lodash-es';
|
|
16
16
|
import 'drizzle-orm/sqlite-core';
|
|
17
17
|
import 'react';
|
|
18
|
-
import 'rxjs';
|
|
19
|
-
import 'immer';
|
|
20
|
-
import 'pluralize';
|
|
21
|
-
import 'eventemitter3';
|
|
22
18
|
import '@tanstack/react-query';
|
|
23
19
|
import 'graphql-request';
|
|
24
20
|
import '@tanstack/query-sync-storage-persister';
|
|
25
21
|
import '@tanstack/react-query-persist-client';
|
|
22
|
+
import 'use-immer';
|
|
23
|
+
import '@xstate/react';
|
|
24
|
+
import 'eventemitter3';
|
|
25
|
+
import 'immer';
|
|
26
|
+
import 'pluralize';
|
|
26
27
|
import '@statelyai/inspect';
|
|
28
|
+
import 'rxjs';
|
|
27
29
|
import 'drizzle-orm/sqlite-proxy';
|
|
28
30
|
import '@zenfs/dom';
|
|
29
31
|
import 'arweave';
|
|
30
|
-
|
|
31
|
-
import '@xstate/react';
|
|
32
|
-
//# sourceMappingURL=index-Clo50o_L.js.map
|
|
32
|
+
//# sourceMappingURL=index-3ASvLLXY.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index-
|
|
1
|
+
{"version":3,"file":"index-3ASvLLXY.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -12,20 +12,20 @@ import debug from 'debug';
|
|
|
12
12
|
import { startCase, debounce, camelCase, orderBy } from 'lodash-es';
|
|
13
13
|
import { sqliteTable, text, int, blob, check, unique } from 'drizzle-orm/sqlite-core';
|
|
14
14
|
import { useState, useEffect, useRef, useCallback } from 'react';
|
|
15
|
-
import { BehaviorSubject } from 'rxjs';
|
|
16
|
-
import { immerable, produce, enableMapSet } from 'immer';
|
|
17
|
-
import pluralize from 'pluralize';
|
|
18
|
-
import EventEmitter from 'eventemitter3';
|
|
19
15
|
import { QueryClient } from '@tanstack/react-query';
|
|
20
16
|
import { GraphQLClient } from 'graphql-request';
|
|
21
17
|
import { createSyncStoragePersister } from '@tanstack/query-sync-storage-persister';
|
|
22
18
|
import { persistQueryClient } from '@tanstack/react-query-persist-client';
|
|
19
|
+
import { useImmer } from 'use-immer';
|
|
20
|
+
import { useSelector } from '@xstate/react';
|
|
21
|
+
import EventEmitter from 'eventemitter3';
|
|
22
|
+
import { immerable, produce, enableMapSet } from 'immer';
|
|
23
|
+
import pluralize from 'pluralize';
|
|
23
24
|
import { createBrowserInspector } from '@statelyai/inspect';
|
|
25
|
+
import { BehaviorSubject } from 'rxjs';
|
|
24
26
|
import { drizzle } from 'drizzle-orm/sqlite-proxy';
|
|
25
27
|
import { WebAccess } from '@zenfs/dom';
|
|
26
28
|
import Arweave from 'arweave';
|
|
27
|
-
import { useImmer } from 'use-immer';
|
|
28
|
-
import { useSelector } from '@xstate/react';
|
|
29
29
|
import { ZERO_ADDRESS } from 'thirdweb';
|
|
30
30
|
import { SchemaEncoder } from '@ethereum-attestation-service/eas-sdk';
|
|
31
31
|
|
|
@@ -1044,7 +1044,7 @@ const hydrateFromDb = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
1044
1044
|
if (propertyRecordSchema &&
|
|
1045
1045
|
propertyRecordSchema.storageType &&
|
|
1046
1046
|
propertyRecordSchema.storageType === 'ItemStorage') {
|
|
1047
|
-
const { Item } = yield import('./index-
|
|
1047
|
+
const { Item } = yield import('./index-3ASvLLXY.js');
|
|
1048
1048
|
const item = yield Item.find({
|
|
1049
1049
|
seedLocalId,
|
|
1050
1050
|
modelName: itemModelName,
|
|
@@ -1166,59 +1166,6 @@ const setModel = (modelName, model) => {
|
|
|
1166
1166
|
modelStore.set(modelName, model);
|
|
1167
1167
|
};
|
|
1168
1168
|
|
|
1169
|
-
debug('app:write');
|
|
1170
|
-
const createSeed = (_a) => __awaiter(void 0, [_a], void 0, function* ({ type, seedUid }) {
|
|
1171
|
-
const appDb = getAppDb();
|
|
1172
|
-
const newSeedLocalId = generateId();
|
|
1173
|
-
yield appDb.insert(seeds).values({
|
|
1174
|
-
localId: newSeedLocalId,
|
|
1175
|
-
type,
|
|
1176
|
-
uid: seedUid,
|
|
1177
|
-
createdAt: Date.now(),
|
|
1178
|
-
});
|
|
1179
|
-
return newSeedLocalId;
|
|
1180
|
-
});
|
|
1181
|
-
const createNewItem = (_a) => __awaiter(void 0, void 0, void 0, function* () {
|
|
1182
|
-
var _b;
|
|
1183
|
-
var { modelName } = _a, propertyData = __rest(_a, ["modelName"]);
|
|
1184
|
-
if (!modelName) {
|
|
1185
|
-
throw new Error('A model name is required for createNewItem');
|
|
1186
|
-
}
|
|
1187
|
-
const seedType = modelName.toLowerCase();
|
|
1188
|
-
const newSeedId = yield createSeed({ type: seedType });
|
|
1189
|
-
const newVersionId = yield createVersion({ seedLocalId: newSeedId });
|
|
1190
|
-
const propertySchemas = (_b = getModel(modelName)) === null || _b === void 0 ? void 0 : _b.schema;
|
|
1191
|
-
for (const [propertyName, propertyValue] of Object.entries(propertyData)) {
|
|
1192
|
-
let propertyRecordSchema;
|
|
1193
|
-
if (propertySchemas && propertySchemas[propertyName]) {
|
|
1194
|
-
propertyRecordSchema = propertySchemas[propertyName];
|
|
1195
|
-
}
|
|
1196
|
-
yield createMetadata({
|
|
1197
|
-
seedLocalId: newSeedId,
|
|
1198
|
-
versionLocalId: newVersionId,
|
|
1199
|
-
propertyName,
|
|
1200
|
-
propertyValue,
|
|
1201
|
-
modelName,
|
|
1202
|
-
}, propertyRecordSchema);
|
|
1203
|
-
// await appDb.run(
|
|
1204
|
-
// sql.raw(
|
|
1205
|
-
// `INSERT INTO metadata (seed_local_id, version_local_id, property_name, property_value, model_type, created_at,
|
|
1206
|
-
// attestation_created_at)
|
|
1207
|
-
// VALUES ('${newSeedId}', '${newVersionId}', '${propertyName}', '${propertyValue}', '${seedType}', ${Date.now()},
|
|
1208
|
-
// ${Date.now()});`,
|
|
1209
|
-
// ),
|
|
1210
|
-
// )
|
|
1211
|
-
}
|
|
1212
|
-
// eventEmitter.emit(`item.requestAll`, { modelName })
|
|
1213
|
-
return {
|
|
1214
|
-
modelName,
|
|
1215
|
-
seedLocalId: newSeedId,
|
|
1216
|
-
versionLocalId: newVersionId,
|
|
1217
|
-
};
|
|
1218
|
-
});
|
|
1219
|
-
|
|
1220
|
-
const eventEmitter = new EventEmitter();
|
|
1221
|
-
|
|
1222
1169
|
var MachineIds;
|
|
1223
1170
|
(function (MachineIds) {
|
|
1224
1171
|
MachineIds["GLOBAL"] = "@seedSdk/global";
|
|
@@ -1352,6 +1299,86 @@ const updateMachineContext = {
|
|
|
1352
1299
|
}),
|
|
1353
1300
|
};
|
|
1354
1301
|
|
|
1302
|
+
const getSchemaUidForModel = (modelName) => __awaiter(void 0, void 0, void 0, function* () {
|
|
1303
|
+
const modeType = modelName.toLowerCase();
|
|
1304
|
+
const modelSchemaQuery = yield queryClient.fetchQuery({
|
|
1305
|
+
queryKey: [`getPropertySchema${modelName}`],
|
|
1306
|
+
queryFn: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
1307
|
+
return easClient.request(GET_SCHEMAS, {
|
|
1308
|
+
where: {
|
|
1309
|
+
schemaNames: {
|
|
1310
|
+
some: {
|
|
1311
|
+
name: {
|
|
1312
|
+
equals: modeType,
|
|
1313
|
+
},
|
|
1314
|
+
},
|
|
1315
|
+
},
|
|
1316
|
+
},
|
|
1317
|
+
});
|
|
1318
|
+
}),
|
|
1319
|
+
});
|
|
1320
|
+
const foundSchema = modelSchemaQuery.schemas[0];
|
|
1321
|
+
return foundSchema.id;
|
|
1322
|
+
});
|
|
1323
|
+
|
|
1324
|
+
debug('app:write');
|
|
1325
|
+
const createSeed = (_a) => __awaiter(void 0, [_a], void 0, function* ({ type, seedUid }) {
|
|
1326
|
+
const schemaUid = yield getSchemaUidForModel(type);
|
|
1327
|
+
if (!schemaUid) {
|
|
1328
|
+
throw new Error(`No schema found for model type: ${type}`);
|
|
1329
|
+
}
|
|
1330
|
+
const appDb = getAppDb();
|
|
1331
|
+
const newSeedLocalId = generateId();
|
|
1332
|
+
yield appDb.insert(seeds).values({
|
|
1333
|
+
localId: newSeedLocalId,
|
|
1334
|
+
type,
|
|
1335
|
+
uid: seedUid,
|
|
1336
|
+
createdAt: Date.now(),
|
|
1337
|
+
schemaUid,
|
|
1338
|
+
});
|
|
1339
|
+
return newSeedLocalId;
|
|
1340
|
+
});
|
|
1341
|
+
const createNewItem = (_a) => __awaiter(void 0, void 0, void 0, function* () {
|
|
1342
|
+
var _b;
|
|
1343
|
+
var { modelName } = _a, propertyData = __rest(_a, ["modelName"]);
|
|
1344
|
+
if (!modelName) {
|
|
1345
|
+
throw new Error('A model name is required for createNewItem');
|
|
1346
|
+
}
|
|
1347
|
+
const seedType = modelName.toLowerCase();
|
|
1348
|
+
const newSeedId = yield createSeed({ type: seedType });
|
|
1349
|
+
const newVersionId = yield createVersion({ seedLocalId: newSeedId });
|
|
1350
|
+
const propertySchemas = (_b = getModel(modelName)) === null || _b === void 0 ? void 0 : _b.schema;
|
|
1351
|
+
for (const [propertyName, propertyValue] of Object.entries(propertyData)) {
|
|
1352
|
+
let propertyRecordSchema;
|
|
1353
|
+
if (propertySchemas && propertySchemas[propertyName]) {
|
|
1354
|
+
propertyRecordSchema = propertySchemas[propertyName];
|
|
1355
|
+
}
|
|
1356
|
+
yield createMetadata({
|
|
1357
|
+
seedLocalId: newSeedId,
|
|
1358
|
+
versionLocalId: newVersionId,
|
|
1359
|
+
propertyName,
|
|
1360
|
+
propertyValue,
|
|
1361
|
+
modelName,
|
|
1362
|
+
}, propertyRecordSchema);
|
|
1363
|
+
// await appDb.run(
|
|
1364
|
+
// sql.raw(
|
|
1365
|
+
// `INSERT INTO metadata (seed_local_id, version_local_id, property_name, property_value, model_type, created_at,
|
|
1366
|
+
// attestation_created_at)
|
|
1367
|
+
// VALUES ('${newSeedId}', '${newVersionId}', '${propertyName}', '${propertyValue}', '${seedType}', ${Date.now()},
|
|
1368
|
+
// ${Date.now()});`,
|
|
1369
|
+
// ),
|
|
1370
|
+
// )
|
|
1371
|
+
}
|
|
1372
|
+
// eventEmitter.emit(`item.requestAll`, { modelName })
|
|
1373
|
+
return {
|
|
1374
|
+
modelName,
|
|
1375
|
+
seedLocalId: newSeedId,
|
|
1376
|
+
versionLocalId: newVersionId,
|
|
1377
|
+
};
|
|
1378
|
+
});
|
|
1379
|
+
|
|
1380
|
+
const eventEmitter = new EventEmitter();
|
|
1381
|
+
|
|
1355
1382
|
var _a$2;
|
|
1356
1383
|
const logger$l = debug('app:property:class');
|
|
1357
1384
|
const namesThatEndWithId = [];
|
|
@@ -2548,7 +2575,7 @@ const addModelsToDb = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
2548
2575
|
if (!models$1) {
|
|
2549
2576
|
return;
|
|
2550
2577
|
}
|
|
2551
|
-
const { models: SeedModels } = yield import('./seed.schema.config-
|
|
2578
|
+
const { models: SeedModels } = yield import('./seed.schema.config-BHNlL53f.js');
|
|
2552
2579
|
const allModels = Object.assign(Object.assign({}, SeedModels), models$1);
|
|
2553
2580
|
let hasModelsInDb = false;
|
|
2554
2581
|
const schemaDefsByModelName = new Map();
|
|
@@ -5953,7 +5980,6 @@ class Item {
|
|
|
5953
5980
|
versionLocalId: latestVersionLocalId,
|
|
5954
5981
|
versionUid: latestVersionUid,
|
|
5955
5982
|
itemModelName: modelName,
|
|
5956
|
-
schemaUid,
|
|
5957
5983
|
};
|
|
5958
5984
|
if (ModelClass && ModelClass.schema) {
|
|
5959
5985
|
const schema = ModelClass.schema;
|
|
@@ -6636,7 +6662,7 @@ const client = {
|
|
|
6636
6662
|
console.error('fs listeners not ready during init');
|
|
6637
6663
|
}
|
|
6638
6664
|
globalService.send({ type: 'init', endpoints, models, addresses });
|
|
6639
|
-
import('./seed.schema.config-
|
|
6665
|
+
import('./seed.schema.config-BHNlL53f.js').then(({ models }) => {
|
|
6640
6666
|
for (const [key, value] of Object.entries(models)) {
|
|
6641
6667
|
setModel(key, value);
|
|
6642
6668
|
}
|
|
@@ -7597,4 +7623,4 @@ if (isNode()) {
|
|
|
7597
7623
|
}
|
|
7598
7624
|
|
|
7599
7625
|
export { 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_SCHEMA_BY_NAME as a, GET_SEEDS as b, GET_SEED_IDS as c, GET_STORAGE_TRANSACTION_ID as d, GET_VERSIONS as e, GET_PROPERTIES as f, GET_ALL_PROPERTIES_FOR_ALL_VERSIONS as g, itemMachineAll as h, itemMachineSingle as i, ImageSrc as j, ItemProperty as k, useItem as l, useItemProperties as m, useCreateItem as n, useItemProperty as o, useDeleteItem as p, useGlobalServiceStatus as q, useServices as r, getGlobalService as s, client as t, useItems as u, getCorrectId as v, withSeed as w };
|
|
7600
|
-
//# sourceMappingURL=index-
|
|
7626
|
+
//# sourceMappingURL=index-Br7jo_vg.js.map
|