@cords/sdk 0.1.11 → 0.1.13

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.mts CHANGED
@@ -186,7 +186,10 @@ declare const CordsAPI: ({ apiKey, version, referer, baseUrl: customBaseUrl, }:
186
186
  };
187
187
  }>;
188
188
  };
189
- declare const CordsPartnerAPI: ({ apiKey, version, referer, baseUrl: customBaseUrl, }: APIOptions) => {
189
+ declare const CordsPartnerAPI: ({ apiKey, version, referer, baseUrl: customBaseUrl, apiKeyId, }: APIOptions & {
190
+ /** Default API key ID filter. Can be overridden. */
191
+ apiKeyId?: string;
192
+ }) => {
190
193
  report: (options?: ReportOptions) => Promise<{
191
194
  data: ReportRecordType[];
192
195
  meta: {
@@ -194,6 +197,7 @@ declare const CordsPartnerAPI: ({ apiKey, version, referer, baseUrl: customBaseU
194
197
  page: number;
195
198
  };
196
199
  }>;
200
+ reportExport: (options?: Omit<ReportOptions, "page">) => Promise<ArrayBuffer>;
197
201
  };
198
202
  /** Helper function to format a service address */
199
203
  declare const formatServiceAddress: (address: ResourceAddressType) => string;
package/dist/index.d.ts CHANGED
@@ -186,7 +186,10 @@ declare const CordsAPI: ({ apiKey, version, referer, baseUrl: customBaseUrl, }:
186
186
  };
187
187
  }>;
188
188
  };
189
- declare const CordsPartnerAPI: ({ apiKey, version, referer, baseUrl: customBaseUrl, }: APIOptions) => {
189
+ declare const CordsPartnerAPI: ({ apiKey, version, referer, baseUrl: customBaseUrl, apiKeyId, }: APIOptions & {
190
+ /** Default API key ID filter. Can be overridden. */
191
+ apiKeyId?: string;
192
+ }) => {
190
193
  report: (options?: ReportOptions) => Promise<{
191
194
  data: ReportRecordType[];
192
195
  meta: {
@@ -194,6 +197,7 @@ declare const CordsPartnerAPI: ({ apiKey, version, referer, baseUrl: customBaseU
194
197
  page: number;
195
198
  };
196
199
  }>;
200
+ reportExport: (options?: Omit<ReportOptions, "page">) => Promise<ArrayBuffer>;
197
201
  };
198
202
  /** Helper function to format a service address */
199
203
  declare const formatServiceAddress: (address: ResourceAddressType) => string;
package/dist/index.js CHANGED
@@ -204,7 +204,8 @@ var CordsPartnerAPI = ({
204
204
  apiKey,
205
205
  version = "production",
206
206
  referer,
207
- baseUrl: customBaseUrl
207
+ baseUrl: customBaseUrl,
208
+ apiKeyId
208
209
  }) => {
209
210
  const requestOptions = {
210
211
  apiKey,
@@ -224,7 +225,8 @@ var CordsPartnerAPI = ({
224
225
  params.append("filters[search-term]", options.searchTerm);
225
226
  if (options == null ? void 0 : options.keyType)
226
227
  params.append("filters[key-type]", options.keyType);
227
- if (options == null ? void 0 : options.apiKey) params.append("filters[api-key]", options.apiKey);
228
+ const apiKey2 = (options == null ? void 0 : options.apiKey) || apiKeyId;
229
+ if (apiKey2) params.append("filters[api-key]", apiKey2);
228
230
  if (options == null ? void 0 : options.type) params.append("filters[type]", options.type);
229
231
  if (options == null ? void 0 : options.province)
230
232
  params.append("filters[province]", options.province);
@@ -239,7 +241,6 @@ var CordsPartnerAPI = ({
239
241
  options.dates.start.getTime() + "|" + options.dates.end.getTime()
240
242
  );
241
243
  }
242
- console.log(decodeURIComponent(url.toString() + "?" + params));
243
244
  const res = await request(
244
245
  requestOptions,
245
246
  url.toString() + "?" + params
@@ -247,8 +248,38 @@ var CordsPartnerAPI = ({
247
248
  const data = await res.json();
248
249
  return data;
249
250
  };
251
+ const reportExport = async (options) => {
252
+ const url = formatUrl("/partner/approved/report/export");
253
+ const params = new URLSearchParams();
254
+ if (options == null ? void 0 : options.email) params.append("filters[email]", options.email);
255
+ if (options == null ? void 0 : options.searchTerm)
256
+ params.append("filters[search-term]", options.searchTerm);
257
+ if (options == null ? void 0 : options.keyType)
258
+ params.append("filters[key-type]", options.keyType);
259
+ const apiKey2 = (options == null ? void 0 : options.apiKey) || apiKeyId;
260
+ if (apiKey2) params.append("filters[api-key]", apiKey2);
261
+ if (options == null ? void 0 : options.type) params.append("filters[type]", options.type);
262
+ if (options == null ? void 0 : options.province)
263
+ params.append("filters[province]", options.province);
264
+ if (options == null ? void 0 : options.postalCode)
265
+ params.append("filters[postal-code]", options.postalCode);
266
+ if (options == null ? void 0 : options.country)
267
+ params.append("filters[country]", options.country);
268
+ if (options == null ? void 0 : options.dates) {
269
+ params.append(
270
+ "filters[dates]",
271
+ options.dates.start.getTime() + "|" + options.dates.end.getTime()
272
+ );
273
+ }
274
+ const res = await request(
275
+ requestOptions,
276
+ url.toString() + "?" + params
277
+ );
278
+ return await res.arrayBuffer();
279
+ };
250
280
  return {
251
- report
281
+ report,
282
+ reportExport
252
283
  };
253
284
  };
254
285
  var formatServiceAddress = (address) => {
package/dist/index.mjs CHANGED
@@ -181,7 +181,8 @@ var CordsPartnerAPI = ({
181
181
  apiKey,
182
182
  version = "production",
183
183
  referer,
184
- baseUrl: customBaseUrl
184
+ baseUrl: customBaseUrl,
185
+ apiKeyId
185
186
  }) => {
186
187
  const requestOptions = {
187
188
  apiKey,
@@ -201,7 +202,8 @@ var CordsPartnerAPI = ({
201
202
  params.append("filters[search-term]", options.searchTerm);
202
203
  if (options == null ? void 0 : options.keyType)
203
204
  params.append("filters[key-type]", options.keyType);
204
- if (options == null ? void 0 : options.apiKey) params.append("filters[api-key]", options.apiKey);
205
+ const apiKey2 = (options == null ? void 0 : options.apiKey) || apiKeyId;
206
+ if (apiKey2) params.append("filters[api-key]", apiKey2);
205
207
  if (options == null ? void 0 : options.type) params.append("filters[type]", options.type);
206
208
  if (options == null ? void 0 : options.province)
207
209
  params.append("filters[province]", options.province);
@@ -216,7 +218,6 @@ var CordsPartnerAPI = ({
216
218
  options.dates.start.getTime() + "|" + options.dates.end.getTime()
217
219
  );
218
220
  }
219
- console.log(decodeURIComponent(url.toString() + "?" + params));
220
221
  const res = await request(
221
222
  requestOptions,
222
223
  url.toString() + "?" + params
@@ -224,8 +225,38 @@ var CordsPartnerAPI = ({
224
225
  const data = await res.json();
225
226
  return data;
226
227
  };
228
+ const reportExport = async (options) => {
229
+ const url = formatUrl("/partner/approved/report/export");
230
+ const params = new URLSearchParams();
231
+ if (options == null ? void 0 : options.email) params.append("filters[email]", options.email);
232
+ if (options == null ? void 0 : options.searchTerm)
233
+ params.append("filters[search-term]", options.searchTerm);
234
+ if (options == null ? void 0 : options.keyType)
235
+ params.append("filters[key-type]", options.keyType);
236
+ const apiKey2 = (options == null ? void 0 : options.apiKey) || apiKeyId;
237
+ if (apiKey2) params.append("filters[api-key]", apiKey2);
238
+ if (options == null ? void 0 : options.type) params.append("filters[type]", options.type);
239
+ if (options == null ? void 0 : options.province)
240
+ params.append("filters[province]", options.province);
241
+ if (options == null ? void 0 : options.postalCode)
242
+ params.append("filters[postal-code]", options.postalCode);
243
+ if (options == null ? void 0 : options.country)
244
+ params.append("filters[country]", options.country);
245
+ if (options == null ? void 0 : options.dates) {
246
+ params.append(
247
+ "filters[dates]",
248
+ options.dates.start.getTime() + "|" + options.dates.end.getTime()
249
+ );
250
+ }
251
+ const res = await request(
252
+ requestOptions,
253
+ url.toString() + "?" + params
254
+ );
255
+ return await res.arrayBuffer();
256
+ };
227
257
  return {
228
- report
258
+ report,
259
+ reportExport
229
260
  };
230
261
  };
231
262
  var formatServiceAddress = (address) => {
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "main": "./dist/index.js",
4
4
  "module": "./dist/index.mjs",
5
5
  "types": "./dist/index.d.ts",
6
- "version": "0.1.11",
6
+ "version": "0.1.13",
7
7
  "private": false,
8
8
  "publishConfig": {
9
9
  "access": "public"
@@ -13,13 +13,13 @@
13
13
  "dev": "bun run build -- --watch"
14
14
  },
15
15
  "devDependencies": {
16
- "@types/bun": "latest"
16
+ "@types/bun": "^1.3.9"
17
17
  },
18
18
  "peerDependencies": {
19
- "typescript": "^5.0.0"
19
+ "typescript": "^5.9.3"
20
20
  },
21
21
  "dependencies": {
22
- "tsup": "^8.0.2"
22
+ "tsup": "^8.5.1"
23
23
  },
24
24
  "license": "MIT",
25
25
  "files": [