@carddb/client 0.1.3 → 0.1.5

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/index.d.ts CHANGED
@@ -474,10 +474,14 @@ interface SearchRecordsOptions {
474
474
  after?: string;
475
475
  /** Whether to validate filter against schema (default: true) */
476
476
  validateSchema?: boolean;
477
+ /** Include live TCGPlayer pricing when configured for the dataset */
478
+ includePricing?: boolean;
477
479
  /** Whether to use cache (defaults to client config) */
478
480
  cache?: boolean;
479
481
  }
480
482
  interface GetRecordOptions {
483
+ /** Include live TCGPlayer pricing when configured for the dataset */
484
+ includePricing?: boolean;
481
485
  /** Whether to use cache (defaults to client config) */
482
486
  cache?: boolean;
483
487
  }
@@ -490,6 +494,8 @@ interface GetRecordByIdentifierOptions {
490
494
  datasetKey: string;
491
495
  /** The identifier value to look up */
492
496
  identifier: string;
497
+ /** Include live TCGPlayer pricing when configured for the dataset */
498
+ includePricing?: boolean;
493
499
  /** Whether to use cache (defaults to client config) */
494
500
  cache?: boolean;
495
501
  }
@@ -502,6 +508,8 @@ interface GetRecordsByIdentifierOptions {
502
508
  datasetKey: string;
503
509
  /** Identifier values to look up */
504
510
  identifiers: string[];
511
+ /** Include live TCGPlayer pricing when configured for the dataset */
512
+ includePricing?: boolean;
505
513
  /** Whether to use cache (defaults to client config) */
506
514
  cache?: boolean;
507
515
  }
package/dist/index.js CHANGED
@@ -86,9 +86,7 @@ var Configuration = class _Configuration {
86
86
  validatePublisher(publisherSlug) {
87
87
  if (!this.allowedPublishers) return;
88
88
  if (this.allowedPublishers.includes(publisherSlug)) return;
89
- throw new RestrictedError(
90
- `Publisher '${publisherSlug}' is not in the allowed publishers list`
91
- );
89
+ throw new RestrictedError(`Publisher '${publisherSlug}' is not in the allowed publishers list`);
92
90
  }
93
91
  /**
94
92
  * Validate that a game is allowed by the configuration
@@ -98,9 +96,7 @@ var Configuration = class _Configuration {
98
96
  const allowedForPublisher = this.allowedGames[publisherSlug];
99
97
  if (!allowedForPublisher) return;
100
98
  if (allowedForPublisher.includes(gameKey)) return;
101
- throw new RestrictedError(
102
- `Game '${gameKey}' is not allowed for publisher '${publisherSlug}'`
103
- );
99
+ throw new RestrictedError(`Game '${gameKey}' is not allowed for publisher '${publisherSlug}'`);
104
100
  }
105
101
  /**
106
102
  * Validate both publisher and game access
@@ -1044,9 +1040,13 @@ var RecordsResource = class extends BaseResource {
1044
1040
  resolveLinks: options.resolveLinks,
1045
1041
  first: options.first,
1046
1042
  after: options.after,
1047
- validateSchema: options.validateSchema
1043
+ validateSchema: options.validateSchema,
1044
+ includePricing: options.includePricing
1045
+ });
1046
+ const key = this.cacheKey("records", "search", {
1047
+ ...variables,
1048
+ includePricing: options.includePricing ?? false
1048
1049
  });
1049
- const key = this.cacheKey("records", "search", variables);
1050
1050
  const data = await this.withCache(key, "records", options, async () => {
1051
1051
  const result = await this.connection.execute(query, variables);
1052
1052
  return result["searchRecords"];
@@ -1064,9 +1064,12 @@ var RecordsResource = class extends BaseResource {
1064
1064
  * const record = await client.records.get('550e8400-e29b-41d4-a716-446655440000')
1065
1065
  */
1066
1066
  async get(id, options = {}) {
1067
- const key = this.cacheKey("records", "get", { id });
1067
+ const key = this.cacheKey("records", "get", {
1068
+ id,
1069
+ includePricing: options.includePricing ?? false
1070
+ });
1068
1071
  return this.withCache(key, "records", options, async () => {
1069
- const { query } = QueryBuilder.fetchRecordById();
1072
+ const { query } = QueryBuilder.fetchRecordById({ includePricing: options.includePricing });
1070
1073
  const result = await this.connection.execute(query, { id });
1071
1074
  return result["fetchRecord"] ?? null;
1072
1075
  });
@@ -1098,10 +1101,13 @@ var RecordsResource = class extends BaseResource {
1098
1101
  publisherSlug,
1099
1102
  gameKey,
1100
1103
  datasetKey: options.datasetKey,
1101
- identifier: options.identifier
1104
+ identifier: options.identifier,
1105
+ includePricing: options.includePricing ?? false
1102
1106
  });
1103
1107
  return this.withCache(key, "records", options, async () => {
1104
- const { query } = QueryBuilder.fetchRecordByIdentifier();
1108
+ const { query } = QueryBuilder.fetchRecordByIdentifier({
1109
+ includePricing: options.includePricing
1110
+ });
1105
1111
  const result = await this.connection.execute(query, {
1106
1112
  publisherSlug,
1107
1113
  gameKey,
@@ -1139,10 +1145,13 @@ var RecordsResource = class extends BaseResource {
1139
1145
  publisherSlug,
1140
1146
  gameKey,
1141
1147
  datasetKey: options.datasetKey,
1142
- identifiers: options.identifiers
1148
+ identifiers: options.identifiers,
1149
+ includePricing: options.includePricing ?? false
1143
1150
  });
1144
1151
  return this.withCache(key, "records", options, async () => {
1145
- const { query } = QueryBuilder.fetchRecordsByIdentifier();
1152
+ const { query } = QueryBuilder.fetchRecordsByIdentifier({
1153
+ includePricing: options.includePricing
1154
+ });
1146
1155
  const result = await this.connection.execute(query, {
1147
1156
  publisherSlug,
1148
1157
  gameKey,
@@ -1160,9 +1169,12 @@ var RecordsResource = class extends BaseResource {
1160
1169
  */
1161
1170
  async getMany(ids, options = {}) {
1162
1171
  if (ids.length === 0) return [];
1163
- const key = this.cacheKey("records", "getMany", { ids });
1172
+ const key = this.cacheKey("records", "getMany", {
1173
+ ids,
1174
+ includePricing: options.includePricing ?? false
1175
+ });
1164
1176
  return this.withCache(key, "records", options, async () => {
1165
- const { query } = QueryBuilder.fetchRecords();
1177
+ const { query } = QueryBuilder.fetchRecords({ includePricing: options.includePricing });
1166
1178
  const result = await this.connection.execute(query, { ids });
1167
1179
  return result["fetchRecords"] ?? [];
1168
1180
  });