@0xobelisk/graphql-client 1.2.0-pre.71 → 1.2.0-pre.73

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/client.d.ts CHANGED
@@ -55,7 +55,7 @@ export declare class DubheGraphqlClient {
55
55
  /**
56
56
  * Subscribe to table data changes - Using PostGraphile's listen subscription feature
57
57
  */
58
- subscribeToTableChanges<T extends StoreTableRow>(tableName: string, options?: SubscriptionOptions & {
58
+ subscribeToTableChanges<_T extends StoreTableRow>(tableName: string, options?: SubscriptionOptions & {
59
59
  fields?: string[];
60
60
  initialEvent?: boolean;
61
61
  first?: number;
@@ -95,7 +95,7 @@ export declare class DubheGraphqlClient {
95
95
  /**
96
96
  * Build dynamic query - Adapted to API without store prefix
97
97
  */
98
- buildQuery(tableName: string, fields: string[], params?: {
98
+ buildQuery(tableName: string, fields: string[], _params?: {
99
99
  filter?: Record<string, any>;
100
100
  orderBy?: OrderBy[];
101
101
  first?: number;
@@ -104,7 +104,7 @@ export declare class DubheGraphqlClient {
104
104
  /**
105
105
  * Batch query multiple tables - Adapted to API without store prefix
106
106
  */
107
- batchQuery<T extends Record<string, any>>(queries: Array<{
107
+ batchQuery<_T extends Record<string, any>>(queries: Array<{
108
108
  key: string;
109
109
  tableName: string;
110
110
  params?: BaseQueryParams & {
package/dist/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- export { DubheGraphqlClient, createDubheGraphqlClient, QueryBuilders, } from './client';
1
+ export { DubheGraphqlClient, createDubheGraphqlClient, QueryBuilders } from './client';
2
2
  export * from './types';
3
3
  export type * from './types';
package/dist/index.js CHANGED
@@ -821,7 +821,7 @@ var DubheGraphqlClient = class {
821
821
  } else {
822
822
  webSocketImpl = WebSocket;
823
823
  }
824
- } catch (error) {
824
+ } catch (_error) {
825
825
  }
826
826
  const clientOptions = {
827
827
  url: config.subscriptionEndpoint,
@@ -1019,7 +1019,7 @@ var DubheGraphqlClient = class {
1019
1019
  const conditionKeys = Object.keys(condition);
1020
1020
  const singularTableName = this.getSingularTableName(tableName);
1021
1021
  const query = import_client2.gql`
1022
- query GetTableByCondition(${conditionKeys.map((key, index) => `$${key}: String!`).join(", ")}) {
1022
+ query GetTableByCondition(${conditionKeys.map((key, _index) => `$${key}: String!`).join(", ")}) {
1023
1023
  ${singularTableName}(${conditionKeys.map((key) => `${key}: $${key}`).join(", ")}) {
1024
1024
  ${this.convertTableFields(tableName, fields)}
1025
1025
  }
@@ -1135,9 +1135,7 @@ var DubheGraphqlClient = class {
1135
1135
  });
1136
1136
  subscriptions.push({ tableName, subscription });
1137
1137
  });
1138
- const activeSubscriptions = subscriptions.map(
1139
- ({ subscription }) => subscription.subscribe()
1140
- );
1138
+ const activeSubscriptions = subscriptions.map(({ subscription }) => subscription.subscribe());
1141
1139
  return () => {
1142
1140
  activeSubscriptions.forEach((sub) => sub.unsubscribe());
1143
1141
  if (globalOptions?.onComplete) {
@@ -1150,26 +1148,24 @@ var DubheGraphqlClient = class {
1150
1148
  * Simplified multi-table subscription - Support table name array and unified configuration
1151
1149
  */
1152
1150
  subscribeToTableList(tableNames, options) {
1153
- const tableConfigs = tableNames.map(
1154
- (tableName) => ({
1155
- tableName,
1156
- options: {
1157
- ...options,
1158
- // Use same configuration for each table
1159
- fields: options?.fields,
1160
- filter: options?.filter,
1161
- initialEvent: options?.initialEvent,
1162
- first: options?.first,
1163
- topicPrefix: options?.topicPrefix
1164
- }
1165
- })
1166
- );
1151
+ const tableConfigs = tableNames.map((tableName) => ({
1152
+ tableName,
1153
+ options: {
1154
+ ...options,
1155
+ // Use same configuration for each table
1156
+ fields: options?.fields,
1157
+ filter: options?.filter,
1158
+ initialEvent: options?.initialEvent,
1159
+ first: options?.first,
1160
+ topicPrefix: options?.topicPrefix
1161
+ }
1162
+ }));
1167
1163
  return this.subscribeToMultipleTables(tableConfigs, options);
1168
1164
  }
1169
1165
  /**
1170
1166
  * Build dynamic query - Adapted to API without store prefix
1171
1167
  */
1172
- buildQuery(tableName, fields, params) {
1168
+ buildQuery(tableName, fields, _params) {
1173
1169
  const pluralTableName = this.getPluralTableName(tableName);
1174
1170
  const fieldSelection = fields.join("\n ");
1175
1171
  return import_client2.gql`
@@ -1209,13 +1205,10 @@ var DubheGraphqlClient = class {
1209
1205
  return { key, result };
1210
1206
  });
1211
1207
  const results = await Promise.all(batchPromises);
1212
- return results.reduce(
1213
- (acc, { key, result }) => {
1214
- acc[key] = result;
1215
- return acc;
1216
- },
1217
- {}
1218
- );
1208
+ return results.reduce((acc, { key, result }) => {
1209
+ acc[key] = result;
1210
+ return acc;
1211
+ }, {});
1219
1212
  }
1220
1213
  /**
1221
1214
  * Real-time data stream listener - Adapted to API without store prefix
@@ -1352,16 +1345,14 @@ var DubheGraphqlClient = class {
1352
1345
  });
1353
1346
  }
1354
1347
  if (cacheConfig.customMergeStrategies) {
1355
- Object.entries(cacheConfig.customMergeStrategies).forEach(
1356
- ([tableName, strategy]) => {
1357
- if (!fields[tableName]) {
1358
- fields[tableName] = {
1359
- keyArgs: strategy.keyArgs || ["filter", "orderBy"],
1360
- merge: strategy.merge || this.defaultMergeStrategy
1361
- };
1362
- }
1348
+ Object.entries(cacheConfig.customMergeStrategies).forEach(([tableName, strategy]) => {
1349
+ if (!fields[tableName]) {
1350
+ fields[tableName] = {
1351
+ keyArgs: strategy.keyArgs || ["filter", "orderBy"],
1352
+ merge: strategy.merge || this.defaultMergeStrategy
1353
+ };
1363
1354
  }
1364
- );
1355
+ });
1365
1356
  }
1366
1357
  return fields;
1367
1358
  }
@@ -1386,46 +1377,33 @@ var DubheGraphqlClient = class {
1386
1377
  }
1387
1378
  const { components = [], resources = [], enums = [] } = this.dubheMetadata;
1388
1379
  components.forEach((componentObj) => {
1389
- Object.entries(componentObj).forEach(
1390
- ([componentName, componentData]) => {
1391
- this.processTableData(componentName, componentData, enums);
1392
- }
1393
- );
1380
+ Object.entries(componentObj).forEach(([componentName, componentData]) => {
1381
+ this.processTableData(componentName, componentData, enums);
1382
+ });
1394
1383
  });
1395
1384
  resources.forEach((resourceObj) => {
1396
- Object.entries(resourceObj).forEach(
1397
- ([resourceName, resourceData]) => {
1398
- this.processTableData(resourceName, resourceData, enums);
1399
- }
1400
- );
1385
+ Object.entries(resourceObj).forEach(([resourceName, resourceData]) => {
1386
+ this.processTableData(resourceName, resourceData, enums);
1387
+ });
1401
1388
  });
1402
1389
  }
1403
1390
  /**
1404
1391
  * Process data for a single table
1405
1392
  */
1406
- processTableData(tableName, tableData, enums) {
1393
+ processTableData(tableName, tableData, _enums) {
1407
1394
  const normalizedTableName = tableName.includes("_") ? this.toCamelCase(tableName) : tableName;
1408
1395
  const fields = [];
1409
1396
  const enumFields = {};
1410
1397
  if (tableData.fields && Array.isArray(tableData.fields)) {
1411
1398
  tableData.fields.forEach((fieldObj) => {
1412
- Object.entries(fieldObj).forEach(
1413
- ([fieldName, fieldType]) => {
1414
- const fieldNameCamelCase = this.toCamelCase(fieldName);
1415
- fields.push(fieldNameCamelCase);
1416
- }
1417
- );
1399
+ Object.entries(fieldObj).forEach(([fieldName, _fieldType]) => {
1400
+ const fieldNameCamelCase = this.toCamelCase(fieldName);
1401
+ fields.push(fieldNameCamelCase);
1402
+ });
1418
1403
  });
1419
1404
  }
1420
- fields.push(
1421
- "createdAtTimestampMs",
1422
- "updatedAtTimestampMs",
1423
- "isDeleted",
1424
- "lastUpdateDigest"
1425
- );
1426
- const primaryKeys = tableData.keys.map(
1427
- (key) => this.toCamelCase(key)
1428
- );
1405
+ fields.push("createdAtTimestampMs", "updatedAtTimestampMs", "isDeleted", "lastUpdateDigest");
1406
+ const primaryKeys = tableData.keys.map((key) => this.toCamelCase(key));
1429
1407
  const tableInfo = {
1430
1408
  tableName: normalizedTableName,
1431
1409
  fields: [...new Set(fields)],
@@ -1500,12 +1478,7 @@ var DubheGraphqlClient = class {
1500
1478
  if (tableInfo) {
1501
1479
  return tableInfo.fields;
1502
1480
  }
1503
- return [
1504
- "createdAtTimestampMs",
1505
- "updatedAtTimestampMs",
1506
- "isDeleted",
1507
- "lastUpdateDigest"
1508
- ];
1481
+ return ["createdAtTimestampMs", "updatedAtTimestampMs", "isDeleted", "lastUpdateDigest"];
1509
1482
  }
1510
1483
  /**
1511
1484
  * Convert table fields to GraphQL query string
@@ -1519,12 +1492,7 @@ var DubheGraphqlClient = class {
1519
1492
  if (autoFields.length > 0) {
1520
1493
  fields = autoFields;
1521
1494
  } else {
1522
- fields = [
1523
- "createdAtTimestampMs",
1524
- "updatedAtTimestampMs",
1525
- "isDeleted",
1526
- "lastUpdateDigest"
1527
- ];
1495
+ fields = ["createdAtTimestampMs", "updatedAtTimestampMs", "isDeleted", "lastUpdateDigest"];
1528
1496
  }
1529
1497
  }
1530
1498
  return fields.join("\n ");