@seedprotocol/sdk 0.1.97 → 0.1.99

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.
@@ -20,7 +20,7 @@ import { useImmer } from 'use-immer';
20
20
  import { useSelector } from '@xstate/react';
21
21
  import EventEmitter from 'eventemitter3';
22
22
  import { immerable, produce, enableMapSet } from 'immer';
23
- import pluralize, { singular } from 'pluralize';
23
+ import pluralize from 'pluralize';
24
24
  import { createBrowserInspector } from '@statelyai/inspect';
25
25
  import { BehaviorSubject } from 'rxjs';
26
26
  import { drizzle } from 'drizzle-orm/sqlite-proxy';
@@ -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-BHJ84k-m.js');
1071
+ const { Item } = yield import('./index-Mt8WaytK.js');
1072
1072
  const item = yield Item.find({
1073
1073
  seedLocalId,
1074
1074
  modelName: itemModelName,
@@ -2622,7 +2622,7 @@ const addModelsToDb = fromCallback(({ sendBack, input: { context } }) => {
2622
2622
  if (!models$1) {
2623
2623
  return;
2624
2624
  }
2625
- const { models: SeedModels } = yield import('./seed.schema.config-DLj7z3au.js');
2625
+ const { models: SeedModels } = yield import('./seed.schema.config-Dffe0eOd.js');
2626
2626
  const allModels = Object.assign(Object.assign({}, SeedModels), models$1);
2627
2627
  let hasModelsInDb = false;
2628
2628
  const schemaDefsByModelName = new Map();
@@ -5787,7 +5787,7 @@ const getItem = (_a) => __awaiter(void 0, [_a], void 0, function* ({ modelName,
5787
5787
  return Item.create(itemInitObj);
5788
5788
  });
5789
5789
 
5790
- const getSchemaForItemProperty = (_a) => __awaiter(void 0, [_a], void 0, function* ({ schemaUid, propertyName, }) {
5790
+ const getSchemaForItemProperty = (_a) => __awaiter(void 0, [_a], void 0, function* ({ schemaUid, propertyName, easDataType, }) {
5791
5791
  let queryParams = {
5792
5792
  where: {
5793
5793
  id: {
@@ -5795,7 +5795,17 @@ const getSchemaForItemProperty = (_a) => __awaiter(void 0, [_a], void 0, functio
5795
5795
  },
5796
5796
  },
5797
5797
  };
5798
- if (!schemaUid || schemaUid === 'null' || schemaUid === 'undefined') {
5798
+ if (!schemaUid && easDataType) {
5799
+ queryParams = {
5800
+ where: {
5801
+ schema: {
5802
+ equals: `${easDataType} ${propertyName}`,
5803
+ },
5804
+ },
5805
+ };
5806
+ }
5807
+ if (!easDataType &&
5808
+ (!schemaUid || schemaUid === 'null' || schemaUid === 'undefined')) {
5799
5809
  queryParams = {
5800
5810
  where: {
5801
5811
  schemaNames: {
@@ -5834,13 +5844,14 @@ const getPublishPayload = (seedLocalId) => __awaiter(void 0, void 0, void 0, fun
5834
5844
  if (!itemProperty.value || !itemProperty.propertyDef) {
5835
5845
  continue;
5836
5846
  }
5847
+ const easDataType = INTERNAL_DATA_TYPES[itemProperty.propertyDef.dataType].eas;
5837
5848
  let propertyNameForSchema = propertyName;
5838
5849
  if (itemProperty.propertyDef.dataType === 'Relation') {
5839
5850
  propertyNameForSchema = `${propertyName}Id`;
5840
5851
  }
5841
5852
  if (itemProperty.propertyDef.dataType === 'List' &&
5842
5853
  itemProperty.propertyDef.ref) {
5843
- const singularPropertyName = singular(propertyName);
5854
+ const singularPropertyName = pluralize.singular(propertyName);
5844
5855
  const compositePropertyName = `${singularPropertyName}${itemProperty.propertyDef.ref}Ids`;
5845
5856
  propertyNameForSchema = compositePropertyName;
5846
5857
  }
@@ -5851,11 +5862,11 @@ const getPublishPayload = (seedLocalId) => __awaiter(void 0, void 0, void 0, fun
5851
5862
  const foundPropertySchema = yield getSchemaForItemProperty({
5852
5863
  schemaUid: itemProperty.schemaUid,
5853
5864
  propertyName: propertyNameForSchema,
5865
+ easDataType,
5854
5866
  });
5855
5867
  if (!foundPropertySchema) {
5856
5868
  throw new Error(`No schema found for property ${itemProperty.propertyName} ${itemProperty.localId}`);
5857
5869
  }
5858
- const easDataType = INTERNAL_DATA_TYPES[itemProperty.propertyDef.dataType].eas;
5859
5870
  const data = [
5860
5871
  {
5861
5872
  name: toSnakeCase(propertyNameForSchema),
@@ -6673,7 +6684,7 @@ const client = {
6673
6684
  console.error('fs listeners not ready during init');
6674
6685
  }
6675
6686
  globalService.send({ type: 'init', endpoints, models, addresses });
6676
- import('./seed.schema.config-DLj7z3au.js').then(({ models }) => {
6687
+ import('./seed.schema.config-Dffe0eOd.js').then(({ models }) => {
6677
6688
  for (const [key, value] of Object.entries(models)) {
6678
6689
  setModel(key, value);
6679
6690
  }
@@ -6933,7 +6944,15 @@ const analyzeInput = fromCallback(({ sendBack, input: { context, event } }) => {
6933
6944
  return false;
6934
6945
  }
6935
6946
  if (!schemaUid) {
6936
- const schemaFromEas = yield getSchemaForItemProperty({ propertyName });
6947
+ let easDataType;
6948
+ if (propertyRecordSchema.dataType) {
6949
+ easDataType = INTERNAL_DATA_TYPES[propertyRecordSchema.dataType]
6950
+ .eas;
6951
+ }
6952
+ const schemaFromEas = yield getSchemaForItemProperty({
6953
+ propertyName,
6954
+ easDataType,
6955
+ });
6937
6956
  if (schemaFromEas) {
6938
6957
  schemaUid = schemaFromEas.id;
6939
6958
  }
@@ -7618,4 +7637,4 @@ if (isNode()) {
7618
7637
  }
7619
7638
 
7620
7639
  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 };
7621
- //# sourceMappingURL=index-uwYqpfQT.js.map
7640
+ //# sourceMappingURL=index-BoPvASL1.js.map