@seedprotocol/sdk 0.1.90 → 0.1.92
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-4AsvJICt.js → index-BQ8Rxqfu.js} +2 -2
- package/dist/{index-4AsvJICt.js.map → index-BQ8Rxqfu.js.map} +1 -1
- package/dist/{index-C4VKEAXQ.js → index-BVJPyy1u.js} +64 -54
- package/dist/index-BVJPyy1u.js.map +1 -0
- package/dist/main.js +1 -1
- package/dist/{seed.schema.config-_TspGuXU.js → seed.schema.config-wUSjIpif.js} +2 -2
- package/dist/{seed.schema.config-_TspGuXU.js.map → seed.schema.config-wUSjIpif.js.map} +1 -1
- package/dist/src/analyzeInput.ts +12 -2
- package/dist/src/getPublishPayload.ts +9 -43
- package/dist/src/getSchemaForItemProperty.ts +48 -0
- package/dist/src/index.ts +4 -21
- package/dist/src/publishMachine.ts +1 -1
- package/dist/src/updateMachineContext.ts +21 -0
- package/dist/types/src/browser/db/read/getPublishPayload.d.ts.map +1 -1
- package/dist/types/src/browser/helpers/getSchemaForItemProperty.d.ts +9 -0
- package/dist/types/src/browser/helpers/getSchemaForItemProperty.d.ts.map +1 -0
- package/dist/types/src/browser/{helpers.d.ts → helpers/index.d.ts} +1 -6
- package/dist/types/src/browser/helpers/index.d.ts.map +1 -0
- package/dist/types/src/browser/helpers/updateMachineContext.d.ts +7 -0
- package/dist/types/src/browser/helpers/updateMachineContext.d.ts.map +1 -0
- package/dist/types/src/browser/property/actors/saveValueToDb/analyzeInput.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/index-C4VKEAXQ.js.map +0 -1
- package/dist/types/src/browser/helpers.d.ts.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-BVJPyy1u.js';
|
|
2
2
|
import './constants-rmQ8zg8_.js';
|
|
3
3
|
import '@ethereum-attestation-service/eas-sdk';
|
|
4
4
|
import 'thirdweb';
|
|
@@ -29,4 +29,4 @@ import 'rxjs';
|
|
|
29
29
|
import 'drizzle-orm/sqlite-proxy';
|
|
30
30
|
import '@zenfs/dom';
|
|
31
31
|
import 'arweave';
|
|
32
|
-
//# sourceMappingURL=index-
|
|
32
|
+
//# sourceMappingURL=index-BQ8Rxqfu.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index-
|
|
1
|
+
{"version":3,"file":"index-BQ8Rxqfu.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -2,7 +2,7 @@ import { b as __awaiter, d as __rest, i as internalPropertyNames, I as INTERNAL_
|
|
|
2
2
|
import path, { basename } from 'path';
|
|
3
3
|
import 'reflect-metadata';
|
|
4
4
|
import { Type } from '@sinclair/typebox';
|
|
5
|
-
import { fromCallback,
|
|
5
|
+
import { fromCallback, createActor, waitFor, setup, assign, raise } from 'xstate';
|
|
6
6
|
import { sql, relations, or, eq, and, max, count, isNotNull, isNull, gt, inArray, like, getTableColumns } from 'drizzle-orm';
|
|
7
7
|
import { fs, configureSingle } from '@zenfs/core';
|
|
8
8
|
import 'dayjs';
|
|
@@ -1068,7 +1068,7 @@ const hydrateFromDb = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
1068
1068
|
if (propertyRecordSchema &&
|
|
1069
1069
|
propertyRecordSchema.storageType &&
|
|
1070
1070
|
propertyRecordSchema.storageType === 'ItemStorage') {
|
|
1071
|
-
const { Item } = yield import('./index-
|
|
1071
|
+
const { Item } = yield import('./index-BQ8Rxqfu.js');
|
|
1072
1072
|
const item = yield Item.find({
|
|
1073
1073
|
seedLocalId,
|
|
1074
1074
|
modelName: itemModelName,
|
|
@@ -1341,19 +1341,6 @@ const getContentUrlFromPath = (path) => __awaiter(void 0, void 0, void 0, functi
|
|
|
1341
1341
|
const fileHandler = new File([fileContents], basename(path));
|
|
1342
1342
|
return URL.createObjectURL(fileHandler);
|
|
1343
1343
|
});
|
|
1344
|
-
const updateMachineContext = {
|
|
1345
|
-
actions: assign(({ context, event }) => {
|
|
1346
|
-
const newContext = Object.assign({}, context);
|
|
1347
|
-
for (let i = 0; i < Object.keys(event).length; i++) {
|
|
1348
|
-
const key = Object.keys(event)[i];
|
|
1349
|
-
if (key === 'type') {
|
|
1350
|
-
continue;
|
|
1351
|
-
}
|
|
1352
|
-
newContext[key] = event[key];
|
|
1353
|
-
}
|
|
1354
|
-
return Object.assign({}, newContext);
|
|
1355
|
-
}),
|
|
1356
|
-
};
|
|
1357
1344
|
|
|
1358
1345
|
const getSchemaUidForModel = (modelName) => __awaiter(void 0, void 0, void 0, function* () {
|
|
1359
1346
|
const modeType = modelName.toLowerCase();
|
|
@@ -2635,7 +2622,7 @@ const addModelsToDb = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
2635
2622
|
if (!models$1) {
|
|
2636
2623
|
return;
|
|
2637
2624
|
}
|
|
2638
|
-
const { models: SeedModels } = yield import('./seed.schema.config-
|
|
2625
|
+
const { models: SeedModels } = yield import('./seed.schema.config-wUSjIpif.js');
|
|
2639
2626
|
const allModels = Object.assign(Object.assign({}, SeedModels), models$1);
|
|
2640
2627
|
let hasModelsInDb = false;
|
|
2641
2628
|
const schemaDefsByModelName = new Map();
|
|
@@ -4817,6 +4804,20 @@ const createPublishAttempt = fromCallback(({ sendBack, input: { context } }) =>
|
|
|
4817
4804
|
});
|
|
4818
4805
|
});
|
|
4819
4806
|
|
|
4807
|
+
const updateMachineContext = {
|
|
4808
|
+
actions: assign(({ context, event }) => {
|
|
4809
|
+
const newContext = Object.assign({}, context);
|
|
4810
|
+
for (let i = 0; i < Object.keys(event).length; i++) {
|
|
4811
|
+
const key = Object.keys(event)[i];
|
|
4812
|
+
if (key === 'type') {
|
|
4813
|
+
continue;
|
|
4814
|
+
}
|
|
4815
|
+
newContext[key] = event[key];
|
|
4816
|
+
}
|
|
4817
|
+
return Object.assign({}, newContext);
|
|
4818
|
+
}),
|
|
4819
|
+
};
|
|
4820
|
+
|
|
4820
4821
|
const preparePublishRequestData = fromCallback(({ sendBack, input: { context } }) => {
|
|
4821
4822
|
const { localId } = context;
|
|
4822
4823
|
const _preparePublishRequestData = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -5786,6 +5787,37 @@ const getItem = (_a) => __awaiter(void 0, [_a], void 0, function* ({ modelName,
|
|
|
5786
5787
|
return Item.create(itemInitObj);
|
|
5787
5788
|
});
|
|
5788
5789
|
|
|
5790
|
+
const getSchemaForItemProperty = (_a) => __awaiter(void 0, [_a], void 0, function* ({ schemaUid, propertyName, }) {
|
|
5791
|
+
let queryParams = {
|
|
5792
|
+
where: {
|
|
5793
|
+
id: {
|
|
5794
|
+
equals: schemaUid,
|
|
5795
|
+
},
|
|
5796
|
+
},
|
|
5797
|
+
};
|
|
5798
|
+
if (!schemaUid || schemaUid === 'null' || schemaUid === 'undefined') {
|
|
5799
|
+
queryParams = {
|
|
5800
|
+
where: {
|
|
5801
|
+
schemaNames: {
|
|
5802
|
+
some: {
|
|
5803
|
+
name: {
|
|
5804
|
+
equals: toSnakeCase(propertyName),
|
|
5805
|
+
},
|
|
5806
|
+
},
|
|
5807
|
+
},
|
|
5808
|
+
},
|
|
5809
|
+
};
|
|
5810
|
+
}
|
|
5811
|
+
const foundPropertySchema = yield queryClient.fetchQuery({
|
|
5812
|
+
queryKey: [`getPropertySchema${propertyName}`],
|
|
5813
|
+
queryFn: () => __awaiter(void 0, void 0, void 0, function* () { return easClient.request(GET_SCHEMAS, queryParams); }),
|
|
5814
|
+
networkMode: 'offlineFirst',
|
|
5815
|
+
});
|
|
5816
|
+
if (foundPropertySchema && foundPropertySchema.schemas.length > 0) {
|
|
5817
|
+
return foundPropertySchema.schemas[0];
|
|
5818
|
+
}
|
|
5819
|
+
});
|
|
5820
|
+
|
|
5789
5821
|
const getPublishPayload = (seedLocalId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
5790
5822
|
const item = yield getItem({ seedLocalId });
|
|
5791
5823
|
if (!item) {
|
|
@@ -5799,47 +5831,18 @@ const getPublishPayload = (seedLocalId) => __awaiter(void 0, void 0, void 0, fun
|
|
|
5799
5831
|
const listOfAttestations = [];
|
|
5800
5832
|
const propertiesToUpdate = [];
|
|
5801
5833
|
for (const [propertyName, itemProperty] of Object.entries(item.properties)) {
|
|
5802
|
-
if (!itemProperty.value) {
|
|
5803
|
-
continue;
|
|
5804
|
-
}
|
|
5805
|
-
let queryParams = {
|
|
5806
|
-
where: {
|
|
5807
|
-
id: {
|
|
5808
|
-
equals: itemProperty.schemaUid,
|
|
5809
|
-
},
|
|
5810
|
-
},
|
|
5811
|
-
};
|
|
5812
|
-
if (!itemProperty.schemaUid) {
|
|
5813
|
-
queryParams = {
|
|
5814
|
-
where: {
|
|
5815
|
-
schemaNames: {
|
|
5816
|
-
some: {
|
|
5817
|
-
name: {
|
|
5818
|
-
equals: toSnakeCase(propertyName),
|
|
5819
|
-
},
|
|
5820
|
-
},
|
|
5821
|
-
},
|
|
5822
|
-
},
|
|
5823
|
-
};
|
|
5824
|
-
}
|
|
5825
|
-
const foundPropertySchema = yield queryClient.fetchQuery({
|
|
5826
|
-
queryKey: [`getPropertySchema${propertyName}`],
|
|
5827
|
-
queryFn: () => __awaiter(void 0, void 0, void 0, function* () { return easClient.request(GET_SCHEMAS, queryParams); }),
|
|
5828
|
-
});
|
|
5829
|
-
if (!foundPropertySchema ||
|
|
5830
|
-
!foundPropertySchema.schemas ||
|
|
5831
|
-
foundPropertySchema.schemas.length === 0) {
|
|
5832
|
-
console.error(`Property schema not found for ${propertyName}`);
|
|
5834
|
+
if (!itemProperty.value || !itemProperty.propertyDef) {
|
|
5833
5835
|
continue;
|
|
5834
5836
|
}
|
|
5835
|
-
|
|
5836
|
-
|
|
5837
|
+
const foundPropertySchema = yield getSchemaForItemProperty(itemProperty);
|
|
5838
|
+
if (!foundPropertySchema) {
|
|
5839
|
+
throw new Error(`No schema found for property ${itemProperty.propertyName} ${itemProperty.localId}`);
|
|
5837
5840
|
}
|
|
5838
5841
|
const easDataType = INTERNAL_DATA_TYPES[itemProperty.propertyDef.dataType].eas;
|
|
5839
5842
|
const data = [
|
|
5840
5843
|
{ name: propertyName, type: easDataType, value: itemProperty.value },
|
|
5841
5844
|
];
|
|
5842
|
-
const easSchemaDefinition = foundPropertySchema.
|
|
5845
|
+
const easSchemaDefinition = foundPropertySchema.schema;
|
|
5843
5846
|
const dataEncoder = new SchemaEncoder(easSchemaDefinition);
|
|
5844
5847
|
const encodedData = dataEncoder.encodeData(data);
|
|
5845
5848
|
listOfAttestations.push({
|
|
@@ -6649,7 +6652,7 @@ const client = {
|
|
|
6649
6652
|
console.error('fs listeners not ready during init');
|
|
6650
6653
|
}
|
|
6651
6654
|
globalService.send({ type: 'init', endpoints, models, addresses });
|
|
6652
|
-
import('./seed.schema.config-
|
|
6655
|
+
import('./seed.schema.config-wUSjIpif.js').then(({ models }) => {
|
|
6653
6656
|
for (const [key, value] of Object.entries(models)) {
|
|
6654
6657
|
setModel(key, value);
|
|
6655
6658
|
}
|
|
@@ -6868,7 +6871,8 @@ const updateItemPropertyValue = (_a) => __awaiter(void 0, [_a], void 0, function
|
|
|
6868
6871
|
});
|
|
6869
6872
|
|
|
6870
6873
|
const analyzeInput = fromCallback(({ sendBack, input: { context, event } }) => {
|
|
6871
|
-
const { localId, propertyName: propertyNameRaw, seedLocalId, versionLocalId, versionUid, propertyValue: existingValue, propertyRecordSchema, itemModelName,
|
|
6874
|
+
const { localId, propertyName: propertyNameRaw, seedLocalId, versionLocalId, versionUid, propertyValue: existingValue, propertyRecordSchema, itemModelName, } = context;
|
|
6875
|
+
let { schemaUid } = context;
|
|
6872
6876
|
let newValue;
|
|
6873
6877
|
if (event) {
|
|
6874
6878
|
newValue = event.newValue;
|
|
@@ -6907,8 +6911,14 @@ const analyzeInput = fromCallback(({ sendBack, input: { context, event } }) => {
|
|
|
6907
6911
|
});
|
|
6908
6912
|
return false;
|
|
6909
6913
|
}
|
|
6914
|
+
if (!schemaUid) {
|
|
6915
|
+
const schemaFromEas = yield getSchemaForItemProperty({ propertyName });
|
|
6916
|
+
if (schemaFromEas) {
|
|
6917
|
+
schemaUid = schemaFromEas.id;
|
|
6918
|
+
}
|
|
6919
|
+
}
|
|
6910
6920
|
yield updateItemPropertyValue({
|
|
6911
|
-
localId
|
|
6921
|
+
localId,
|
|
6912
6922
|
propertyName,
|
|
6913
6923
|
newValue,
|
|
6914
6924
|
seedLocalId,
|
|
@@ -7587,4 +7597,4 @@ if (isNode()) {
|
|
|
7587
7597
|
}
|
|
7588
7598
|
|
|
7589
7599
|
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 };
|
|
7590
|
-
//# sourceMappingURL=index-
|
|
7600
|
+
//# sourceMappingURL=index-BVJPyy1u.js.map
|