@workglow/storage 0.0.101 → 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/node.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
  }
@@ -2002,17 +2003,16 @@ class BaseSqlTabularStorage extends BaseTabularStorage {
2002
2003
  return value;
2003
2004
  }
2004
2005
  if (actualType.contentEncoding === "blob") {
2005
- const v = value;
2006
- if (v instanceof Uint8Array) {
2007
- return v;
2006
+ if (value instanceof Uint8Array) {
2007
+ return value;
2008
2008
  }
2009
- if (typeof Buffer !== "undefined" && v instanceof Buffer) {
2010
- return new Uint8Array(v);
2009
+ if (typeof Buffer !== "undefined" && value instanceof Buffer) {
2010
+ return new Uint8Array(value);
2011
2011
  }
2012
- if (Array.isArray(v)) {
2013
- return new Uint8Array(v);
2012
+ if (Array.isArray(value)) {
2013
+ return new Uint8Array(value);
2014
2014
  }
2015
- return v;
2015
+ return value;
2016
2016
  } else if (value instanceof Date) {
2017
2017
  return value.toISOString();
2018
2018
  } else {
@@ -2032,14 +2032,13 @@ class BaseSqlTabularStorage extends BaseTabularStorage {
2032
2032
  return value;
2033
2033
  }
2034
2034
  if (actualType.contentEncoding === "blob") {
2035
- const v = value;
2036
- if (typeof Buffer !== "undefined" && v instanceof Buffer) {
2037
- return new Uint8Array(v);
2035
+ if (typeof Buffer !== "undefined" && value instanceof Buffer) {
2036
+ return new Uint8Array(value);
2038
2037
  }
2039
- if (v instanceof Uint8Array) {
2040
- return v;
2038
+ if (value instanceof Uint8Array) {
2039
+ return value;
2041
2040
  }
2042
- return v;
2041
+ return value;
2043
2042
  } else {
2044
2043
  return value;
2045
2044
  }
@@ -2282,11 +2281,10 @@ class PostgresTabularStorage extends BaseSqlTabularStorage {
2282
2281
  }
2283
2282
  }
2284
2283
  if (typeof actualType !== "boolean" && (actualType.type === "number" || actualType.type === "integer")) {
2285
- const v = value;
2286
- if (typeof v === "number")
2287
- return v;
2288
- if (typeof v === "string") {
2289
- const parsed = Number(v);
2284
+ if (typeof value === "number")
2285
+ return value;
2286
+ if (typeof value === "string") {
2287
+ const parsed = Number(value);
2290
2288
  if (!isNaN(parsed))
2291
2289
  return parsed;
2292
2290
  }
@@ -2349,10 +2347,11 @@ class PostgresTabularStorage extends BaseSqlTabularStorage {
2349
2347
  const paramsToInsert = [];
2350
2348
  let paramIndex = 1;
2351
2349
  const pkColumns = this.primaryKeyColumns();
2350
+ const entityRecord = entity;
2352
2351
  for (const col of pkColumns) {
2353
2352
  const colStr = String(col);
2354
2353
  if (this.isAutoGeneratedKey(colStr)) {
2355
- const clientProvidedValue = entity[col];
2354
+ const clientProvidedValue = entityRecord[colStr];
2356
2355
  const hasClientValue = clientProvidedValue !== undefined && clientProvidedValue !== null;
2357
2356
  let shouldUseClientValue = false;
2358
2357
  if (this.clientProvidedKeys === "never") {
@@ -2372,14 +2371,14 @@ class PostgresTabularStorage extends BaseSqlTabularStorage {
2372
2371
  continue;
2373
2372
  }
2374
2373
  columnsToInsert.push(colStr);
2375
- const value = entity[col];
2374
+ const value = entityRecord[colStr];
2376
2375
  paramsToInsert.push(this.jsToSqlValue(colStr, value));
2377
2376
  }
2378
2377
  const valueColumns = this.valueColumns();
2379
2378
  for (const col of valueColumns) {
2380
2379
  const colStr = String(col);
2381
2380
  columnsToInsert.push(colStr);
2382
- const value = entity[col];
2381
+ const value = entityRecord[colStr];
2383
2382
  paramsToInsert.push(this.jsToSqlValue(colStr, value));
2384
2383
  }
2385
2384
  const columnList = columnsToInsert.map((c) => `"${c}"`).join(", ");
@@ -2401,8 +2400,9 @@ class PostgresTabularStorage extends BaseSqlTabularStorage {
2401
2400
  const params = paramsToInsert;
2402
2401
  const result = await db.query(sql, params);
2403
2402
  const updatedEntity = result.rows[0];
2403
+ const updatedRecord = updatedEntity;
2404
2404
  for (const key in this.schema.properties) {
2405
- updatedEntity[key] = this.sqlToJsValue(key, updatedEntity[key]);
2405
+ updatedRecord[key] = this.sqlToJsValue(key, updatedRecord[key]);
2406
2406
  }
2407
2407
  this.events.emit("put", updatedEntity);
2408
2408
  return updatedEntity;
@@ -2421,8 +2421,9 @@ class PostgresTabularStorage extends BaseSqlTabularStorage {
2421
2421
  let val;
2422
2422
  if (result.rows.length > 0) {
2423
2423
  val = result.rows[0];
2424
+ const valRecord = val;
2424
2425
  for (const key2 in this.schema.properties) {
2425
- val[key2] = this.sqlToJsValue(key2, val[key2]);
2426
+ valRecord[key2] = this.sqlToJsValue(key2, valRecord[key2]);
2426
2427
  }
2427
2428
  } else {
2428
2429
  val = undefined;
@@ -2451,8 +2452,9 @@ class PostgresTabularStorage extends BaseSqlTabularStorage {
2451
2452
  const result = await db.query(sql, whereClauseValues);
2452
2453
  if (result.rows.length > 0) {
2453
2454
  for (const row of result.rows) {
2455
+ const record = row;
2454
2456
  for (const k in this.schema.properties) {
2455
- row[k] = this.sqlToJsValue(k, row[k]);
2457
+ record[k] = this.sqlToJsValue(k, record[k]);
2456
2458
  }
2457
2459
  }
2458
2460
  this.events.emit("search", key, result.rows);
@@ -2476,8 +2478,9 @@ class PostgresTabularStorage extends BaseSqlTabularStorage {
2476
2478
  const result = await db.query(sql);
2477
2479
  if (result.rows.length > 0) {
2478
2480
  for (const row of result.rows) {
2481
+ const record = row;
2479
2482
  for (const key in this.schema.properties) {
2480
- row[key] = this.sqlToJsValue(key, row[key]);
2483
+ record[key] = this.sqlToJsValue(key, record[key]);
2481
2484
  }
2482
2485
  }
2483
2486
  return result.rows;
@@ -2502,8 +2505,9 @@ class PostgresTabularStorage extends BaseSqlTabularStorage {
2502
2505
  return;
2503
2506
  }
2504
2507
  for (const row of result.rows) {
2508
+ const record = row;
2505
2509
  for (const key in this.schema.properties) {
2506
- row[key] = this.sqlToJsValue(key, row[key]);
2510
+ record[key] = this.sqlToJsValue(key, record[key]);
2507
2511
  }
2508
2512
  }
2509
2513
  return result.rows;
@@ -2643,13 +2647,12 @@ class SqliteTabularStorage extends BaseSqlTabularStorage {
2643
2647
  const isArray = typeDef === true || typeof actualType !== "boolean" && actualType.type === "array";
2644
2648
  const isBoolean = typeDef === true || typeof actualType !== "boolean" && actualType.type === "boolean";
2645
2649
  if (isBoolean) {
2646
- const v = value;
2647
- if (typeof v === "boolean")
2648
- return v ? 1 : 0;
2649
- if (typeof v === "number")
2650
- return v ? 1 : 0;
2651
- if (typeof v === "string")
2652
- return v === "1" || v.toLowerCase() === "true" ? 1 : 0;
2650
+ if (typeof value === "boolean")
2651
+ return value ? 1 : 0;
2652
+ if (typeof value === "number")
2653
+ return value ? 1 : 0;
2654
+ if (typeof value === "string")
2655
+ return value === "1" || value.toLowerCase() === "true" ? 1 : 0;
2653
2656
  }
2654
2657
  if ((isObject || isArray) && value !== null && typeof value === "object") {
2655
2658
  if (!(value instanceof Date) && !(value instanceof Uint8Array) && (typeof Buffer === "undefined" || !(value instanceof Buffer))) {
@@ -2679,13 +2682,12 @@ class SqliteTabularStorage extends BaseSqlTabularStorage {
2679
2682
  const isArray = typeDef === true || typeof actualType !== "boolean" && actualType.type === "array";
2680
2683
  const isBoolean = typeDef === true || typeof actualType !== "boolean" && actualType.type === "boolean";
2681
2684
  if (isBoolean) {
2682
- const v = value;
2683
- if (typeof v === "boolean")
2684
- return v;
2685
- if (typeof v === "number")
2686
- return v !== 0 ? true : false;
2687
- if (typeof v === "string")
2688
- return v === "1" || v.toLowerCase() === "true" ? true : false;
2685
+ if (typeof value === "boolean")
2686
+ return value;
2687
+ if (typeof value === "number")
2688
+ return value !== 0 ? true : false;
2689
+ if (typeof value === "string")
2690
+ return value === "1" || value.toLowerCase() === "true" ? true : false;
2689
2691
  }
2690
2692
  if (isArray || isObject) {
2691
2693
  if (typeof value === "string") {
@@ -2743,7 +2745,8 @@ class SqliteTabularStorage extends BaseSqlTabularStorage {
2743
2745
  let entityToInsert = entity;
2744
2746
  if (this.hasAutoGeneratedKey() && this.autoGeneratedKeyName) {
2745
2747
  const keyName = String(this.autoGeneratedKeyName);
2746
- const clientProvidedValue = entity[keyName];
2748
+ const entityRecord = entity;
2749
+ const clientProvidedValue = entityRecord[keyName];
2747
2750
  const hasClientValue = clientProvidedValue !== undefined && clientProvidedValue !== null;
2748
2751
  let shouldUseClientValue = false;
2749
2752
  if (this.clientProvidedKeys === "never") {
@@ -2769,7 +2772,8 @@ class SqliteTabularStorage extends BaseSqlTabularStorage {
2769
2772
  for (const col of pkColumns) {
2770
2773
  const colStr = String(col);
2771
2774
  if (this.isAutoGeneratedKey(colStr) && this.autoGeneratedKeyStrategy === "autoincrement" && this.clientProvidedKeys !== "always") {
2772
- const clientProvidedValue = entityToInsert[colStr];
2775
+ const insertRecord2 = entityToInsert;
2776
+ const clientProvidedValue = insertRecord2[colStr];
2773
2777
  const hasClientValue = clientProvidedValue !== undefined && clientProvidedValue !== null;
2774
2778
  if (this.clientProvidedKeys === "if-missing" && hasClientValue) {
2775
2779
  columnsToInsert.push(colStr);
@@ -2782,10 +2786,11 @@ class SqliteTabularStorage extends BaseSqlTabularStorage {
2782
2786
  paramsToInsert.push(this.jsToSqlValue(colStr, value));
2783
2787
  }
2784
2788
  const valueColumns = this.valueColumns();
2789
+ const insertRecord = entityToInsert;
2785
2790
  for (const col of valueColumns) {
2786
2791
  const colStr = String(col);
2787
2792
  columnsToInsert.push(colStr);
2788
- const value = entityToInsert[colStr];
2793
+ const value = insertRecord[colStr];
2789
2794
  paramsToInsert.push(this.jsToSqlValue(colStr, value));
2790
2795
  }
2791
2796
  const columnList = columnsToInsert.map((c) => `\`${c}\``).join(", ");
@@ -2842,8 +2847,9 @@ class SqliteTabularStorage extends BaseSqlTabularStorage {
2842
2847
  throw new Error(`Invalid SQLite params detected at indices: ${invalidParams.map((p) => p.index).join(", ")}`);
2843
2848
  }
2844
2849
  const updatedEntity = stmt.get(...params);
2850
+ const updatedRecord = updatedEntity;
2845
2851
  for (const k in this.schema.properties) {
2846
- updatedEntity[k] = this.sqlToJsValue(k, updatedEntity[k]);
2852
+ updatedRecord[k] = this.sqlToJsValue(k, updatedRecord[k]);
2847
2853
  }
2848
2854
  this.events.emit("put", updatedEntity);
2849
2855
  return updatedEntity;
@@ -2863,8 +2869,9 @@ class SqliteTabularStorage extends BaseSqlTabularStorage {
2863
2869
  const params = this.getPrimaryKeyAsOrderedArray(key);
2864
2870
  const value = stmt.get(...params);
2865
2871
  if (value) {
2872
+ const row = value;
2866
2873
  for (const k in this.schema.properties) {
2867
- value[k] = this.sqlToJsValue(k, value[k]);
2874
+ row[k] = this.sqlToJsValue(k, row[k]);
2868
2875
  }
2869
2876
  this.events.emit("get", key, value);
2870
2877
  return value;
@@ -2895,8 +2902,9 @@ class SqliteTabularStorage extends BaseSqlTabularStorage {
2895
2902
  const result = stmt.all(...whereClauseValues);
2896
2903
  if (result.length > 0) {
2897
2904
  for (const row of result) {
2905
+ const record = row;
2898
2906
  for (const k in this.schema.properties) {
2899
- row[k] = this.sqlToJsValue(k, row[k]);
2907
+ record[k] = this.sqlToJsValue(k, record[k]);
2900
2908
  }
2901
2909
  }
2902
2910
  this.events.emit("search", key, result);
@@ -2922,8 +2930,9 @@ class SqliteTabularStorage extends BaseSqlTabularStorage {
2922
2930
  if (!value.length)
2923
2931
  return;
2924
2932
  for (const row of value) {
2933
+ const record = row;
2925
2934
  for (const k in this.schema.properties) {
2926
- row[k] = this.sqlToJsValue(k, row[k]);
2935
+ record[k] = this.sqlToJsValue(k, record[k]);
2927
2936
  }
2928
2937
  }
2929
2938
  return value;
@@ -2951,8 +2960,9 @@ class SqliteTabularStorage extends BaseSqlTabularStorage {
2951
2960
  return;
2952
2961
  }
2953
2962
  for (const row of rows) {
2963
+ const record = row;
2954
2964
  for (const k in this.schema.properties) {
2955
- row[k] = this.sqlToJsValue(k, row[k]);
2965
+ record[k] = this.sqlToJsValue(k, record[k]);
2956
2966
  }
2957
2967
  }
2958
2968
  return rows;
@@ -3183,11 +3193,10 @@ class SupabaseTabularStorage extends BaseSqlTabularStorage {
3183
3193
  }
3184
3194
  const actualType = this.getNonNullType(typeDef);
3185
3195
  if (typeof actualType !== "boolean" && (actualType.type === "number" || actualType.type === "integer")) {
3186
- const v = value;
3187
- if (typeof v === "number")
3188
- return v;
3189
- if (typeof v === "string") {
3190
- const parsed = Number(v);
3196
+ if (typeof value === "number")
3197
+ return value;
3198
+ if (typeof value === "string") {
3199
+ const parsed = Number(value);
3191
3200
  if (!isNaN(parsed))
3192
3201
  return parsed;
3193
3202
  }
@@ -3209,7 +3218,8 @@ class SupabaseTabularStorage extends BaseSqlTabularStorage {
3209
3218
  let entityToInsert = { ...entity };
3210
3219
  if (this.hasAutoGeneratedKey() && this.autoGeneratedKeyName) {
3211
3220
  const keyName = String(this.autoGeneratedKeyName);
3212
- const clientProvidedValue = entity[keyName];
3221
+ const entityRecord = entity;
3222
+ const clientProvidedValue = entityRecord[keyName];
3213
3223
  const hasClientValue = clientProvidedValue !== undefined && clientProvidedValue !== null;
3214
3224
  let shouldOmitKey = false;
3215
3225
  if (this.clientProvidedKeys === "never") {
@@ -3239,8 +3249,9 @@ class SupabaseTabularStorage extends BaseSqlTabularStorage {
3239
3249
  if (error)
3240
3250
  throw error;
3241
3251
  const updatedEntity = data;
3252
+ const updatedRecord = updatedEntity;
3242
3253
  for (const key in this.schema.properties) {
3243
- updatedEntity[key] = this.sqlToJsValue(key, updatedEntity[key]);
3254
+ updatedRecord[key] = this.sqlToJsValue(key, updatedRecord[key]);
3244
3255
  }
3245
3256
  this.events.emit("put", updatedEntity);
3246
3257
  return updatedEntity;
@@ -3252,8 +3263,9 @@ class SupabaseTabularStorage extends BaseSqlTabularStorage {
3252
3263
  }
3253
3264
  async get(key) {
3254
3265
  let query = this.client.from(this.table).select("*");
3266
+ const keyRecord = key;
3255
3267
  for (const pkName of this.primaryKeyNames) {
3256
- query = query.eq(String(pkName), key[pkName]);
3268
+ query = query.eq(String(pkName), keyRecord[String(pkName)]);
3257
3269
  }
3258
3270
  const { data, error } = await query.single();
3259
3271
  if (error) {
@@ -3265,8 +3277,9 @@ class SupabaseTabularStorage extends BaseSqlTabularStorage {
3265
3277
  }
3266
3278
  const val = data;
3267
3279
  if (val) {
3280
+ const valRecord = val;
3268
3281
  for (const key2 in this.schema.properties) {
3269
- val[key2] = this.sqlToJsValue(key2, val[key2]);
3282
+ valRecord[key2] = this.sqlToJsValue(key2, valRecord[key2]);
3270
3283
  }
3271
3284
  }
3272
3285
  this.events.emit("get", key, val);
@@ -3295,8 +3308,9 @@ class SupabaseTabularStorage extends BaseSqlTabularStorage {
3295
3308
  throw error;
3296
3309
  if (data && data.length > 0) {
3297
3310
  for (const row of data) {
3311
+ const record = row;
3298
3312
  for (const key in this.schema.properties) {
3299
- row[key] = this.sqlToJsValue(key, row[key]);
3313
+ record[key] = this.sqlToJsValue(key, record[key]);
3300
3314
  }
3301
3315
  }
3302
3316
  this.events.emit("search", searchCriteria, data);
@@ -3309,8 +3323,9 @@ class SupabaseTabularStorage extends BaseSqlTabularStorage {
3309
3323
  async delete(value) {
3310
3324
  const { key } = this.separateKeyValueFromCombined(value);
3311
3325
  let query = this.client.from(this.table).delete();
3326
+ const deleteKeyRecord = key;
3312
3327
  for (const pkName of this.primaryKeyNames) {
3313
- query = query.eq(String(pkName), key[pkName]);
3328
+ query = query.eq(String(pkName), deleteKeyRecord[String(pkName)]);
3314
3329
  }
3315
3330
  const { error } = await query;
3316
3331
  if (error)
@@ -3323,8 +3338,9 @@ class SupabaseTabularStorage extends BaseSqlTabularStorage {
3323
3338
  throw error;
3324
3339
  if (data && data.length) {
3325
3340
  for (const row of data) {
3341
+ const record = row;
3326
3342
  for (const key in this.schema.properties) {
3327
- row[key] = this.sqlToJsValue(key, row[key]);
3343
+ record[key] = this.sqlToJsValue(key, record[key]);
3328
3344
  }
3329
3345
  }
3330
3346
  return data;
@@ -3356,8 +3372,9 @@ class SupabaseTabularStorage extends BaseSqlTabularStorage {
3356
3372
  return;
3357
3373
  }
3358
3374
  for (const row of data) {
3375
+ const record = row;
3359
3376
  for (const key in this.schema.properties) {
3360
- row[key] = this.sqlToJsValue(key, row[key]);
3377
+ record[key] = this.sqlToJsValue(key, record[key]);
3361
3378
  }
3362
3379
  }
3363
3380
  return data;
@@ -3406,8 +3423,9 @@ class SupabaseTabularStorage extends BaseSqlTabularStorage {
3406
3423
  }
3407
3424
  convertRealtimeRow(row) {
3408
3425
  const entity = { ...row };
3426
+ const record = entity;
3409
3427
  for (const key in this.schema.properties) {
3410
- entity[key] = this.sqlToJsValue(key, row[key]);
3428
+ record[key] = this.sqlToJsValue(key, row[key]);
3411
3429
  }
3412
3430
  return entity;
3413
3431
  }
@@ -7147,4 +7165,4 @@ export {
7147
7165
  BaseTabularStorage
7148
7166
  };
7149
7167
 
7150
- //# debugId=C74BA1BBB43EDF7664756E2164756E21
7168
+ //# debugId=8A11082CCBBE123F64756E2164756E21