@workglow/storage 0.0.100 → 0.0.102

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/browser.js CHANGED
@@ -189,11 +189,12 @@ class BaseTabularStorage {
189
189
  const valueNames = this.valueColumns();
190
190
  const value = {};
191
191
  const key = {};
192
+ const objRecord = obj;
192
193
  for (const k of primaryKeyNames) {
193
- key[k] = obj[k];
194
+ key[k] = objRecord[k];
194
195
  }
195
196
  for (const k of valueNames) {
196
- value[k] = obj[k];
197
+ value[k] = objRecord[k];
197
198
  }
198
199
  return { value, key };
199
200
  }
@@ -2761,17 +2762,16 @@ class BaseSqlTabularStorage extends BaseTabularStorage {
2761
2762
  return value;
2762
2763
  }
2763
2764
  if (actualType.contentEncoding === "blob") {
2764
- const v = value;
2765
- if (v instanceof Uint8Array) {
2766
- return v;
2765
+ if (value instanceof Uint8Array) {
2766
+ return value;
2767
2767
  }
2768
- if (typeof Buffer !== "undefined" && v instanceof Buffer) {
2769
- return new Uint8Array(v);
2768
+ if (typeof Buffer !== "undefined" && value instanceof Buffer) {
2769
+ return new Uint8Array(value);
2770
2770
  }
2771
- if (Array.isArray(v)) {
2772
- return new Uint8Array(v);
2771
+ if (Array.isArray(value)) {
2772
+ return new Uint8Array(value);
2773
2773
  }
2774
- return v;
2774
+ return value;
2775
2775
  } else if (value instanceof Date) {
2776
2776
  return value.toISOString();
2777
2777
  } else {
@@ -2791,14 +2791,13 @@ class BaseSqlTabularStorage extends BaseTabularStorage {
2791
2791
  return value;
2792
2792
  }
2793
2793
  if (actualType.contentEncoding === "blob") {
2794
- const v = value;
2795
- if (typeof Buffer !== "undefined" && v instanceof Buffer) {
2796
- return new Uint8Array(v);
2794
+ if (typeof Buffer !== "undefined" && value instanceof Buffer) {
2795
+ return new Uint8Array(value);
2797
2796
  }
2798
- if (v instanceof Uint8Array) {
2799
- return v;
2797
+ if (value instanceof Uint8Array) {
2798
+ return value;
2800
2799
  }
2801
- return v;
2800
+ return value;
2802
2801
  } else {
2803
2802
  return value;
2804
2803
  }
@@ -3006,11 +3005,10 @@ class SupabaseTabularStorage extends BaseSqlTabularStorage {
3006
3005
  }
3007
3006
  const actualType = this.getNonNullType(typeDef);
3008
3007
  if (typeof actualType !== "boolean" && (actualType.type === "number" || actualType.type === "integer")) {
3009
- const v = value;
3010
- if (typeof v === "number")
3011
- return v;
3012
- if (typeof v === "string") {
3013
- const parsed = Number(v);
3008
+ if (typeof value === "number")
3009
+ return value;
3010
+ if (typeof value === "string") {
3011
+ const parsed = Number(value);
3014
3012
  if (!isNaN(parsed))
3015
3013
  return parsed;
3016
3014
  }
@@ -3032,7 +3030,8 @@ class SupabaseTabularStorage extends BaseSqlTabularStorage {
3032
3030
  let entityToInsert = { ...entity };
3033
3031
  if (this.hasAutoGeneratedKey() && this.autoGeneratedKeyName) {
3034
3032
  const keyName = String(this.autoGeneratedKeyName);
3035
- const clientProvidedValue = entity[keyName];
3033
+ const entityRecord = entity;
3034
+ const clientProvidedValue = entityRecord[keyName];
3036
3035
  const hasClientValue = clientProvidedValue !== undefined && clientProvidedValue !== null;
3037
3036
  let shouldOmitKey = false;
3038
3037
  if (this.clientProvidedKeys === "never") {
@@ -3062,8 +3061,9 @@ class SupabaseTabularStorage extends BaseSqlTabularStorage {
3062
3061
  if (error)
3063
3062
  throw error;
3064
3063
  const updatedEntity = data;
3064
+ const updatedRecord = updatedEntity;
3065
3065
  for (const key in this.schema.properties) {
3066
- updatedEntity[key] = this.sqlToJsValue(key, updatedEntity[key]);
3066
+ updatedRecord[key] = this.sqlToJsValue(key, updatedRecord[key]);
3067
3067
  }
3068
3068
  this.events.emit("put", updatedEntity);
3069
3069
  return updatedEntity;
@@ -3075,8 +3075,9 @@ class SupabaseTabularStorage extends BaseSqlTabularStorage {
3075
3075
  }
3076
3076
  async get(key) {
3077
3077
  let query = this.client.from(this.table).select("*");
3078
+ const keyRecord = key;
3078
3079
  for (const pkName of this.primaryKeyNames) {
3079
- query = query.eq(String(pkName), key[pkName]);
3080
+ query = query.eq(String(pkName), keyRecord[String(pkName)]);
3080
3081
  }
3081
3082
  const { data, error } = await query.single();
3082
3083
  if (error) {
@@ -3088,8 +3089,9 @@ class SupabaseTabularStorage extends BaseSqlTabularStorage {
3088
3089
  }
3089
3090
  const val = data;
3090
3091
  if (val) {
3092
+ const valRecord = val;
3091
3093
  for (const key2 in this.schema.properties) {
3092
- val[key2] = this.sqlToJsValue(key2, val[key2]);
3094
+ valRecord[key2] = this.sqlToJsValue(key2, valRecord[key2]);
3093
3095
  }
3094
3096
  }
3095
3097
  this.events.emit("get", key, val);
@@ -3118,8 +3120,9 @@ class SupabaseTabularStorage extends BaseSqlTabularStorage {
3118
3120
  throw error;
3119
3121
  if (data && data.length > 0) {
3120
3122
  for (const row of data) {
3123
+ const record = row;
3121
3124
  for (const key in this.schema.properties) {
3122
- row[key] = this.sqlToJsValue(key, row[key]);
3125
+ record[key] = this.sqlToJsValue(key, record[key]);
3123
3126
  }
3124
3127
  }
3125
3128
  this.events.emit("search", searchCriteria, data);
@@ -3132,8 +3135,9 @@ class SupabaseTabularStorage extends BaseSqlTabularStorage {
3132
3135
  async delete(value) {
3133
3136
  const { key } = this.separateKeyValueFromCombined(value);
3134
3137
  let query = this.client.from(this.table).delete();
3138
+ const deleteKeyRecord = key;
3135
3139
  for (const pkName of this.primaryKeyNames) {
3136
- query = query.eq(String(pkName), key[pkName]);
3140
+ query = query.eq(String(pkName), deleteKeyRecord[String(pkName)]);
3137
3141
  }
3138
3142
  const { error } = await query;
3139
3143
  if (error)
@@ -3146,8 +3150,9 @@ class SupabaseTabularStorage extends BaseSqlTabularStorage {
3146
3150
  throw error;
3147
3151
  if (data && data.length) {
3148
3152
  for (const row of data) {
3153
+ const record = row;
3149
3154
  for (const key in this.schema.properties) {
3150
- row[key] = this.sqlToJsValue(key, row[key]);
3155
+ record[key] = this.sqlToJsValue(key, record[key]);
3151
3156
  }
3152
3157
  }
3153
3158
  return data;
@@ -3179,8 +3184,9 @@ class SupabaseTabularStorage extends BaseSqlTabularStorage {
3179
3184
  return;
3180
3185
  }
3181
3186
  for (const row of data) {
3187
+ const record = row;
3182
3188
  for (const key in this.schema.properties) {
3183
- row[key] = this.sqlToJsValue(key, row[key]);
3189
+ record[key] = this.sqlToJsValue(key, record[key]);
3184
3190
  }
3185
3191
  }
3186
3192
  return data;
@@ -3229,8 +3235,9 @@ class SupabaseTabularStorage extends BaseSqlTabularStorage {
3229
3235
  }
3230
3236
  convertRealtimeRow(row) {
3231
3237
  const entity = { ...row };
3238
+ const record = entity;
3232
3239
  for (const key in this.schema.properties) {
3233
- entity[key] = this.sqlToJsValue(key, row[key]);
3240
+ record[key] = this.sqlToJsValue(key, row[key]);
3234
3241
  }
3235
3242
  return entity;
3236
3243
  }
@@ -4788,4 +4795,4 @@ export {
4788
4795
  BaseTabularStorage
4789
4796
  };
4790
4797
 
4791
- //# debugId=7DE4087156DCB1A264756E2164756E21
4798
+ //# debugId=B7E554C36B7CCFEF64756E2164756E21