@artaio/node-api 0.30.1 → 0.32.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.
Files changed (57) hide show
  1. package/README.md +3 -1
  2. package/dist/lib/ArtaClient.d.ts +5 -5
  3. package/dist/lib/ArtaClient.js +17 -4
  4. package/dist/lib/MetadataTypes.d.ts +1 -93
  5. package/dist/lib/MetadataTypes.js +15 -0
  6. package/dist/lib/arta.d.ts +1 -1
  7. package/dist/lib/arta.js +2 -2
  8. package/dist/lib/endpoint/attachment.d.ts +4 -10
  9. package/dist/lib/endpoint/emailRules.d.ts +6 -12
  10. package/dist/lib/endpoint/emailSubscriptions.d.ts +6 -12
  11. package/dist/lib/endpoint/endpoint.d.ts +5 -5
  12. package/dist/lib/endpoint/endpoint.js +3 -2
  13. package/dist/lib/endpoint/hostedSessions.d.ts +12 -29
  14. package/dist/lib/endpoint/invoicePayments.d.ts +7 -14
  15. package/dist/lib/endpoint/invoicePayments.js +13 -3
  16. package/dist/lib/endpoint/invoices.d.ts +4 -18
  17. package/dist/lib/endpoint/keys.d.ts +6 -16
  18. package/dist/lib/endpoint/logs.d.ts +7 -19
  19. package/dist/lib/endpoint/logs.js +12 -3
  20. package/dist/lib/endpoint/metadata.d.ts +3 -3
  21. package/dist/lib/endpoint/organization.d.ts +2 -14
  22. package/dist/lib/endpoint/payments.d.ts +7 -11
  23. package/dist/lib/endpoint/payments.js +13 -3
  24. package/dist/lib/endpoint/requests.d.ts +17 -41
  25. package/dist/lib/endpoint/requests.js +17 -5
  26. package/dist/lib/endpoint/shipments.d.ts +6 -73
  27. package/dist/lib/endpoint/shipments.js +19 -13
  28. package/dist/lib/endpoint/trackings.d.ts +3 -19
  29. package/dist/lib/endpoint/trackings.js +15 -6
  30. package/dist/lib/endpoint/uploads.d.ts +7 -18
  31. package/dist/lib/endpoint/webhookDeliveries.d.ts +4 -18
  32. package/dist/lib/endpoint/webhooks.d.ts +10 -13
  33. package/dist/lib/index.d.ts +9 -16
  34. package/dist/lib/net/FetchHttpClient.d.ts +13 -0
  35. package/dist/lib/net/FetchHttpClient.js +128 -0
  36. package/dist/lib/net/HttpClient.d.ts +6 -6
  37. package/dist/lib/net/RestClient.d.ts +3 -3
  38. package/dist/lib/types.d.ts +750 -0
  39. package/dist/lib/types.js +2 -0
  40. package/dist/lib/utils.d.ts +7 -2
  41. package/dist/lib/utils.js +16 -5
  42. package/dist/package.json +29 -21
  43. package/dist/schemas/generate.d.ts +1 -0
  44. package/dist/schemas/generate.js +51 -0
  45. package/dist/schemas/index.d.ts +3204 -0
  46. package/dist/schemas/index.js +733 -0
  47. package/dist/test-integration/index.d.ts +2 -0
  48. package/dist/test-integration/index.js +7 -0
  49. package/dist/test-integration/keys.test.d.ts +1 -0
  50. package/dist/test-integration/keys.test.js +71 -0
  51. package/dist/test-integration/requests.test.d.ts +1 -0
  52. package/dist/test-integration/requests.test.js +87 -0
  53. package/dist/test-integration/shipments.test.d.ts +1 -0
  54. package/dist/test-integration/shipments.test.js +114 -0
  55. package/package.json +29 -21
  56. package/dist/lib/net/NodeHttpClient.d.ts +0 -20
  57. package/dist/lib/net/NodeHttpClient.js +0 -203
package/README.md CHANGED
@@ -5,7 +5,9 @@ arta-node-api is in a pre-release beta. The package's API is unstable and expect
5
5
  Arta Node.js Library
6
6
  ===
7
7
 
