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