@artaio/node-api 0.31.0 → 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 (49) hide show
  1. package/README.md +3 -1
  2. package/dist/lib/ArtaClient.js +13 -6
  3. package/dist/lib/MetadataTypes.d.ts +1 -93
  4. package/dist/lib/MetadataTypes.js +15 -0
  5. package/dist/lib/arta.d.ts +1 -1
  6. package/dist/lib/arta.js +2 -2
  7. package/dist/lib/endpoint/attachment.d.ts +4 -10
  8. package/dist/lib/endpoint/emailRules.d.ts +6 -12
  9. package/dist/lib/endpoint/emailSubscriptions.d.ts +6 -12
  10. package/dist/lib/endpoint/endpoint.d.ts +5 -5
  11. package/dist/lib/endpoint/endpoint.js +3 -2
  12. package/dist/lib/endpoint/hostedSessions.d.ts +12 -29
  13. package/dist/lib/endpoint/invoicePayments.d.ts +4 -15
  14. package/dist/lib/endpoint/invoices.d.ts +4 -18
  15. package/dist/lib/endpoint/keys.d.ts +6 -16
  16. package/dist/lib/endpoint/logs.d.ts +4 -20
  17. package/dist/lib/endpoint/metadata.d.ts +3 -3
  18. package/dist/lib/endpoint/organization.d.ts +2 -14
  19. package/dist/lib/endpoint/payments.d.ts +4 -12
  20. package/dist/lib/endpoint/requests.d.ts +17 -41
  21. package/dist/lib/endpoint/requests.js +17 -5
  22. package/dist/lib/endpoint/shipments.d.ts +6 -73
  23. package/dist/lib/endpoint/shipments.js +19 -13
  24. package/dist/lib/endpoint/trackings.d.ts +3 -19
  25. package/dist/lib/endpoint/uploads.d.ts +7 -18
  26. package/dist/lib/endpoint/webhookDeliveries.d.ts +4 -18
  27. package/dist/lib/endpoint/webhooks.d.ts +10 -13
  28. package/dist/lib/index.d.ts +9 -16
  29. package/dist/lib/net/FetchHttpClient.d.ts +13 -0
  30. package/dist/lib/net/FetchHttpClient.js +128 -0
  31. package/dist/lib/net/HttpClient.d.ts +3 -6
  32. package/dist/lib/types.d.ts +750 -0
  33. package/dist/lib/types.js +2 -0
  34. package/dist/package.json +15 -10
  35. package/dist/schemas/generate.d.ts +1 -0
  36. package/dist/schemas/generate.js +51 -0
  37. package/dist/schemas/index.d.ts +3204 -0
  38. package/dist/schemas/index.js +733 -0
  39. package/dist/test-integration/index.d.ts +2 -0
  40. package/dist/test-integration/index.js +7 -0
  41. package/dist/test-integration/keys.test.d.ts +1 -0
  42. package/dist/test-integration/keys.test.js +71 -0
  43. package/dist/test-integration/requests.test.d.ts +1 -0
  44. package/dist/test-integration/requests.test.js +87 -0
  45. package/dist/test-integration/shipments.test.d.ts +1 -0
  46. package/dist/test-integration/shipments.test.js +114 -0
  47. package/package.json +15 -10
  48. package/dist/lib/net/NodeHttpClient.d.ts +0 -20
  49. 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
 