8
- The Arta Node library provides a seamless integration to Arta API for applications running on Node.js using both Typescript or Javascript.
8
+ The Arta Node library provides a seamless integration to Arta API for applications running on Node.js 18+ or any platform using [Serverless JS](https://www.cloudflare.com/learning/serverless/serverless-javascript/) using both Typescript or Javascript.
9
+
10
+ It is a very light package with zero runtime dependencies using only the [fetch](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) Web API.
9
11
 
10
12
  ## Documentation
11
13
 
@@ -1,5 +1,5 @@
1
- import { HttpClient } from './net/HttpClient';
2
- import { RestClient } from './net/RestClient';
1
+ import type { HttpClient } from './net/HttpClient';
2
+ import type { RestClient } from './net/RestClient';
3
3
  export type ArtaID = number | string;
4
4
  interface ArtaClientConfig {
5
5
  apiKey: string;
@@ -13,9 +13,9 @@ export declare class ArtaClient implements RestClient {
13
13
  private request;
14
14
  private makeReqParams;
15
15
  private makeArtaAuthHeader;
16
- get(path: string, auth?: string): Promise<any>;
17
- post(path: string, payload: any, auth?: string): Promise<any>;
18
- patch(path: string, payload: any, auth?: string): Promise<any>;
16
+ get<T>(path: string, auth?: string): Promise<T>;
17
+ post<U, T>(path: string, payload: U, auth?: string): Promise<T>;
18
+ patch<U, T>(path: string, payload: U, auth?: string): Promise<T>;
19
19
  delete(path: string, auth?: string): Promise<void>;
20
20
  }
21
21
  export {};
@@ -53,6 +53,12 @@ var ArtaClient = /** @class */ (function () {
53
53
  switch (_a.label) {
54
54
  case 0:
55
55
  authValue = this.makeArtaAuthHeader(this.config.apiKey);
56
+ if (params.headers == null) {
57
+ params.headers = {
58
+ 'Content-Type': 'application/json',
59
+ 'User-Agent': "ARTA/v1 arta-node/".concat(package_json_1.version),
60
+ };
61
+ }
56
62
  if (params.headers.Authorization == null) {
57
63
  params.headers.Authorization = authValue;
58
64
  }
@@ -80,9 +86,16 @@ var ArtaClient = /** @class */ (function () {
80
86
  method: method,
81
87
  headers: {
82
88
  'User-Agent': "ARTA/v1 arta-node/".concat(package_json_1.version),
89
+ 'Content-Type': 'application/json'
83
90
  },
84
91
  };
85
92
  if (auth) {
93
+ if (reqParams.headers == null) {
94
+ reqParams.headers = {
95
+ 'User-Agent': "ARTA/v1 arta-node/".concat(package_json_1.version),
96
+ 'Content-Type': 'application/json'
97
+ };
98
+ }
86
99
  reqParams.headers.Authorization = this.makeArtaAuthHeader(auth);
87
100
  }
88
101
  if (body) {
@@ -99,7 +112,7 @@ var ArtaClient = /** @class */ (function () {
99
112
  return __generator(this, function (_a) {
100
113
  switch (_a.label) {
101
114
  case 0:
102
- reqParams = this.makeReqParams(path, 'get', auth);
115
+ reqParams = this.makeReqParams(path, 'GET', auth);
103
116
  return [4 /*yield*/, this.request(reqParams)];
104
117
  case 1:
105
118
  res = _a.sent();
@@ -114,7 +127,7 @@ var ArtaClient = /** @class */ (function () {
114
127
  return __generator(this, function (_a) {
115
128
  switch (_a.label) {
116
129
  case 0:
117
- reqParams = this.makeReqParams(path, 'post', auth, JSON.stringify(payload));
130
+ reqParams = this.makeReqParams(path, 'POST', auth, JSON.stringify(payload));
118
131
  return [4 /*yield*/, this.request(reqParams)];
119
132
  case 1:
120
133
  res = _a.sent();
@@ -129,7 +142,7 @@ var ArtaClient = /** @class */ (function () {
129
142
  return __generator(this, function (_a) {
130
143
  switch (_a.label) {
131
144
  case 0:
132
- reqParams = this.makeReqParams(path, 'patch', auth, JSON.stringify(payload));
145
+ reqParams = this.makeReqParams(path, 'PATCH', auth, JSON.stringify(payload));
133
146
  return [4 /*yield*/, this.request(reqParams)];
134
147
  case 1:
135
148
  res = _a.sent();
@@ -142,7 +155,7 @@ var ArtaClient = /** @class */ (function () {
142
155
  return __awaiter(this, void 0, void 0, function () {
143
156
  return __generator(this, function (_a) {
144
157
  switch (_a.label) {
145
- case 0: return [4 /*yield*/, this.request(this.makeReqParams(path, 'delete', auth))];
158
+ case 0: return [4 /*yield*/, this.request(this.makeReqParams(path, 'DELETE', auth))];
146
159
  case 1:
147
160
  _a.sent();
148
161
  return [2 /*return*/, Promise.resolve()];
@@ -1,110 +1,18 @@
1
- import { Nullable, NullableString } from './utils';
2
- export type AdditionalService = 'assembly' | 'debris_disposal' | 'deinstallation' | 'destination_additional_labor' | 'destination_building_coi' | 'destination_condition_check' | 'destination_full_condition_report' | 'destination_unpacking' | 'double_blind_bols' | 'installation' | 'origin_building_coi' | 'origin_condition_check' | 'origin_full_condition_report' | 'placement' | 'signature_delivery' | 'tarmac_supervision';
1
+ export * from './types';
3
2
  export type AccessRestriction = 'elevator_only' | 'freight_elevator' | 'loading_dock' | 'loading_dock_low' | 'low_clearance' | 'non_paved' | 'stairs_only' | 'steep_gradient';
4
- export type Insurance = 'arta_transit_insurance' | 'no_arta_insurance';
5
3
  export type PaymentProcessType = 'checkout' | 'checkout_direct' | 'invoicing';
6
- export type QuoteType = 'parcel' | 'premium' | 'select' | 'self_ship';
7
4
  export type QuoteRequestStatus = 'cancelled' | 'closed' | 'disqualified' | 'expired' | 'in_progress' | 'pending' | 'quoted';
8
- export type EmailNotificationId = 'booking' | 'cancelled' | 'collected' | 'collection' | 'complete' | 'custom_quoted_dashboard' | 'in_transit' | 'invoice' | 'self_ship_label' | 'payment' | 'scheduling' | 'eei';
9
- export type Recipients = 'payer' | 'origin' | 'destination';
10
- export type MimeType = 'application/pdf' | 'application/vnd.ms-excel' | 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' | 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' | 'image/jpeg' | 'image/png' | 'text/csv' | 'video/mp4' | 'video/quicktime' | 'application/msword';
11
- export type DocumentType = 'bill_of_lading' | 'certificate_of_insurance' | 'certificate_of_insurance_template' | 'condition_report' | 'condition_check' | 'image' | 'instructions' | 'airway_bill' | 'commercial_invoice' | 'power_of_attorney' | 'proof_of_export' | 'proof_of_delivery' | 'quote' | 'shipping_label' | 'other';
12
5
  export type PackingType = 'alcohol_case' | 'blanket' | 'box' | 'cbin_closed' | 'cbin_open' | 'crate' | 'foam_lined_box' | 'frame' | 'lockbox' | 'no_packing' | 'pallet' | 'portfolio' | 'rug_roll' | 'shadow_box' | 'slipcase' | 'soft_packing' | 'soft_wrap' | 'sonotube' | 'stabilizing_box' | 'tube';
13
6
  export type PackingSubType = 'alcohol_case' | 'lay_flat_wine_box' | 'blanket' | 'wardrobe_box' | 'cardboard_box' | 'chandelier_box' | 'chair_box' | 'cbin_closed' | 'cbin_open' | 'ply_box' | 'fine_art_econo_crate' | 'fine_art_international_crate' | 'econo_crate' | 'international_econo_crate' | 'furniture_crate' | 'international_furniture_crate' | 'parcel_crate' | 'museum_crate' | 'international_museum_crate' | 'foam_lined_box' | 'cavity_box' | 'strongbox' | 'double_box' | 'travel_frame' | 'travel_frame_art' | 'travel_frame_other' | 'a_frame' | 'slat_crate' | 'tri_wall_crate' | 'lockbox' | 'no_packing' | 'pallet' | 'international_pallet' | 'portfolio' | 'rug_rolled' | 'shadow_box' | 'slipcase' | 'slipcase_glass_tape' | 'poly_cardboard' | 'bubble_cardboard' | 'garment_bag' | 'poly_only' | 'dartek_only' | 'bubble_only' | 'cling_wrap' | 'cbin_communal' | 'sonotube' | 'stabilizing_box' | 'shipping_tube_small' | 'shipping_tube_large';
14
7
  export type ObjectType = 'art' | 'furniture' | 'jewelry' | 'decorative_arts' | 'collectibles' | 'alcohol' | 'automotive' | 'fashion' | 'other';
15
8
  export type ObjectSubType = 'painting_unframed' | 'painting_framed' | 'painting_framed_plexi' | 'painting_framed_glass' | 'work_on_paper_unframed' | 'work_on_paper_framed' | 'work_on_paper_framed_plexi' | 'work_on_paper_framed_glass' | 'mixed_media_unframed' | 'mixed_media_framed' | 'mixed_media_framed_plexi' | 'mixed_media_framed_glass' | 'photograph_unframed' | 'photograph_framed' | 'photograph_framed_plexi' | 'photograph_framed_glass' | 'new_media' | 'sculpture' | 'pedestal' | 'pedestal_case_glass' | 'pedestal_case_plexi' | 'ceramic' | 'neon' | 'tapestry' | 'other_art' | 'table' | 'chair' | 'sofa_loveseat_chaise' | 'floor_lamp' | 'floor_lamp_shade' | 'table_lamp' | 'table_lamp_shade' | 'sconce' | 'ottoman' | 'bookcase_storage' | 'nightstand' | 'armoire_dresser' | 'carpet_rug' | 'mirror' | 'chandelier' | 'bedframe' | 'headboard' | 'desk_vanity' | 'media_console' | 'other_furniture' | 'earrings' | 'necklace' | 'bracelet' | 'ring' | 'brooch' | 'watch' | 'cufflinks' | 'eyeglasses' | 'set' | 'precious_stones' | 'snuff_box_cigarette_case' | 'other_jewelry' | 'vase_vessel' | 'bowl' | 'plaque' | 'object_of_vertu' | 'candelabra_candlestick' | 'dinnerware' | 'flatware' | 'glassware' | 'serveware' | 'porcelain_plate' | 'porcelain_bowl' | 'tabletop_accessory' | 'clock' | 'other_decorative_arts' | 'stamp' | 'book' | 'coin' | 'document_manuscript' | 'toy' | 'miniature_model' | 'figurine_doll' | 'neon_sign' | 'memorabilia' | 'camera_electrical' | 'other_collectibles' | 'wine_bottle' | 'spirits_bottle' | 'beer_bottle' | 'wine_case' | 'spirits_case' | 'beer_case' | 'wine_barrel' | 'spirits_barrel' | 'beer_barrel' | 'other_alcohols' | 'car' | 'motorcycle' | 'bus' | 'van' | 'limousine' | 'carriage' | 'trailer' | 'sidecar' | 'other_automotive' | 'clothing' | 'footwear' | 'handbag' | 'accessories' | 'other_fashion' | 'musical_instrument' | 'firearm_weapon' | 'hunting_fishing' | 'medical_equipment' | 'other';
16
9
  export type ParcelTransportServices = 'economy' | 'economy_freight' | 'ground' | 'next_day_air' | 'priority' | 'priority_freight' | 'second_day_air' | 'standard';
17
- export type WebhookDeliveryType = 'request.created' | 'request.status.updated' | 'shipment.created' | 'shipment.eei_form_status.updated' | 'shipment.schedule.updated' | 'shipment.status.updated' | 'shipment.tracking.updated' | 'ping';
18
10
  export type ObjectMaterial = 'stone_marble' | 'precious_stones' | 'fiber_synthetic' | 'fabric_natural' | 'taxidermy' | 'carbon_fiber' | 'live_animal' | 'paper' | 'glass' | 'presious_metals' | 'particleboard' | 'styrofoam' | 'wood' | 'photo_film' | 'sand' | 'metal' | 'plexiglass' | 'aquatic_life' | 'canvas' | 'drywall' | 'hard_plastic' | 'vinyl' | 'soft_plastic' | 'leather' | 'rubber' | 'concreate' | 'paint' | 'electronics' | 'fiber_natural' | 'gas' | 'fabric_synthetic' | 'CITES' | 'liquids' | 'salts';
19
- export type ShipmentExceptionTypeId = 'change_of_address_request' | 'customs_information_required' | 'damaged_items' | 'direct_payment_required' | 'held_at_customs' | 'inaccurate_object_details' | 'incorrect_address' | 'lost_in_transit' | 'not_ready_for_delivery' | 'not_ready_for_release' | 'other' | 'prepayment_required' | 'requested_hold_to_collect' | 'requested_hold_to_deliver' | 'wrong_item';
20
11
  export type ArtaTrackingServiceType = 'transport' | 'location' | 'handling' | 'packing' | 'storage' | 'administration' | 'taxes_duties_fees' | 'security' | 'equipment';
21
12
  export type ArtaTrackingServiceSubType = 'specialized' | 'consolidated' | 'freight' | 'parcel' | 'collection' | 'delivery' | 'location' | 'unpacking' | 'condition' | 'installation' | 'deinstallation' | 'debris_disposal' | 'site_visit' | 'handling' | 'packing' | 'packing_materials' | 'receive_release' | 'warehouse' | 'customs' | 'coi' | 'administration' | 'taxes_duties' | 'fees' | 'security' | 'equipment';
22
13
  export type ArtaTrackingServiceSubSubType = 'armored_transport' | 'dedicated_transport' | 'specialized_shuttle' | 'road_groupage' | 'sea_groupage' | 'sea_freight' | 'ltl_freight' | 'ftl_freight' | 'air_freight' | 'cargo_air_freight' | 'parcel' | 'priority_freight' | 'economy_freight' | 'collection' | 'art_fair_collection' | 'residential_collection' | 'airport_collection' | 'port_collection' | 'dock_collection' | 'consolidated_collection' | 'failed_collection' | 'recollection' | 'delivery' | 'inside_delivery' | 'art_fair_delivery' | 'room_of_choice_delivery' | 'curbside_delivery' | 'residential_delivery' | 'signature_delivery' | 'saturday_delivery' | 'sunday_delivery' | 'scheduled_delivery' | 'after_hours_delivery' | 'airport_delivery' | 'port_delivery' | 'dock_delivery' | 'failed_delivery' | 'redelivery' | 'origin_additional_stops' | 'destination_additional_stops' | 'origin_off_route' | 'destination_off_route' | 'must_fly' | 'origin_unpacking_soft' | 'destination_unpacking_soft' | 'origin_unpacking_wood' | 'destination_unpacking_wood' | 'origin_unpacking' | 'destination_unpacking' | 'origin_full_condition_report' | 'destination_full_condition_report' | 'origin_condition_check' | 'destination_condition_check' | 'installation' | 'placement' | 'assembly' | 'deinstallation' | 'disassembly' | 'debris_disposal' | 'crate_disposal' | 'soft_packed_disposal' | 'origin_site_visit' | 'destination_site_visit' | 'origin_additional_labor' | 'destination_additional_labor' | 'airport_handling' | 'origin_oversized_handling' | 'destination_oversized_handling' | 'origin_additional_stairs' | 'destination_additional_stairs' | 'packing_labor' | 'crate_fabrication' | 't_frame_fabrication' | 'fabrication' | 'retrofitting' | 'additional_packing' | 'pack_into' | 'poly' | 'dartek' | 'bubble' | 'cling_wrap' | 'cbin_communal' | 'blanket' | 'portfolio' | 'poly_cardboard' | 'bubble_cardboard' | 'rug_rolled' | 'cbin_closed' | 'cbin_open' | 'garment_bag' | 'wardrobe_box' | 'cardboard_box' | 'chandelier_box' | 'chair_box' | 'slipcase' | 'glass_tape' | 'stabilizing_box' | 'shadow_box' | 'foam_lined_box' | 'cavity_box' | 'strongbox' | 'double_box' | 'shipping_tube_small' | 'shipping_tube_large' | 'sonotube' | 'alcohol_case' | 'lay_flat_wine_box' | 'lockbox' | 'travel_frame' | 'travel_frame_art' | 'travel_frame_other' | 'a_frame' | 'slat_crate' | 'tri_wall_crate' | 'ply_box' | 'fine_art_econo_crate' | 'fine_art_international_crate' | 'econo_crate' | 'international_econo_crate' | 'furniture_crate' | 'international_furniture_crate' | 'parcel_crate' | 'museum_crate' | 'international_museum_crate' | 'pallet' | 'international_pallet' | 'warehouse_handling' | 'receive_in_fee' | 'release_fee' | 'storage' | 'temp_storage' | 'viewing_room' | 'staging' | 'import_customs_formalities' | 'export_customs_formalities' | 'origin_building_coi' | 'destination_building_coi' | 'double_blind_bols' | 'power_of_attorney' | 'administrative' | 'mpf' | 'bond' | 'duties' | 'taxes' | 'disbursement' | 'temporary_customs_entry' | 'fuel_surcharge' | 'tarmac_supervision' | 'courier_onboard' | 'fork_lift' | 'gantry' | 'pallet_jack' | 'scaffolding' | 'rigging' | 'lift_gate' | 'ramp' | 'floor_protection';
23
- export type DisqualificationReasonCode = 'external_service_unavailable' | 'client_timeout_reached';
24
- export type PackageStatus = 'pending' | 'transit' | 'out_for_delivery' | 'delivered' | 'unknown' | 'notfound' | 'undelivered' | 'exception' | 'expired';
25
14
  export type EEIFormStatus = 'pending' | 'cleared' | 'approved' | 'rejected' | 'submitted';
26
15
  export type ShipmentStatus = 'pending' | 'confirmed' | 'collected' | 'in_transit' | 'completed';
27
- export type WebhookResourceType = 'ping' | 'request' | 'shipment';
28
- export type WebhookDeliveryStatus = 'delivered' | 'failed';
29
16
  export type PaymentContext = 'hosted_checkout' | 'invoiced';
30
- export type SupportedCurrency = 'CAD' | 'EUR' | 'GBP' | 'HKD' | 'USD';
31
17
  export type AuthTypes = 'api_key';
32
18
  export type APIStatus = 'active' | 'beta' | 'deprecated';
33
- export interface Contact {
34
- name: string;
35
- email_address?: NullableString;
36
- phone_number?: NullableString;
37
- }
38
- export interface ArtaLocation {
39
- access_restrictions?: Nullable<AccessRestriction[]>;
40
- address_line_1?: NullableString;
41
- address_line_2?: NullableString;
42
- address_line_3?: NullableString;
43
- city?: NullableString;
44
- region?: NullableString;
45
- postal_code?: NullableString;
46
- country: string;
47
- title?: NullableString;
48
- contacts?: Nullable<Contact[]>;
49
- estimated_country?: string;
50
- estimated_region?: string;
51
- estimated_city?: string;
52
- }
53
- export type Details = {
54
- materials?: Nullable<ObjectMaterial[]>;
55
- creation_date?: NullableString;
56
- creator?: NullableString;
57
- notes?: NullableString;
58
- title?: NullableString;
59
- is_fragile?: Nullable<boolean>;
60
- is_cites?: Nullable<boolean>;
61
- };
62
- export interface ArtaObject {
63
- internal_reference?: NullableString;
64
- current_packing?: Nullable<PackingSubType[]>;
65
- details?: Nullable<Details>;
66
- height: number | string;
67
- width: number | string;
68
- weight?: Nullable<number | string>;
69
- value: number | string;
70
- depth?: Nullable<number | string>;
71
- images?: Nullable<string[]>;
72
- public_reference?: string;
73
- subtype: ObjectSubType;
74
- unit_of_measurement?: NullableString;
75
- weight_unit?: NullableString;
76
- value_currency: SupportedCurrency;
77
- }
78
- export interface Disqualification {
79
- quote_types: QuoteType[];
80
- reason?: NullableString;
81
- reason_code: DisqualificationReasonCode;
82
- }
83
- export interface InsurancePolicy {
84
- amount: number;
85
- amount_currency: SupportedCurrency;
86
- id: string;
87
- insured_value: number;
88
- insured_value_currency: SupportedCurrency;
89
- }
90
- export interface ArtaService {
91
- amount: number;
92
- amount_currency: SupportedCurrency;
93
- included_services: ArtaService[];
94
- is_requested: boolean;
95
- is_required: boolean;
96
- name: string;
97
- sub_subtype: ArtaTrackingServiceSubSubType;
98
- subtype: ArtaTrackingServiceSubType;
99
- type: ArtaTrackingServiceType;
100
- }
101
- export interface Quote {
102
- id: number;
103
- included_services: ArtaService[];
104
- included_insurance_policy?: Nullable<InsurancePolicy>;
105
- optional_services: ArtaService[];
106
- quote_type: QuoteType;
107
- status: string;
108
- total: number;
109
- total_currency: SupportedCurrency;
110
- }
@@ -1,2 +1,17 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
2
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./types"), exports);
@@ -1,4 +1,4 @@
1
- import { Logger, LoggerVerbosity } from './logging';
1
+ import type { Logger, LoggerVerbosity } from './logging';
2
2
  import { AttachmentsEndpoint } from './endpoint/attachment';
3
3
  import { EmailRulesEndpoint } from './endpoint/emailRules';
4
4
  import { EmailSubscriptionsEndpoint } from './endpoint/emailSubscriptions';
package/dist/lib/arta.js CHANGED
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Arta = void 0;
4
4
  var ArtaClient_1 = require("./ArtaClient");
5
5
  var logging_1 = require("./logging");
6
- var NodeHttpClient_1 = require("./net/NodeHttpClient");
6
+ var FetchHttpClient_1 = require("./net/FetchHttpClient");
7
7
  var attachment_1 = require("./endpoint/attachment");
8
8
  var emailRules_1 = require("./endpoint/emailRules");
9
9
  var emailSubscriptions_1 = require("./endpoint/emailSubscriptions");
@@ -30,7 +30,7 @@ var Arta = /** @class */ (function () {
30
30
  function Arta(apiKey, config) {
31
31
  this.config = Object.assign(defaultConfig, config);
32
32
  (0, logging_1.initLogger)(this.config.logger, this.config.verbosity);
33
- this.artaClient = new ArtaClient_1.ArtaClient(new NodeHttpClient_1.NodeHttpClient(), {
33
+ this.artaClient = new ArtaClient_1.ArtaClient(new FetchHttpClient_1.FetchHttpClient(), {
34
34
  apiKey: apiKey,
35
35
  host: this.config.host,
36
36
  });
@@ -1,13 +1,7 @@
1
- import { ArtaID } from '../ArtaClient';
2
- import { RestClient } from '../net/RestClient';
3
- import { DatedInterface, NullableString } from '../utils';
4
- import { Page } from '../pagination';
5
- export interface Attachment extends DatedInterface {
6
- id: ArtaID;
7
- upload_id: number;
8
- request_id?: NullableString;
9
- shipment_id?: NullableString;
10
- }
1
+ import type { ArtaID } from '../ArtaClient';
2
+ import type { RestClient } from '../net/RestClient';
3
+ import type { Page } from '../pagination';
4
+ import type { Attachment } from '../types';
11
5
  export interface AttachmentCreateBodyRequest {
12
6
  upload_id: number;
13
7
  request_id: string;
@@ -1,16 +1,10 @@
1
- import { ArtaID } from '../ArtaClient';
2
- import { RestClient } from '../net/RestClient';
3
- import { DatedInterface } from '../utils';
4
- import { Page } from '../pagination';
5
- import { EmailNotificationId, Recipients } from '../MetadataTypes';
6
- export interface EmailRule extends DatedInterface {
7
- id: ArtaID;
8
- email_notification_id: EmailNotificationId;
9
- recipients: Recipients[];
10
- }
1
+ import type { ArtaID } from '../ArtaClient';
2
+ import type { RestClient } from '../net/RestClient';
3
+ import type { Page } from '../pagination';
4
+ import type { EmailNotificationId, EmailRule, Recipient } from '../types';
11
5
  export interface EmailRuleCreateBody {
12
6
  email_notification_id: EmailNotificationId;
13
- recipients: Recipients[];
7
+ recipients: Recipient[];
14
8
  }
15
9
  export interface EmailRuleCreate {
16
10
  email_rule: EmailRuleCreateBody;
@@ -23,7 +17,7 @@ export declare class EmailRulesEndpoint {
23
17
  getById(id: ArtaID, auth?: string): Promise<EmailRule>;
24
18
  list(page?: number, pageSize?: number, auth?: string): Promise<Page<EmailRule>>;
25
19
  update(id: ArtaID, payload: {
26
- recipients: Recipients[];
20
+ recipients: Recipient[];
27
21
  }, auth?: string): Promise<EmailRule>;
28
22
  create(payload: EmailRuleCreateBody, auth?: string): Promise<EmailRule>;
29
23
  remove(id: ArtaID, auth?: string): Promise<void>;
@@ -1,16 +1,10 @@
1
- import { ArtaID } from '../ArtaClient';
2
- import { RestClient } from '../net/RestClient';
3
- import { DatedInterface, NullableString } from '../utils';
4
- import { Page } from '../pagination';
5
- import { EmailNotificationId } from '../MetadataTypes';
6
- export interface EmailSubscription extends DatedInterface {
7
- id: ArtaID;
8
- email_notification_ids: EmailNotificationId;
9
- email_address: string;
10
- name?: NullableString;
11
- }
1
+ import type { ArtaID } from '../ArtaClient';
2
+ import type { RestClient } from '../net/RestClient';
3
+ import type { NullableString } from '../utils';
4
+ import type { Page } from '../pagination';
5
+ import type { EmailNotificationId, EmailSubscription } from '../types';
12
6
  export interface EmailSubscriptionCreateBody {
13
- email_notification_ids: EmailNotificationId;
7
+ email_notification_ids: EmailNotificationId[];
14
8
  email_address: string;
15
9
  name?: NullableString;
16
10
  }
@@ -1,8 +1,8 @@
1
- import { ArtaID } from '../ArtaClient';
2
- import { RestClient } from '../net/RestClient';
3
- import { DatedInterface } from '../utils';
4
- import { Page } from '../pagination';
5
- import { QueryParameters } from '../queryParams';
1
+ import type { ArtaID } from '../ArtaClient';
2
+ import type { RestClient } from '../net/RestClient';
3
+ import type { DatedInterface } from '../utils';
4
+ import type { Page } from '../pagination';
5
+ import type { QueryParameters } from '../queryParams';
6
6
  export interface Endpoint<T, U> {
7
7
  list: (queryParam?: QueryParameters, auth?: string) => Promise<Page<T>>;
8
8
  listAll: (auth?: string, onReturn?: (params: any) => T) => AsyncGenerator<T>;
@@ -39,8 +39,9 @@ var __await = (this && this.__await) || function (v) { return this instanceof __
39
39
  var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {
40
40
  if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
41
41
  var g = generator.apply(thisArg, _arguments || []), i, q = [];
42
- return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
43
- function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
42
+ return i = {}, verb("next"), verb("throw"), verb("return", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;
43
+ function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }
44
+ function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } }
44
45
  function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
45
46
  function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
46
47
  function fulfill(value) { resume("next", value); }
@@ -1,29 +1,12 @@
1
- import { ArtaID } from '../ArtaClient';
2
- import { RestClient } from '../net/RestClient';
3
- import { Page } from '../pagination';
4
- import { AdditionalService, ArtaLocation, ArtaObject, Insurance, PaymentProcessType, QuoteType, QuoteRequestStatus } from '../MetadataTypes';
5
- import { DatedInterface, Nullable, NullableString } from '../utils';
6
- import { HostedSessionsSearch } from '../search';
7
- export interface HostedSession extends DatedInterface {
8
- id: ArtaID;
9
- additional_services?: Nullable<AdditionalService[]>;
10
- cancel_url?: NullableString;
11
- destination?: Nullable<ArtaLocation>;
12
- insurance?: Nullable<Insurance>;
13
- internal_reference?: NullableString;
14
- objects: ArtaObject[];
15
- origin: ArtaLocation;
16
- preferred_quote_types?: Nullable<QuoteType[]>;
17
- public_reference?: NullableString;
18
- shipping_notes?: NullableString;
19
- success_url?: NullableString;
20
- payment_process: PaymentProcessType;
21
- private_token: string;
22
- shortcode: string;
23
- status: QuoteRequestStatus;
24
- url?: NullableString;
1
+ import type { ArtaID } from '../ArtaClient';
2
+ import type { RestClient } from '../net/RestClient';
3
+ import type { Page } from '../pagination';
4
+ import type { AdditionalService, ArtaLocation, ArtaObject, HostedSession, Insurance, QuoteType } from '../MetadataTypes';
5
+ import { type Nullable, type NullableString } from '../utils';
6
+ import type { HostedSessionsSearch } from '../search';
7
+ export type EnrichedHostedSession = HostedSession & {
25
8
  cancel: (auth?: string) => Promise<HostedSession>;
26
- }
9
+ };
27
10
  export interface HostedSessionCreateBody {
28
11
  additional_services?: Nullable<AdditionalService[]>;
29
12
  cancel_url?: NullableString;
@@ -46,8 +29,8 @@ export declare class HostedSessionsEndpoint {
46
29
  private readonly path;
47
30
  constructor(artaClient: RestClient);
48
31
  private withFunctionCalls;
49
- getById(id: ArtaID, auth?: string): Promise<HostedSession>;
50
- list(search?: HostedSessionsSearch, page?: number, pageSize?: number, auth?: string): Promise<Page<HostedSession>>;
51
- create(payload: HostedSessionCreateBody, auth?: string): Promise<HostedSession>;
52
- cancel(id: ArtaID, auth?: string): Promise<HostedSession>;
32
+ getById(id: ArtaID, auth?: string): Promise<EnrichedHostedSession>;
33
+ list(search?: HostedSessionsSearch, page?: number, pageSize?: number, auth?: string): Promise<Page<EnrichedHostedSession>>;
34
+ create(payload: HostedSessionCreateBody, auth?: string): Promise<EnrichedHostedSession>;
35
+ cancel(id: ArtaID, auth?: string): Promise<EnrichedHostedSession>;
53
36
  }
@@ -1,17 +1,10 @@
1
- import { ArtaID } from '../ArtaClient';
2
- import { SupportedCurrency } from '../MetadataTypes';
3
- import { RestClient } from '../net/RestClient';
4
- import { Page } from '../pagination';
5
- import { DatedInterface, NullableString } from '../utils';
6
- export interface InvoicePayment extends DatedInterface {
7
- id: ArtaID;
8
- amount: number;
9
- amount_currency: SupportedCurrency;
10
- credit_id: NullableString;
11
- invoice_id: NullableString;
12
- paid_on: Date;
13
- payment_id?: NullableString;
14
- shipment_id?: NullableString;
1
+ import type { ArtaID } from '../ArtaClient';
2
+ import type { RestClient } from '../net/RestClient';
3
+ import type { Page } from '../pagination';
4
+ import type { InvoicePayment } from '../types';
5
+ export interface UnparsedInvoicePayment extends Omit<InvoicePayment, 'paid_on' | 'amount'> {
6
+ paid_on: string;
7
+ amount: string;
15
8
  }
16
9
  export declare class InvoicePaymentsEndpoint {
17
10
  private readonly artaClient;
@@ -1,6 +1,18 @@
1
1
  "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
2
13
  Object.defineProperty(exports, "__esModule", { value: true });
3
14
  exports.InvoicePaymentsEndpoint = void 0;
15
+ var utils_1 = require("../utils");
4
16
  var endpoint_1 = require("./endpoint");
5
17
  var InvoicePaymentsEndpoint = /** @class */ (function () {
6
18
  function InvoicePaymentsEndpoint(artaClient) {
@@ -17,9 +29,7 @@ var InvoicePaymentsEndpoint = /** @class */ (function () {
17
29
  return this.defaultEndpoint.list({ page: page, page_size: pageSize }, auth);
18
30
  };
19
31
  InvoicePaymentsEndpoint.prototype.enrichFields = function (resource) {
20
- resource.amount = Number(resource.amount);
21
- resource.paid_on = new Date(resource.paid_on);
22
- return resource;
32
+ return __assign(__assign({}, resource), { amount: Number(resource.amount), paid_on: (0, utils_1.createDateAsUTC)(resource.paid_on) });
23
33
  };
24
34
  return InvoicePaymentsEndpoint;
25
35
  }());
@@ -1,21 +1,7 @@
1
- import { ArtaID } from '../ArtaClient';
2
- import { SupportedCurrency } from '../MetadataTypes';
3
- import { RestClient } from '../net/RestClient';
4
- import { Page } from '../pagination';
5
- import { DatedInterface, Nullable, NullableString } from '../utils';
6
- export interface Invoice extends DatedInterface {
7
- amount_owed: number;
8
- amount_owed_currency: SupportedCurrency;
9
- amount_paid: number;
10
- amount_paid_currency: SupportedCurrency;
11
- created_at: Date;
12
- invoice_url?: NullableString;
13
- id: ArtaID;
14
- issued_on: Nullable<Date>;
15
- shipment_id: NullableString;
16
- status: string;
17
- updated_at: Date;
18
- }
1
+ import type { ArtaID } from '../ArtaClient';
2
+ import type { RestClient } from '../net/RestClient';
3
+ import type { Page } from '../pagination';
4
+ import type { Invoice } from '../types';
19
5
  export declare class InvoicesEndpoint {
20
6
  private readonly artaClient;
21
7
  private readonly defaultEndpoint;
@@ -1,17 +1,7 @@
1
- import { ArtaID } from '../ArtaClient';
2
- import { RestClient } from '../net/RestClient';
3
- import { DatedInterface, NullableString } from '../utils';
4
- import { Page } from '../pagination';
5
- export interface Key extends DatedInterface {
6
- id: ArtaID;
7
- is_testing: boolean;
8
- name?: NullableString;
9
- token: string;
10
- }
11
- export interface KeyCreateBody {
12
- is_testing: boolean;
13
- name?: NullableString;
14
- }
1
+ import type { RestClient } from '../net/RestClient';
2
+ import type { Page } from '../pagination';
3
+ import type { Key } from '../types';
4
+ export type KeyCreateBody = Pick<Key, 'is_testing' | 'name'>;
15
5
  export interface KeyCreate {
16
6
  api_key: KeyCreateBody;
17
7
  }
@@ -20,9 +10,9 @@ export declare class KeysEndpoint {
20
10
  private readonly defaultEndpoint;
21
11
  private readonly path;
22
12
  constructor(artaClient: RestClient);
23
- getById(id: ArtaID, auth?: string): Promise<Key>;
13
+ getById(id: Key['id'], auth?: string): Promise<Key>;
24
14
  list(page?: number, pageSize?: number, auth?: string): Promise<Page<Key>>;
25
15
  listAll(auth?: string): AsyncGenerator<Key>;
26
16
  create(payload: KeyCreateBody, auth?: string): Promise<Key>;
27
- remove(id: ArtaID, auth?: string): Promise<void>;
17
+ remove(id: Key['id'], auth?: string): Promise<void>;
28
18
  }
@@ -1,22 +1,10 @@
1
- import { ArtaID } from '../ArtaClient';
2
- import { RestClient } from '../net/RestClient';
3
- import { Page } from '../pagination';
4
- import { DatedInterface, NullableString } from '../utils';
5
- export interface Log extends DatedInterface {
6
- api_key_id: number;
7
- arta_version: string;
8
- end_at: Date;
9
- id: ArtaID;
10
- created_at: Date;
11
- method: string;
12
- path: string;
13
- query_params: string;
14
- request_body?: NullableString;
15
- request_id: string;
16
- response_body?: NullableString;
17
- start_at: Date;
18
- status: number;
19
- updated_at: Date;
1
+ import type { ArtaID } from '../ArtaClient';
2
+ import type { RestClient } from '../net/RestClient';
3
+ import type { Page } from '../pagination';
4
+ import type { Log } from '../types';
5
+ export interface UnparsedLog extends Omit<Log, 'start_at' | 'end_at'> {
6
+ start_at: string;
7
+ end_at: string;
20
8
  }
21
9
  export declare class LogsEndpoint {
22
10
  private readonly artaClient;
@@ -1,4 +1,15 @@
1
1
  "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
2
13
  Object.defineProperty(exports, "__esModule", { value: true });
3
14
  exports.LogsEndpoint = void 0;
4
15
  var utils_1 = require("../utils");
@@ -18,9 +29,7 @@ var LogsEndpoint = /** @class */ (function () {
18
29
  return this.defaultEndpoint.list({ page: page, page_size: pageSize }, auth);
19
30
  };
20
31
  LogsEndpoint.prototype.enrichFields = function (resource) {
21
- resource.start_at = (0, utils_1.createDateAsUTC)(resource.start_at);
22
- resource.end_at = (0, utils_1.createDateAsUTC)(resource.end_at);
23
- return resource;
32
+ return __assign(__assign({}, resource), { start_at: (0, utils_1.createDateAsUTC)(resource.start_at), end_at: (0, utils_1.createDateAsUTC)(resource.end_at) });
24
33
  };
25
34
  return LogsEndpoint;
26
35
  }());
@@ -1,5 +1,5 @@
1
- import { AccessRestriction, APIStatus, ArtaTrackingServiceSubSubType, ArtaTrackingServiceSubType, ArtaTrackingServiceType, AuthTypes, EmailNotificationId, Insurance, ObjectMaterial, ObjectSubType, ObjectType, PackageStatus, PackingSubType, PackingType, ParcelTransportServices, PaymentProcessType, QuoteRequestStatus, QuoteType, Recipients, ShipmentExceptionTypeId, ShipmentStatus, SupportedCurrency } from '../MetadataTypes';
2
- import { RestClient } from '../net/RestClient';
1
+ import type { AccessRestriction, APIStatus, ArtaTrackingServiceSubSubType, ArtaTrackingServiceSubType, ArtaTrackingServiceType, AuthTypes, EmailNotificationId, Insurance, ObjectMaterial, ObjectSubType, ObjectType, PackageStatus, PackingSubType, PackingType, ParcelTransportServices, PaymentProcessType, QuoteRequestStatus, QuoteType, Recipient, ShipmentExceptionTypeId, ShipmentStatus, SupportedCurrency } from '../MetadataTypes';
2
+ import type { RestClient } from '../net/RestClient';
3
3
  export interface APIVersionMetadata {
4
4
  authentication: AuthTypes[];
5
5
  description: string;
@@ -13,7 +13,7 @@ export interface CurrencyMetadata {
13
13
  }
14
14
  export interface EmailNotificationMetadata {
15
15
  description: string;
16
- optional_recipients: Recipients;
16
+ optional_recipients: Recipient[];
17
17
  id: EmailNotificationId;
18
18
  }
19
19
  export interface ShipmentExceptionTypeMetadata {