@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.
@@ -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-C4VKEAXQ.js';
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-4AsvJICt.js.map
32
+ //# sourceMappingURL=index-BQ8Rxqfu.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index-4AsvJICt.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
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, assign, createActor, waitFor, setup, raise } from 'xstate';
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-4AsvJICt.js');
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-_TspGuXU.js');
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
- if (!itemProperty.propertyDef) {
5836
- continue;
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.schemas[0].schema;
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-_TspGuXU.js').then(({ models }) => {
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, schemaUid, } = context;
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: 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-C4VKEAXQ.js.map
7600
+ //# sourceMappingURL=index-BVJPyy1u.js.map