@parseapi/sdk 1.6.0 → 1.7.0
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/README.md +7 -1
- package/dist/index.cjs +9 -3
- package/dist/index.d.cts +22 -3
- package/dist/index.d.ts +22 -3
- package/dist/index.js +9 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -17,7 +17,7 @@ Get a key at [parseapi.com](https://parseapi.com). The client also reads `PARSEA
|
|
|
17
17
|
|
|
18
18
|
## API versions
|
|
19
19
|
|
|
20
|
-
Version 1.
|
|
20
|
+
Version 1.7.0 explicitly selects the API contract supported by this SDK. It sends `Parse-Version: 2.0.0` on every lookup so responses match the API contract supported by the package. Your key and the team's saved default stay the same.
|
|
21
21
|
|
|
22
22
|
Upgrade the dependency in staging, review the [release notes](https://parseapi.com/docs/releases), and test the application before deploying the same code and dependency version to production. Commit your dependency lockfile so the tested package travels with your deployment. Future major SDK upgrades can select a newer API contract.
|
|
23
23
|
|
|
@@ -246,6 +246,12 @@ await parse.weather(40.7128, -74.006, { deep: true, date: '2026-08-15' });
|
|
|
246
246
|
|
|
247
247
|
Tariff starts with the general schedule line. Paid deep adds units and the special and other schedule columns. An optional origin then resolves country-specific measures. The three calls below show those successive choices. Without origin, schedule detail is still returned and origin-dependent fields are null. A null effective rate is not a zero rate.
|
|
248
248
|
|
|
249
|
+
Tariff lookup and search accept an optional `edition` fingerprint and `date` (`YYYY-MM-DD`). The edition pins exact immutable source bytes. A date is accepted only when verified source coverage exists. An edition without a date returns undated schedule context (`date: null`). Default requests use today. Paid detail exposes an open-string `reason` when `effective_rate` is null, including `incomplete_coverage`. A null rate never means zero. Explicit selections fail with `tariff_selection_mismatch` if an older server ignores the requested scope.
|
|
250
|
+
|
|
251
|
+
Origin means where the goods originate, not where they ship from. The effective rate covers matched stored schedule measures only. It is not complete duty or landed cost.
|
|
252
|
+
|
|
253
|
+
Codes contain 4, 6, 8 or 10 ASCII digits; dots and whitespace are optional. Search returns up to 20 description matches with parent `lineage` so a result named "Other" has context. Search is not product classification. In deep, `measures: null` means origin-dependent measures were not resolved. `measures: []` means the resolved lookup found none.
|
|
254
|
+
|
|
249
255
|
```ts
|
|
250
256
|
await parse.tariff('8471.30.01.00');
|
|
251
257
|
await parse.tariff('8471.30.01.00', { deep: true });
|
package/dist/index.cjs
CHANGED
|
@@ -24,7 +24,7 @@ __export(index_exports, {
|
|
|
24
24
|
parseAPI: () => parseAPI
|
|
25
25
|
});
|
|
26
26
|
module.exports = __toCommonJS(index_exports);
|
|
27
|
-
var VERSION = "1.
|
|
27
|
+
var VERSION = "1.7.0";
|
|
28
28
|
var API_VERSION = "2.0.0";
|
|
29
29
|
var DEFAULT_BASE_URL = "https://api.parseapi.com";
|
|
30
30
|
var DEFAULT_TIMEOUT_MS = 1e4;
|
|
@@ -49,6 +49,12 @@ var ParseAPIError = class extends Error {
|
|
|
49
49
|
this.requestId = requestId;
|
|
50
50
|
}
|
|
51
51
|
};
|
|
52
|
+
function tariffSelection(result, opts) {
|
|
53
|
+
if ((opts?.edition !== void 0 || opts?.date !== void 0) && (typeof result.edition !== "string" || result.edition.length !== 64 || !/^[a-f0-9]{64}$/.test(result.edition) || opts.edition !== void 0 && result.edition !== opts.edition || (opts.date !== void 0 ? result.date !== opts.date : result.date != null))) {
|
|
54
|
+
throw new ParseAPIError(0, "tariff_selection_mismatch", "Tariff response did not confirm the requested edition/date. The server may not support this selection.", null, null);
|
|
55
|
+
}
|
|
56
|
+
return result;
|
|
57
|
+
}
|
|
52
58
|
function env(name) {
|
|
53
59
|
return typeof process !== "undefined" ? process.env?.[name] : void 0;
|
|
54
60
|
}
|
|
@@ -317,9 +323,9 @@ function parseAPI(apiKey, options = {}) {
|
|
|
317
323
|
),
|
|
318
324
|
/** Look up the general US duty schedule line. Paid deep adds units and the special and other schedule columns. Add origin with deep to resolve country-specific measures. Without origin, schedule detail remains available and origin-dependent fields are null. A null effective rate is not a zero rate. */
|
|
319
325
|
tariff: Object.assign(
|
|
320
|
-
(code, opts) => request(`/tariff/${enc(code)}`, { origin: opts?.origin, ...deepQuery(opts) }, void 0, opts),
|
|
326
|
+
(code, opts) => request(`/tariff/${enc(code)}`, { origin: opts?.origin, edition: opts?.edition, date: opts?.date, ...deepQuery(opts) }, void 0, opts).then((result) => tariffSelection(result, opts)),
|
|
321
327
|
{
|
|
322
|
-
search: (query, opts) => request("/tariff", { q: query }, void 0, opts)
|
|
328
|
+
search: (query, opts) => request("/tariff", { q: query, edition: opts?.edition, date: opts?.date }, void 0, opts).then((result) => tariffSelection(result, opts))
|
|
323
329
|
}
|
|
324
330
|
),
|
|
325
331
|
currency: Object.assign(
|
package/dist/index.d.cts
CHANGED
|
@@ -377,11 +377,13 @@ interface TariffMeasure {
|
|
|
377
377
|
conditional?: boolean | null;
|
|
378
378
|
}
|
|
379
379
|
interface TariffDeep {
|
|
380
|
+
/** Open-string explanation when effective_rate is null. */
|
|
381
|
+
reason?: string | null;
|
|
380
382
|
/** The origin country the measures were resolved for. */
|
|
381
383
|
origin?: string | null;
|
|
382
|
-
/** Composed ad valorem percent. Null when the components do not compose cleanly. */
|
|
384
|
+
/** Composed ad valorem percent for matched stored measures only, not complete duty or landed cost. Null when the components do not compose cleanly. */
|
|
383
385
|
effective_rate?: number | null;
|
|
384
|
-
/**
|
|
386
|
+
/** Matching stored Chapter 99 schedule measures for this code and goods origin. */
|
|
385
387
|
measures?: TariffMeasure[] | null;
|
|
386
388
|
/** Units of quantity (No., kg). */
|
|
387
389
|
units: string[];
|
|
@@ -391,6 +393,10 @@ interface TariffDeep {
|
|
|
391
393
|
other: string | null;
|
|
392
394
|
}
|
|
393
395
|
interface Tariff {
|
|
396
|
+
/** Exact immutable edition. Older servers may omit it. */
|
|
397
|
+
edition?: string;
|
|
398
|
+
/** Answering date, or null for an undated edition query. */
|
|
399
|
+
date?: string | null;
|
|
394
400
|
/** Normalized code with dots (8471.30.01.00). */
|
|
395
401
|
hts: string;
|
|
396
402
|
/** The schedule line verbatim. */
|
|
@@ -407,8 +413,14 @@ interface TariffSearchHit {
|
|
|
407
413
|
hts: string;
|
|
408
414
|
description: string;
|
|
409
415
|
general: string | null;
|
|
416
|
+
/** Parent descriptions, outermost first. Older responses may omit this context. */
|
|
417
|
+
lineage?: string[] | null;
|
|
410
418
|
}
|
|
411
419
|
interface TariffSearch {
|
|
420
|
+
/** Exact immutable edition. Older servers may omit it. */
|
|
421
|
+
edition?: string;
|
|
422
|
+
/** Answering date, or null for an undated edition query. */
|
|
423
|
+
date?: string | null;
|
|
412
424
|
q: string;
|
|
413
425
|
revision: string;
|
|
414
426
|
/** Up to 20 tariff lines, best match first. */
|
|
@@ -1637,8 +1649,15 @@ type NaicsSearchOptions = {
|
|
|
1637
1649
|
type TariffOptions = {
|
|
1638
1650
|
/** Origin country (ISO2). With paid deep, resolves country-specific measures. */
|
|
1639
1651
|
origin?: string;
|
|
1652
|
+
/** Exact immutable edition fingerprint. */
|
|
1653
|
+
edition?: string;
|
|
1654
|
+
/** YYYY-MM-DD, accepted only with verified source coverage. */
|
|
1655
|
+
date?: string;
|
|
1640
1656
|
} & DeepOption & RequestOptions;
|
|
1641
|
-
type TariffSearchOptions =
|
|
1657
|
+
type TariffSearchOptions = {
|
|
1658
|
+
edition?: string;
|
|
1659
|
+
date?: string;
|
|
1660
|
+
} & RequestOptions;
|
|
1642
1661
|
type CurrencyOptions = LanguageOption & DeepOption & RequestOptions;
|
|
1643
1662
|
type CurrencyRateOptions = {
|
|
1644
1663
|
date?: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -377,11 +377,13 @@ interface TariffMeasure {
|
|
|
377
377
|
conditional?: boolean | null;
|
|
378
378
|
}
|
|
379
379
|
interface TariffDeep {
|
|
380
|
+
/** Open-string explanation when effective_rate is null. */
|
|
381
|
+
reason?: string | null;
|
|
380
382
|
/** The origin country the measures were resolved for. */
|
|
381
383
|
origin?: string | null;
|
|
382
|
-
/** Composed ad valorem percent. Null when the components do not compose cleanly. */
|
|
384
|
+
/** Composed ad valorem percent for matched stored measures only, not complete duty or landed cost. Null when the components do not compose cleanly. */
|
|
383
385
|
effective_rate?: number | null;
|
|
384
|
-
/**
|
|
386
|
+
/** Matching stored Chapter 99 schedule measures for this code and goods origin. */
|
|
385
387
|
measures?: TariffMeasure[] | null;
|
|
386
388
|
/** Units of quantity (No., kg). */
|
|
387
389
|
units: string[];
|
|
@@ -391,6 +393,10 @@ interface TariffDeep {
|
|
|
391
393
|
other: string | null;
|
|
392
394
|
}
|
|
393
395
|
interface Tariff {
|
|
396
|
+
/** Exact immutable edition. Older servers may omit it. */
|
|
397
|
+
edition?: string;
|
|
398
|
+
/** Answering date, or null for an undated edition query. */
|
|
399
|
+
date?: string | null;
|
|
394
400
|
/** Normalized code with dots (8471.30.01.00). */
|
|
395
401
|
hts: string;
|
|
396
402
|
/** The schedule line verbatim. */
|
|
@@ -407,8 +413,14 @@ interface TariffSearchHit {
|
|
|
407
413
|
hts: string;
|
|
408
414
|
description: string;
|
|
409
415
|
general: string | null;
|
|
416
|
+
/** Parent descriptions, outermost first. Older responses may omit this context. */
|
|
417
|
+
lineage?: string[] | null;
|
|
410
418
|
}
|
|
411
419
|
interface TariffSearch {
|
|
420
|
+
/** Exact immutable edition. Older servers may omit it. */
|
|
421
|
+
edition?: string;
|
|
422
|
+
/** Answering date, or null for an undated edition query. */
|
|
423
|
+
date?: string | null;
|
|
412
424
|
q: string;
|
|
413
425
|
revision: string;
|
|
414
426
|
/** Up to 20 tariff lines, best match first. */
|
|
@@ -1637,8 +1649,15 @@ type NaicsSearchOptions = {
|
|
|
1637
1649
|
type TariffOptions = {
|
|
1638
1650
|
/** Origin country (ISO2). With paid deep, resolves country-specific measures. */
|
|
1639
1651
|
origin?: string;
|
|
1652
|
+
/** Exact immutable edition fingerprint. */
|
|
1653
|
+
edition?: string;
|
|
1654
|
+
/** YYYY-MM-DD, accepted only with verified source coverage. */
|
|
1655
|
+
date?: string;
|
|
1640
1656
|
} & DeepOption & RequestOptions;
|
|
1641
|
-
type TariffSearchOptions =
|
|
1657
|
+
type TariffSearchOptions = {
|
|
1658
|
+
edition?: string;
|
|
1659
|
+
date?: string;
|
|
1660
|
+
} & RequestOptions;
|
|
1642
1661
|
type CurrencyOptions = LanguageOption & DeepOption & RequestOptions;
|
|
1643
1662
|
type CurrencyRateOptions = {
|
|
1644
1663
|
date?: string;
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
|
-
var VERSION = "1.
|
|
2
|
+
var VERSION = "1.7.0";
|
|
3
3
|
var API_VERSION = "2.0.0";
|
|
4
4
|
var DEFAULT_BASE_URL = "https://api.parseapi.com";
|
|
5
5
|
var DEFAULT_TIMEOUT_MS = 1e4;
|
|
@@ -24,6 +24,12 @@ var ParseAPIError = class extends Error {
|
|
|
24
24
|
this.requestId = requestId;
|
|
25
25
|
}
|
|
26
26
|
};
|
|
27
|
+
function tariffSelection(result, opts) {
|
|
28
|
+
if ((opts?.edition !== void 0 || opts?.date !== void 0) && (typeof result.edition !== "string" || result.edition.length !== 64 || !/^[a-f0-9]{64}$/.test(result.edition) || opts.edition !== void 0 && result.edition !== opts.edition || (opts.date !== void 0 ? result.date !== opts.date : result.date != null))) {
|
|
29
|
+
throw new ParseAPIError(0, "tariff_selection_mismatch", "Tariff response did not confirm the requested edition/date. The server may not support this selection.", null, null);
|
|
30
|
+
}
|
|
31
|
+
return result;
|
|
32
|
+
}
|
|
27
33
|
function env(name) {
|
|
28
34
|
return typeof process !== "undefined" ? process.env?.[name] : void 0;
|
|
29
35
|
}
|
|
@@ -292,9 +298,9 @@ function parseAPI(apiKey, options = {}) {
|
|
|
292
298
|
),
|
|
293
299
|
/** Look up the general US duty schedule line. Paid deep adds units and the special and other schedule columns. Add origin with deep to resolve country-specific measures. Without origin, schedule detail remains available and origin-dependent fields are null. A null effective rate is not a zero rate. */
|
|
294
300
|
tariff: Object.assign(
|
|
295
|
-
(code, opts) => request(`/tariff/${enc(code)}`, { origin: opts?.origin, ...deepQuery(opts) }, void 0, opts),
|
|
301
|
+
(code, opts) => request(`/tariff/${enc(code)}`, { origin: opts?.origin, edition: opts?.edition, date: opts?.date, ...deepQuery(opts) }, void 0, opts).then((result) => tariffSelection(result, opts)),
|
|
296
302
|
{
|
|
297
|
-
search: (query, opts) => request("/tariff", { q: query }, void 0, opts)
|
|
303
|
+
search: (query, opts) => request("/tariff", { q: query, edition: opts?.edition, date: opts?.date }, void 0, opts).then((result) => tariffSelection(result, opts))
|
|
298
304
|
}
|
|
299
305
|
),
|
|
300
306
|
currency: Object.assign(
|