@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.cjs CHANGED
@@ -87,9 +87,7 @@ var Configuration = class _Configuration {
87
87
  validatePublisher(publisherSlug) {
88
88
  if (!this.allowedPublishers) return;
89
89
  if (this.allowedPublishers.includes(publisherSlug)) return;
90
- throw new core.RestrictedError(
91
- `Publisher '${publisherSlug}' is not in the allowed publishers list`
92
- );
90
+ throw new core.RestrictedError(`Publisher '${publisherSlug}' is not in the allowed publishers list`);
93
91
  }
94
92
  /**
95
93
  * Validate that a game is allowed by the configuration
@@ -99,9 +97,7 @@ var Configuration = class _Configuration {
99
97
  const allowedForPublisher = this.allowedGames[publisherSlug];
100
98
  if (!allowedForPublisher) return;
101
99
  if (allowedForPublisher.includes(gameKey)) return;
102
- throw new core.RestrictedError(
103
- `Game '${gameKey}' is not allowed for publisher '${publisherSlug}'`
104
- );
100
+ throw new core.RestrictedError(`Game '${gameKey}' is not allowed for publisher '${publisherSlug}'`);
105
101
  }
106
102
  /**
107
103
  * Validate both publisher and game access
@@ -1045,9 +1041,13 @@ var RecordsResource = class extends BaseResource {
1045
1041
  resolveLinks: options.resolveLinks,
1046
1042
  first: options.first,
1047
1043
  after: options.after,
1048
- validateSchema: options.validateSchema
1044
+ validateSchema: options.validateSchema,
1045
+ includePricing: options.includePricing
1046
+ });
1047
+ const key = this.cacheKey("records", "search", {
1048
+ ...variables,
1049
+ includePricing: options.includePricing ?? false
1049
1050
  });
1050
- const key = this.cacheKey("records", "search", variables);
1051
1051
  const data = await this.withCache(key, "records", options, async () => {
1052
1052
  const result = await this.connection.execute(query, variables);
1053
1053
  return result["searchRecords"];
@@ -1065,9 +1065,12 @@ var RecordsResource = class extends BaseResource {
1065
1065
  * const record = await client.records.get('550e8400-e29b-41d4-a716-446655440000')
1066
1066
  */
1067
1067
  async get(id, options = {}) {
1068
- const key = this.cacheKey("records", "get", { id });
1068
+ const key = this.cacheKey("records", "get", {
1069
+ id,
1070
+ includePricing: options.includePricing ?? false
1071
+ });
1069
1072
  return this.withCache(key, "records", options, async () => {
1070
- const { query } = core.QueryBuilder.fetchRecordById();
1073
+ const { query } = core.QueryBuilder.fetchRecordById({ includePricing: options.includePricing });
1071
1074
  const result = await this.connection.execute(query, { id });
1072
1075
  return result["fetchRecord"] ?? null;
1073
1076
  });
@@ -1099,10 +1102,13 @@ var RecordsResource = class extends BaseResource {
1099
1102
  publisherSlug,
1100
1103
  gameKey,
1101
1104
  datasetKey: options.datasetKey,
1102
- identifier: options.identifier
1105
+ identifier: options.identifier,
1106
+ includePricing: options.includePricing ?? false
1103
1107
  });
1104
1108
  return this.withCache(key, "records", options, async () => {
1105
- const { query } = core.QueryBuilder.fetchRecordByIdentifier();
1109
+ const { query } = core.QueryBuilder.fetchRecordByIdentifier({
1110
+ includePricing: options.includePricing
1111
+ });
1106
1112
  const result = await this.connection.execute(query, {
1107
1113
  publisherSlug,
1108
1114
  gameKey,
@@ -1140,10 +1146,13 @@ var RecordsResource = class extends BaseResource {
1140
1146
  publisherSlug,
1141
1147
  gameKey,
1142
1148
  datasetKey: options.datasetKey,
1143
- identifiers: options.identifiers
1149
+ identifiers: options.identifiers,
1150
+ includePricing: options.includePricing ?? false
1144
1151
  });
1145
1152
  return this.withCache(key, "records", options, async () => {
1146
- const { query } = core.QueryBuilder.fetchRecordsByIdentifier();
1153
+ const { query } = core.QueryBuilder.fetchRecordsByIdentifier({
1154
+ includePricing: options.includePricing
1155
+ });
1147
1156
  const result = await this.connection.execute(query, {
1148
1157
  publisherSlug,
1149
1158
  gameKey,
@@ -1161,9 +1170,12 @@ var RecordsResource = class extends BaseResource {
1161
1170
  */
1162
1171
  async getMany(ids, options = {}) {
1163
1172
  if (ids.length === 0) return [];
1164
- const key = this.cacheKey("records", "getMany", { ids });
1173
+ const key = this.cacheKey("records", "getMany", {
1174
+ ids,
1175
+ includePricing: options.includePricing ?? false
1176
+ });
1165
1177
  return this.withCache(key, "records", options, async () => {
1166
- const { query } = core.QueryBuilder.fetchRecords();
1178
+ const { query } = core.QueryBuilder.fetchRecords({ includePricing: options.includePricing });
1167
1179
  const result = await this.connection.execute(query, { ids });
1168
1180
  return result["fetchRecords"] ?? [];
1169
1181
  });