@@ -54,7 +54,10 @@ var ArtaClient = /** @class */ (function () {
54
54
  case 0:
55
55
  authValue = this.makeArtaAuthHeader(this.config.apiKey);
56
56
  if (params.headers == null) {
57
- params.headers = {};
57
+ params.headers = {
58
+ 'Content-Type': 'application/json',
59
+ 'User-Agent': "ARTA/v1 arta-node/".concat(package_json_1.version),
60
+ };
58
61
  }
59
62
  if (params.headers.Authorization == null) {
60
63
  params.headers.Authorization = authValue;
@@ -83,11 +86,15 @@ var ArtaClient = /** @class */ (function () {
83
86
  method: method,
84
87
  headers: {
85
88
  'User-Agent': "ARTA/v1 arta-node/".concat(package_json_1.version),
89
+ 'Content-Type': 'application/json'
86
90
  },
87
91
  };
88
92
  if (auth) {
89
93
  if (reqParams.headers == null) {
90
- reqParams.headers = {};
94
+ reqParams.headers = {
95
+ 'User-Agent': "ARTA/v1 arta-node/".concat(package_json_1.version),
96
+ 'Content-Type': 'application/json'
97
+ };
91
98
  }
92
99
  reqParams.headers.Authorization = this.makeArtaAuthHeader(auth);
93
100
  }
@@ -105,7 +112,7 @@ var ArtaClient = /** @class */ (function () {
105
112
  return __generator(this, function (_a) {
106
113
  switch (_a.label) {
107
114
  case 0:
108
- reqParams = this.makeReqParams(path, 'get', auth);
115
+ reqParams = this.makeReqParams(path, 'GET', auth);
109
116
  return [4 /*yield*/, this.request(reqParams)];
110
117
  case 1:
111
118
  res = _a.sent();
@@ -120,7 +127,7 @@ var ArtaClient = /** @class */ (function () {
120
127
  return __generator(this, function (_a) {
121
128
  switch (_a.label) {
122
129
  case 0:
123
- reqParams = this.makeReqParams(path, 'post', auth, JSON.stringify(payload));
130
+ reqParams = this.makeReqParams(path, 'POST', auth, JSON.stringify(payload));
124
131
  return [4 /*yield*/, this.request(reqParams)];
125
132
  case 1:
126
133
  res = _a.sent();
@@ -135,7 +142,7 @@ var ArtaClient = /** @class */ (function () {
135
142
  return __generator(this, function (_a) {
136
143
  switch (_a.label) {
137
144
  case 0:
138
- reqParams = this.makeReqParams(path, 'patch', auth, JSON.stringify(payload));
145
+ reqParams = this.makeReqParams(path, 'PATCH', auth, JSON.stringify(payload));
139
146
  return [4 /*yield*/, this.request(reqParams)];
140
147
  case 1:
141
148
  res = _a.sent();
@@ -148,7 +155,7 @@ var ArtaClient = /** @class */ (function () {
148
155
  return __awaiter(this, void 0, void 0, function () {
149
156
  return __generator(this, function (_a) {
150
157
  switch (_a.label) {
151
- 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))];
152
159
  case 1:
153
160
  _a.sent();
154
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 { type DatedInterface, type Nullable, type 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,18 +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, 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;
15
- }
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';
16
5
  export interface UnparsedInvoicePayment extends Omit<InvoicePayment, 'paid_on' | 'amount'> {
17
6
  paid_on: string;
18
7
  amount: string;
@@ -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,23 +1,7 @@
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;
20
- }
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';
21
5
  export interface UnparsedLog extends Omit<Log, 'start_at' | 'end_at'> {
22
6
  start_at: string;
23
7
  end_at: string;
@@ -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 {
@@ -1,17 +1,5 @@
1
- import { ArtaID } from '../ArtaClient';
2
- import { RestClient } from '../net/RestClient';
3
- import { DatedInterface, NullableString } from '../utils';
4
- export interface Organization extends DatedInterface {
5
- api_version: string;
6
- id: ArtaID;
7
- name: string;
8
- billing_terms?: NullableString;
9
- company_name?: NullableString;
10
- display_name?: NullableString;
11
- shortcode?: NullableString;
12
- status?: NullableString;
13
- stripe_customer_id?: NullableString;
14
- }
1
+ import type { RestClient } from '../net/RestClient';
2
+ import type { Organization } from '../types';
15
3
  export declare class OrganizationsEndpoint {
16
4
  private readonly artaClient;
17
5
  private readonly path;
@@ -1,15 +1,7 @@
1
- import { ArtaID } from '../ArtaClient';
2
- import { PaymentContext, SupportedCurrency } from '../MetadataTypes';
3
- import { RestClient } from '../net/RestClient';
4
- import { Page } from '../pagination';
5
- import { DatedInterface } from '../utils';
6
- export interface Payment extends DatedInterface {
7
- id: ArtaID;
8
- amount: number;
9
- amount_currency: SupportedCurrency;
10
- context: PaymentContext;
11
- paid_on: Date;
12
- }
1
+ import type { ArtaID } from '../ArtaClient';
2
+ import type { RestClient } from '../net/RestClient';
3
+ import type { Page } from '../pagination';
4
+ import type { Payment } from '../types';
13
5
  export interface UnparsedPayment extends Omit<Payment, 'paid_on' | 'amount'> {
14
6
  paid_on: string;
15
7
  amount: string;