kiriminaja 1.2.0 → 1.3.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 +45 -1
- package/dist/_shared/services.js +1 -1
- package/dist/_shared/services.js.map +1 -1
- package/dist/adapters/h3.d.ts +3 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +9 -1
- package/dist/index.mjs +30 -4
- package/dist/index.mjs.map +1 -1
- package/dist/services/coverage-area/pricing-express.d.ts +5 -1
- package/dist/services/coverage-area/pricing-instant.d.ts +4 -1
- package/dist/services/credit/balance.d.ts +2 -0
- package/dist/services/credit/index.d.ts +3 -0
- package/dist/services/index.d.ts +3 -0
- package/dist/types/courier.d.ts +18 -0
- package/dist/types/credit-responses.d.ts +7 -0
- package/dist/types/order.d.ts +19 -1
- package/dist/utils/volumetric.d.ts +15 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -96,7 +96,7 @@ await KiriminAja.coverageArea.pricingExpress({
|
|
|
96
96
|
weight: 1000, // grams
|
|
97
97
|
item_value: 50000,
|
|
98
98
|
insurance: 0,
|
|
99
|
-
courier: [
|
|
99
|
+
courier: [ExpressService.JNE, "other"],
|
|
100
100
|
});
|
|
101
101
|
|
|
102
102
|
// Instant (same-day) rates
|
|
@@ -147,6 +147,23 @@ await KiriminAja.order.express.requestPickup({
|
|
|
147
147
|
cod: 0,
|
|
148
148
|
package_type_id: 7,
|
|
149
149
|
item_name: "TEST Item name",
|
|
150
|
+
// `items` is optional. When provided, it lists the individual
|
|
151
|
+
// items inside the package. `item_value` is still required.
|
|
152
|
+
items: [
|
|
153
|
+
{
|
|
154
|
+
name: "Kaos Polos",
|
|
155
|
+
price: 125000,
|
|
156
|
+
qty: 2,
|
|
157
|
+
weight: 260,
|
|
158
|
+
width: 4,
|
|
159
|
+
length: 4,
|
|
160
|
+
height: 4,
|
|
161
|
+
metadata: {
|
|
162
|
+
sku: "KP-001",
|
|
163
|
+
variant_label: "Merah / L",
|
|
164
|
+
},
|
|
165
|
+
},
|
|
166
|
+
],
|
|
150
167
|
},
|
|
151
168
|
],
|
|
152
169
|
});
|
|
@@ -234,6 +251,33 @@ await KiriminAja.payment.getPayment(orderId);
|
|
|
234
251
|
|
|
235
252
|
---
|
|
236
253
|
|
|
254
|
+
### Credit
|
|
255
|
+
|
|
256
|
+
```ts
|
|
257
|
+
// Get the current KiriminAja credit balance
|
|
258
|
+
const res = await KiriminAja.credit.balance();
|
|
259
|
+
// res.data.balance -> number
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
### Utilities — Volumetric
|
|
263
|
+
|
|
264
|
+
Estimate the smallest bounding box (length / width / height) for a
|
|
265
|
+
multi-item package by trying three stacking strategies and returning the
|
|
266
|
+
arrangement with the smallest volume.
|
|
267
|
+
|
|
268
|
+
```ts
|
|
269
|
+
import { Volumetric } from "kiriminaja";
|
|
270
|
+
// or: import { calculate } from "kiriminaja";
|
|
271
|
+
|
|
272
|
+
const dim = Volumetric.calculate([
|
|
273
|
+
{ qty: 2, length: 10, width: 10, height: 2 },
|
|
274
|
+
{ qty: 1, length: 5, width: 5, height: 5 },
|
|
275
|
+
]);
|
|
276
|
+
// dim.length, dim.width, dim.height
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
---
|
|
280
|
+
|
|
237
281
|
## Nuxt / Nitro (h3 Adapter)
|
|
238
282
|
|
|
239
283
|
The `kiriminaja/adapters/h3` sub-package wraps `init()` into a Nitro server plugin and provides a `useKiriminAja()` composable for event handlers — no extra dependencies required.
|
package/dist/_shared/services.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var e=function(e){return e.SANDBOX=`sandbox`,e.PRODUCTION=`production`,e}({}),t={[e.SANDBOX]:`https://tdev.kiriminaja.com`,[e.PRODUCTION]:`https://client.kiriminaja.com`},n,r=({env:r=e.SANDBOX,baseUrl:i,apiKey:a,fetch:o,headers:s}={})=>{let c=o??globalThis.fetch;if(!c)throw Error(`Global fetch is not available. Provide Init({ fetch }) or use a runtime with fetch (Node 18+/Bun).`);return n={env:r,baseUrl:i??t[r],apiKey:a,fetch:c,headers:s},n},i=()=>{if(!n)throw Error(`KiriminAja SDK is not initialized. Call KiriminAja.init(), or use a framework adapter (e.g. defineKiriminAjaPlugin for h3/Nitro), or pass options directly to useKiriminAja().`);return n},a=(e,t)=>{let n=e.startsWith(`/`)?e:`/${e}`;return new URL(n,t)},o=async(e,t={})=>{let n=i(),r=a(e,n.baseUrl);if(t.query)for(let[e,n]of Object.entries(t.query))n!=null&&r.searchParams.set(e,String(n));let o=t.method??`POST`,s=t.body!==void 0&&o!==`GET`&&o!==`DELETE`,c=new Headers;if(c.set(`Accept`,`application/json`),s&&c.set(`Content-Type`,`application/json`),n.apiKey&&c.set(`Authorization`,`Bearer ${n.apiKey}`),n.headers&&new Headers(n.headers).forEach((e,t)=>{c.set(t,e)}),t.headers)for(let[e,n]of Object.entries(t.headers))c.set(e,n);let l=await n.fetch(r.toString(),{method:o,headers:c,...s?{body:JSON.stringify(t.body)}:{}});if(!l.ok)throw Error(`Request failed: ${l.status} ${l.statusText}`);return await l.json()},s=async(e,t,n={})=>o(e,{...n,method:`POST`,body:t}),c=async(e,t={})=>o(e,{...t,method:`GET`}),l=async(e,t={})=>o(e,{...t,method:`DELETE`}),u={provinces:()=>s(`/api/mitra/province`),cities:e=>s(`/api/mitra/city`,{provinsi_id:e}),districts:e=>s(`/api/mitra/kecamatan`,{kabupaten_id:e}),subDistricts:e=>s(`/api/mitra/kelurahan`,{kecamatan_id:e}),districtsByName:e=>s(`/api/mitra/v2/get_address_by_name`,{search:e})},d=e=>s(`/api/mitra/v6.1/shipping_price`,e),f=e=>s(`/api/mitra/v4/instant/pricing`,e),p={address:u,coverageArea:{...u,pricingExpress:d,pricingInstant:f},order:{express:{track:e=>s(`/api/mitra/tracking`,{order_id:e}),cancel:(e,t)=>o(`/api/mitra/v3/cancel_shipment`,{method:`POST`,query:{awb:e,reason:t}}),requestPickup:e=>s(`/api/mitra/v6.1/request_pickup`,e)},instant:{create:e=>s(`/api/mitra/v4/instant/pickup/request`,e),findNewDriver:e=>s(`/api/mitra/v4/instant/pickup/find-new-driver`,{order_id:e}),cancel:e=>l(`/api/mitra/v4/instant/pickup/void/${e}`),track:e=>c(`/api/mitra/v4/instant/tracking/${e}`)}},pickup:{schedules:()=>s(`/api/mitra/v2/schedules`)},payment:{getPayment:e=>s(`/api/mitra/v2/get_payment`,{payment_id:e})},courier:{list:()=>s(`/api/mitra/couriers`),group:()=>s(`/api/mitra/couriers_group`),detail:e=>s(`/api/mitra/courier_services`,{courier_code:e}),setWhitelistServices:e=>s(`/api/mitra/v3/set_whitelist_services`,{services:e})}};Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return e}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return r}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return p}});
|
|
1
|
+
var e=function(e){return e.SANDBOX=`sandbox`,e.PRODUCTION=`production`,e}({}),t={[e.SANDBOX]:`https://tdev.kiriminaja.com`,[e.PRODUCTION]:`https://client.kiriminaja.com`},n,r=({env:r=e.SANDBOX,baseUrl:i,apiKey:a,fetch:o,headers:s}={})=>{let c=o??globalThis.fetch;if(!c)throw Error(`Global fetch is not available. Provide Init({ fetch }) or use a runtime with fetch (Node 18+/Bun).`);return n={env:r,baseUrl:i??t[r],apiKey:a,fetch:c,headers:s},n},i=()=>{if(!n)throw Error(`KiriminAja SDK is not initialized. Call KiriminAja.init(), or use a framework adapter (e.g. defineKiriminAjaPlugin for h3/Nitro), or pass options directly to useKiriminAja().`);return n},a=(e,t)=>{let n=e.startsWith(`/`)?e:`/${e}`;return new URL(n,t)},o=async(e,t={})=>{let n=i(),r=a(e,n.baseUrl);if(t.query)for(let[e,n]of Object.entries(t.query))n!=null&&r.searchParams.set(e,String(n));let o=t.method??`POST`,s=t.body!==void 0&&o!==`GET`&&o!==`DELETE`,c=new Headers;if(c.set(`Accept`,`application/json`),s&&c.set(`Content-Type`,`application/json`),n.apiKey&&c.set(`Authorization`,`Bearer ${n.apiKey}`),n.headers&&new Headers(n.headers).forEach((e,t)=>{c.set(t,e)}),t.headers)for(let[e,n]of Object.entries(t.headers))c.set(e,n);let l=await n.fetch(r.toString(),{method:o,headers:c,...s?{body:JSON.stringify(t.body)}:{}});if(!l.ok)throw Error(`Request failed: ${l.status} ${l.statusText}`);return await l.json()},s=async(e,t,n={})=>o(e,{...n,method:`POST`,body:t}),c=async(e,t={})=>o(e,{...t,method:`GET`}),l=async(e,t={})=>o(e,{...t,method:`DELETE`}),u={provinces:()=>s(`/api/mitra/province`),cities:e=>s(`/api/mitra/city`,{provinsi_id:e}),districts:e=>s(`/api/mitra/kecamatan`,{kabupaten_id:e}),subDistricts:e=>s(`/api/mitra/kelurahan`,{kecamatan_id:e}),districtsByName:e=>s(`/api/mitra/v2/get_address_by_name`,{search:e})},d=e=>s(`/api/mitra/v6.1/shipping_price`,e),f=e=>s(`/api/mitra/v4/instant/pricing`,e),p={address:u,coverageArea:{...u,pricingExpress:d,pricingInstant:f},credit:{balance:()=>c(`/api/mitra/v6.2/credit/balance`)},order:{express:{track:e=>s(`/api/mitra/tracking`,{order_id:e}),cancel:(e,t)=>o(`/api/mitra/v3/cancel_shipment`,{method:`POST`,query:{awb:e,reason:t}}),requestPickup:e=>s(`/api/mitra/v6.1/request_pickup`,e)},instant:{create:e=>s(`/api/mitra/v4/instant/pickup/request`,e),findNewDriver:e=>s(`/api/mitra/v4/instant/pickup/find-new-driver`,{order_id:e}),cancel:e=>l(`/api/mitra/v4/instant/pickup/void/${e}`),track:e=>c(`/api/mitra/v4/instant/tracking/${e}`)}},pickup:{schedules:()=>s(`/api/mitra/v2/schedules`)},payment:{getPayment:e=>s(`/api/mitra/v2/get_payment`,{payment_id:e})},courier:{list:()=>s(`/api/mitra/couriers`),group:()=>s(`/api/mitra/couriers_group`),detail:e=>s(`/api/mitra/courier_services`,{courier_code:e}),setWhitelistServices:e=>s(`/api/mitra/v3/set_whitelist_services`,{services:e})}};Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return e}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return r}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return p}});
|
|
2
2
|
//# sourceMappingURL=services.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"services.js","names":[],"sources":["../../src/config/api.ts","../../src/config/client.ts","../../src/http/request.ts","../../src/services/address/province.ts","../../src/services/address/city.ts","../../src/services/address/district.ts","../../src/services/address/sub-district.ts","../../src/services/address/district-by-name.ts","../../src/services/address/index.ts","../../src/services/coverage-area/pricing-express.ts","../../src/services/coverage-area/pricing-instant.ts","../../src/services/coverage-area/index.ts","../../src/services/order/express/cancel.ts","../../src/services/order/express/request-pickup.ts","../../src/services/order/express/track.ts","../../src/services/order/instant/cancel.ts","../../src/services/order/instant/create.ts","../../src/services/order/instant/find-new-driver.ts","../../src/services/order/instant/track.ts","../../src/services/order/index.ts","../../src/services/pickup/schedules.ts","../../src/services/pickup/index.ts","../../src/services/payment/get-payment.ts","../../src/services/payment/index.ts","../../src/services/courier/detail.ts","../../src/services/courier/group.ts","../../src/services/courier/list.ts","../../src/services/courier/set-whitelist-services.ts","../../src/services/courier/index.ts","../../src/services/index.ts"],"sourcesContent":["export enum KAEnv {\n SANDBOX = \"sandbox\",\n PRODUCTION = \"production\",\n}\n\nexport const KA_ENV_URL: Record<KAEnv, string> = {\n [KAEnv.SANDBOX]: \"https://tdev.kiriminaja.com\",\n [KAEnv.PRODUCTION]: \"https://client.kiriminaja.com\",\n};\n","import { KA_ENV_URL, KAEnv } from \"./api\";\n\nexport type FetchLike = (\n input: Parameters<typeof fetch>[0],\n init?: Parameters<typeof fetch>[1],\n) => ReturnType<typeof fetch>;\n\nexport type HeadersInitLike =\n | Record<string, string>\n | Array<[string, string]>\n | Parameters<typeof fetch>[1];\n\nexport type InitOptions = {\n env?: KAEnv;\n baseUrl?: string;\n apiKey?: string;\n fetch?: FetchLike;\n headers?: HeadersInitLike;\n};\n\nexport type ClientConfig = {\n env: KAEnv;\n baseUrl: string;\n apiKey?: string;\n fetch: FetchLike;\n headers?: HeadersInitLike;\n};\n\nlet singletonConfig: ClientConfig | undefined;\n\nexport const init = ({\n env = KAEnv.SANDBOX,\n baseUrl,\n apiKey,\n fetch: fetchImpl,\n headers,\n}: InitOptions = {}): ClientConfig => {\n const resolvedFetch = fetchImpl ?? (globalThis as Record<string, unknown>).fetch as FetchLike | undefined;\n if (!resolvedFetch) {\n throw new Error(\n \"Global fetch is not available. Provide Init({ fetch }) or use a runtime with fetch (Node 18+/Bun).\",\n );\n }\n\n const resolvedBaseUrl = baseUrl ?? KA_ENV_URL[env];\n singletonConfig = {\n env,\n baseUrl: resolvedBaseUrl,\n apiKey,\n fetch: resolvedFetch,\n headers,\n };\n\n return singletonConfig;\n};\n\nexport const getConfig = (): ClientConfig => {\n if (!singletonConfig) {\n throw new Error(\n \"KiriminAja SDK is not initialized. Call KiriminAja.init(), or use a framework adapter (e.g. defineKiriminAjaPlugin for h3/Nitro), or pass options directly to useKiriminAja().\",\n );\n }\n return singletonConfig;\n};\n","import { getConfig } from \"../config/client\";\n\ntype RequestMethod = \"GET\" | \"POST\" | \"DELETE\";\n\ntype RequestOptions = {\n method?: RequestMethod;\n query?: Record<string, string | number | boolean | undefined | null>;\n body?: unknown;\n headers?: Record<string, string>;\n};\n\nconst buildUrl = (path: string, baseUrl: string) => {\n const normalizedPath = path.startsWith(\"/\") ? path : `/${path}`;\n return new URL(normalizedPath, baseUrl);\n};\n\nexport const requestJson = async <T>(\n path: string,\n options: RequestOptions = {},\n): Promise<T> => {\n const config = getConfig();\n const url = buildUrl(path, config.baseUrl);\n\n if (options.query) {\n for (const [key, value] of Object.entries(options.query)) {\n if (value === undefined || value === null) continue;\n url.searchParams.set(key, String(value));\n }\n }\n\n const method: RequestMethod = options.method ?? \"POST\";\n const hasJsonBody =\n options.body !== undefined && method !== \"GET\" && method !== \"DELETE\";\n\n const headers = new Headers();\n headers.set(\"Accept\", \"application/json\");\n if (hasJsonBody) headers.set(\"Content-Type\", \"application/json\");\n if (config.apiKey) headers.set(\"Authorization\", `Bearer ${config.apiKey}`);\n\n if (config.headers) {\n new Headers(config.headers as any).forEach((value, key) => {\n headers.set(key, value);\n });\n }\n\n if (options.headers) {\n for (const [key, value] of Object.entries(options.headers)) {\n headers.set(key, value);\n }\n }\n\n const response = await config.fetch(url.toString(), {\n method,\n headers,\n ...(hasJsonBody ? { body: JSON.stringify(options.body) } : {}),\n });\n\n if (!response.ok) {\n throw new Error(\n `Request failed: ${response.status} ${response.statusText}`,\n );\n }\n\n return (await response.json()) as T;\n};\n\nexport const postJson = async <T>(\n path: string,\n body?: unknown,\n options: Omit<RequestOptions, \"method\" | \"body\"> = {},\n): Promise<T> => {\n return requestJson<T>(path, { ...options, method: \"POST\", body });\n};\n\nexport const getJson = async <T>(\n path: string,\n options: Omit<RequestOptions, \"method\" | \"body\"> = {},\n): Promise<T> => {\n return requestJson<T>(path, { ...options, method: \"GET\" });\n};\n\nexport const deleteJson = async <T>(\n path: string,\n options: Omit<RequestOptions, \"method\" | \"body\"> = {},\n): Promise<T> => {\n return requestJson<T>(path, { ...options, method: \"DELETE\" });\n};\n","import type { ProvinceListResponse } from \"../../types/coverage-area-responses\";\nimport { postJson } from \"../../http/request\";\n\nexport const getProvinces = () => {\n return postJson<ProvinceListResponse>(\"/api/mitra/province\");\n};\n","import type { CityListResponse } from \"../../types/coverage-area-responses\";\nimport { postJson } from \"../../http/request\";\n\nexport const getCities = (provinsiId: number) => {\n return postJson<CityListResponse>(\"/api/mitra/city\", {\n provinsi_id: provinsiId,\n });\n};\n","import type { DistrictListResponse } from \"../../types/coverage-area-responses\";\nimport { postJson } from \"../../http/request\";\n\nexport const getDistricts = (kabupatenId: number) => {\n return postJson<DistrictListResponse>(\"/api/mitra/kecamatan\", {\n kabupaten_id: kabupatenId,\n });\n};\n","import type { SubDistrictListResponse } from \"../../types/coverage-area-responses\";\nimport { postJson } from \"../../http/request\";\n\nexport const getSubDistricts = (kecamatanId: number) => {\n return postJson<SubDistrictListResponse>(\"/api/mitra/kelurahan\", {\n kecamatan_id: kecamatanId,\n });\n};\n","import type { DistrictByNameResponse } from \"../../types/coverage-area-responses\";\nimport { postJson } from \"../../http/request\";\n\nexport const getDistrictsByName = (search: string) => {\n return postJson<DistrictByNameResponse>(\n \"/api/mitra/v2/get_address_by_name\",\n {\n search,\n },\n );\n};\n","import { getProvinces } from \"./province\";\nimport { getCities } from \"./city\";\nimport { getDistricts } from \"./district\";\nimport { getSubDistricts } from \"./sub-district\";\nimport { getDistrictsByName } from \"./district-by-name\";\n\nexport const address = {\n provinces: getProvinces,\n cities: getCities,\n districts: getDistricts,\n subDistricts: getSubDistricts,\n districtsByName: getDistrictsByName,\n};\n","import type { KAResponse } from \"../../types/api-response\";\nimport { postJson } from \"../../http/request\";\n\nexport type PricingExpressPayload = {\n origin: number;\n destination: number;\n weight: number;\n item_value: string | number;\n insurance: number;\n courier: string[];\n};\n\nexport const getPricingExpress = <T = unknown>(\n payload: PricingExpressPayload,\n) => {\n return postJson<KAResponse<T>>(\"/api/mitra/v6.1/shipping_price\", payload);\n};\n","import type { KAResponse } from \"../../types/api-response\";\nimport { postJson } from \"../../http/request\";\nimport type { InstantService } from \"@/types/courier\";\n\nexport type PricingInstantPayload = {\n service: InstantService[];\n item_price: number;\n origin: {\n lat: number;\n long: number;\n address: string;\n };\n destination: {\n lat: number;\n long: number;\n address: string;\n };\n weight: number;\n vehicle: \"motor\" | \"mobil\";\n timezone: string;\n};\n\nexport const getPricingInstant = <T = unknown>(\n payload: PricingInstantPayload,\n) => {\n return postJson<KAResponse<T>>(\"/api/mitra/v4/instant/pricing\", payload);\n};\n","import { getPricingExpress } from \"./pricing-express\";\nimport { getPricingInstant } from \"./pricing-instant\";\nimport { address } from \"../address/index\";\n\nexport const coverageArea = {\n ...address,\n pricingExpress: getPricingExpress,\n pricingInstant: getPricingInstant,\n};\n","import type { CancelExpressOrderResponse } from \"../../../types/order-responses\";\nimport { requestJson } from \"../../../http/request\";\n\nexport const cancelExpressOrder = (awb: string, reason: string) =>\n requestJson<CancelExpressOrderResponse>(\"/api/mitra/v3/cancel_shipment\", {\n method: \"POST\",\n query: {\n awb,\n reason,\n },\n });\n","import type { KAResponse } from \"../../../types/api-response\";\nimport type { RequestPickupPayload } from \"../../../types/order\";\nimport { postJson } from \"../../../http/request\";\n\nexport const requestPickup = (payload: RequestPickupPayload) =>\n postJson<KAResponse<unknown>>(\"/api/mitra/v6.1/request_pickup\", payload);\n","import type { ExpressTrackingResponse } from \"../../../types/order-responses\";\nimport { postJson } from \"../../../http/request\";\n\nexport const trackExpressOrder = (orderId: string) =>\n postJson<ExpressTrackingResponse>(\"/api/mitra/tracking\", {\n order_id: orderId,\n });\n","import type { CancelInstantOrderResponse } from \"../../../types/order-responses\";\nimport { deleteJson } from \"../../../http/request\";\n\nexport const cancelInstantOrder = (orderId: string) =>\n deleteJson<CancelInstantOrderResponse>(\n `/api/mitra/v4/instant/pickup/void/${orderId}`,\n );\n","import type { CreateInstantPickupResponse } from \"../../../types/order-responses\";\nimport type { InstantPickupPayload } from \"../../../types/order\";\nimport { postJson } from \"../../../http/request\";\n\nexport const createInstantPickup = (payload: InstantPickupPayload) =>\n postJson<CreateInstantPickupResponse>(\n \"/api/mitra/v4/instant/pickup/request\",\n payload,\n );\n","import type { FindNewInstantDriverResponse } from \"../../../types/order-responses\";\nimport { postJson } from \"../../../http/request\";\n\nexport const findNewInstantDriver = (orderId: string) =>\n postJson<FindNewInstantDriverResponse>(\n \"/api/mitra/v4/instant/pickup/find-new-driver\",\n {\n order_id: orderId,\n },\n );\n","import type { InstantTrackingResponse } from \"../../../types/order-responses\";\nimport { getJson } from \"../../../http/request\";\n\nexport const trackInstantOrder = (orderId: string) =>\n getJson<InstantTrackingResponse>(\n `/api/mitra/v4/instant/tracking/${orderId}`,\n );\n","import {\n cancelExpressOrder,\n requestPickup,\n trackExpressOrder,\n} from \"./express\";\nimport {\n cancelInstantOrder,\n createInstantPickup,\n findNewInstantDriver,\n trackInstantOrder,\n} from \"./instant\";\n\nexport const order = {\n express: {\n track: trackExpressOrder,\n cancel: cancelExpressOrder,\n requestPickup,\n },\n instant: {\n create: createInstantPickup,\n findNewDriver: findNewInstantDriver,\n cancel: cancelInstantOrder,\n track: trackInstantOrder,\n },\n};\n","import type { PickupSchedulesResponse } from \"@/types/pickup-responses\";\nimport { postJson } from \"@/http/request\";\n\nexport const getPickupSchedules = () =>\n postJson<PickupSchedulesResponse>(\"/api/mitra/v2/schedules\");\n","import { getPickupSchedules } from \"./schedules\";\n\nexport const pickup = {\n schedules: getPickupSchedules,\n};\n","import type { GetPaymentResponse } from \"../../types/payment-responses\";\nimport { postJson } from \"../../http/request\";\n\nexport const getPayment = (paymentId: string) =>\n postJson<GetPaymentResponse>(\"/api/mitra/v2/get_payment\", {\n payment_id: paymentId,\n });\n","import { getPayment } from \"./get-payment\";\n\nexport const payment = {\n getPayment,\n};\n","import type { CourierDetailResponse } from \"../../types/courier\";\nimport { postJson } from \"../../http/request\";\n\nexport const getCourierDetail = (courierCode: string) =>\n postJson<CourierDetailResponse>(\"/api/mitra/courier_services\", {\n courier_code: courierCode,\n });\n","import type { CourierGroupResponse } from \"../../types/courier\";\nimport { postJson } from \"../../http/request\";\n\nexport const getCourierGroups = () =>\n postJson<CourierGroupResponse>(\"/api/mitra/couriers_group\");\n","import type { CourierListResponse } from \"../../types/courier\";\nimport { postJson } from \"../../http/request\";\n\nexport const listCouriers = () =>\n postJson<CourierListResponse>(\"/api/mitra/couriers\");\n","import type { SetCourierPreferenceResponse } from \"../../types/courier\";\nimport { postJson } from \"../../http/request\";\n\nexport const setWhitelistServices = (services: string[]) =>\n postJson<SetCourierPreferenceResponse>(\n \"/api/mitra/v3/set_whitelist_services\",\n {\n services,\n },\n );\n","import { getCourierDetail } from \"./detail\";\nimport { getCourierGroups } from \"./group\";\nimport { listCouriers } from \"./list\";\nimport { setWhitelistServices } from \"./set-whitelist-services\";\n\nexport const courier = {\n list: listCouriers,\n group: getCourierGroups,\n detail: getCourierDetail,\n setWhitelistServices,\n};\n","import { address } from \"./address/index\";\nimport { coverageArea } from \"./coverage-area/index\";\nimport { order } from \"./order/index\";\nimport { pickup } from \"./pickup/index\";\nimport { payment } from \"./payment/index\";\nimport { courier } from \"./courier/index\";\n\nexport const services = {\n address,\n coverageArea,\n order,\n pickup,\n payment,\n courier,\n};\n"],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"services.js","names":[],"sources":["../../src/config/api.ts","../../src/config/client.ts","../../src/http/request.ts","../../src/services/address/province.ts","../../src/services/address/city.ts","../../src/services/address/district.ts","../../src/services/address/sub-district.ts","../../src/services/address/district-by-name.ts","../../src/services/address/index.ts","../../src/services/coverage-area/pricing-express.ts","../../src/services/coverage-area/pricing-instant.ts","../../src/services/coverage-area/index.ts","../../src/services/credit/balance.ts","../../src/services/credit/index.ts","../../src/services/order/express/cancel.ts","../../src/services/order/express/request-pickup.ts","../../src/services/order/express/track.ts","../../src/services/order/instant/cancel.ts","../../src/services/order/instant/create.ts","../../src/services/order/instant/find-new-driver.ts","../../src/services/order/instant/track.ts","../../src/services/order/index.ts","../../src/services/pickup/schedules.ts","../../src/services/pickup/index.ts","../../src/services/payment/get-payment.ts","../../src/services/payment/index.ts","../../src/services/courier/detail.ts","../../src/services/courier/group.ts","../../src/services/courier/list.ts","../../src/services/courier/set-whitelist-services.ts","../../src/services/courier/index.ts","../../src/services/index.ts"],"sourcesContent":["export enum KAEnv {\n SANDBOX = \"sandbox\",\n PRODUCTION = \"production\",\n}\n\nexport const KA_ENV_URL: Record<KAEnv, string> = {\n [KAEnv.SANDBOX]: \"https://tdev.kiriminaja.com\",\n [KAEnv.PRODUCTION]: \"https://client.kiriminaja.com\",\n};\n","import { KA_ENV_URL, KAEnv } from \"./api\";\n\nexport type FetchLike = (\n input: Parameters<typeof fetch>[0],\n init?: Parameters<typeof fetch>[1],\n) => ReturnType<typeof fetch>;\n\nexport type HeadersInitLike =\n | Record<string, string>\n | Array<[string, string]>\n | Parameters<typeof fetch>[1];\n\nexport type InitOptions = {\n env?: KAEnv;\n baseUrl?: string;\n apiKey?: string;\n fetch?: FetchLike;\n headers?: HeadersInitLike;\n};\n\nexport type ClientConfig = {\n env: KAEnv;\n baseUrl: string;\n apiKey?: string;\n fetch: FetchLike;\n headers?: HeadersInitLike;\n};\n\nlet singletonConfig: ClientConfig | undefined;\n\nexport const init = ({\n env = KAEnv.SANDBOX,\n baseUrl,\n apiKey,\n fetch: fetchImpl,\n headers,\n}: InitOptions = {}): ClientConfig => {\n const resolvedFetch = fetchImpl ?? (globalThis as Record<string, unknown>).fetch as FetchLike | undefined;\n if (!resolvedFetch) {\n throw new Error(\n \"Global fetch is not available. Provide Init({ fetch }) or use a runtime with fetch (Node 18+/Bun).\",\n );\n }\n\n const resolvedBaseUrl = baseUrl ?? KA_ENV_URL[env];\n singletonConfig = {\n env,\n baseUrl: resolvedBaseUrl,\n apiKey,\n fetch: resolvedFetch,\n headers,\n };\n\n return singletonConfig;\n};\n\nexport const getConfig = (): ClientConfig => {\n if (!singletonConfig) {\n throw new Error(\n \"KiriminAja SDK is not initialized. Call KiriminAja.init(), or use a framework adapter (e.g. defineKiriminAjaPlugin for h3/Nitro), or pass options directly to useKiriminAja().\",\n );\n }\n return singletonConfig;\n};\n","import { getConfig } from \"../config/client\";\n\ntype RequestMethod = \"GET\" | \"POST\" | \"DELETE\";\n\ntype RequestOptions = {\n method?: RequestMethod;\n query?: Record<string, string | number | boolean | undefined | null>;\n body?: unknown;\n headers?: Record<string, string>;\n};\n\nconst buildUrl = (path: string, baseUrl: string) => {\n const normalizedPath = path.startsWith(\"/\") ? path : `/${path}`;\n return new URL(normalizedPath, baseUrl);\n};\n\nexport const requestJson = async <T>(\n path: string,\n options: RequestOptions = {},\n): Promise<T> => {\n const config = getConfig();\n const url = buildUrl(path, config.baseUrl);\n\n if (options.query) {\n for (const [key, value] of Object.entries(options.query)) {\n if (value === undefined || value === null) continue;\n url.searchParams.set(key, String(value));\n }\n }\n\n const method: RequestMethod = options.method ?? \"POST\";\n const hasJsonBody =\n options.body !== undefined && method !== \"GET\" && method !== \"DELETE\";\n\n const headers = new Headers();\n headers.set(\"Accept\", \"application/json\");\n if (hasJsonBody) headers.set(\"Content-Type\", \"application/json\");\n if (config.apiKey) headers.set(\"Authorization\", `Bearer ${config.apiKey}`);\n\n if (config.headers) {\n new Headers(config.headers as any).forEach((value, key) => {\n headers.set(key, value);\n });\n }\n\n if (options.headers) {\n for (const [key, value] of Object.entries(options.headers)) {\n headers.set(key, value);\n }\n }\n\n const response = await config.fetch(url.toString(), {\n method,\n headers,\n ...(hasJsonBody ? { body: JSON.stringify(options.body) } : {}),\n });\n\n if (!response.ok) {\n throw new Error(\n `Request failed: ${response.status} ${response.statusText}`,\n );\n }\n\n return (await response.json()) as T;\n};\n\nexport const postJson = async <T>(\n path: string,\n body?: unknown,\n options: Omit<RequestOptions, \"method\" | \"body\"> = {},\n): Promise<T> => {\n return requestJson<T>(path, { ...options, method: \"POST\", body });\n};\n\nexport const getJson = async <T>(\n path: string,\n options: Omit<RequestOptions, \"method\" | \"body\"> = {},\n): Promise<T> => {\n return requestJson<T>(path, { ...options, method: \"GET\" });\n};\n\nexport const deleteJson = async <T>(\n path: string,\n options: Omit<RequestOptions, \"method\" | \"body\"> = {},\n): Promise<T> => {\n return requestJson<T>(path, { ...options, method: \"DELETE\" });\n};\n","import type { ProvinceListResponse } from \"../../types/coverage-area-responses\";\nimport { postJson } from \"../../http/request\";\n\nexport const getProvinces = () => {\n return postJson<ProvinceListResponse>(\"/api/mitra/province\");\n};\n","import type { CityListResponse } from \"../../types/coverage-area-responses\";\nimport { postJson } from \"../../http/request\";\n\nexport const getCities = (provinsiId: number) => {\n return postJson<CityListResponse>(\"/api/mitra/city\", {\n provinsi_id: provinsiId,\n });\n};\n","import type { DistrictListResponse } from \"../../types/coverage-area-responses\";\nimport { postJson } from \"../../http/request\";\n\nexport const getDistricts = (kabupatenId: number) => {\n return postJson<DistrictListResponse>(\"/api/mitra/kecamatan\", {\n kabupaten_id: kabupatenId,\n });\n};\n","import type { SubDistrictListResponse } from \"../../types/coverage-area-responses\";\nimport { postJson } from \"../../http/request\";\n\nexport const getSubDistricts = (kecamatanId: number) => {\n return postJson<SubDistrictListResponse>(\"/api/mitra/kelurahan\", {\n kecamatan_id: kecamatanId,\n });\n};\n","import type { DistrictByNameResponse } from \"../../types/coverage-area-responses\";\nimport { postJson } from \"../../http/request\";\n\nexport const getDistrictsByName = (search: string) => {\n return postJson<DistrictByNameResponse>(\n \"/api/mitra/v2/get_address_by_name\",\n {\n search,\n },\n );\n};\n","import { getProvinces } from \"./province\";\nimport { getCities } from \"./city\";\nimport { getDistricts } from \"./district\";\nimport { getSubDistricts } from \"./sub-district\";\nimport { getDistrictsByName } from \"./district-by-name\";\n\nexport const address = {\n provinces: getProvinces,\n cities: getCities,\n districts: getDistricts,\n subDistricts: getSubDistricts,\n districtsByName: getDistrictsByName,\n};\n","import type { KAResponse } from \"../../types/api-response\";\nimport { postJson } from \"../../http/request\";\nimport type { ExpressService } from \"@/types/courier\";\n\nexport type PricingExpressPayload = {\n origin: number;\n destination: number;\n weight: number;\n item_value: string | number;\n insurance: number;\n\n /**\n * @description Use string for custom courier codes that not provided in ExpressService enum\n */\n courier: (ExpressService | string)[];\n};\n\nexport const getPricingExpress = <T = unknown>(\n payload: PricingExpressPayload,\n) => {\n return postJson<KAResponse<T>>(\"/api/mitra/v6.1/shipping_price\", payload);\n};\n","import type { KAResponse } from \"../../types/api-response\";\nimport { postJson } from \"../../http/request\";\nimport type { InstantService } from \"@/types/courier\";\n\nexport type PricingInstantPayload = {\n /**\n * @description Use string for custom courier codes that not provided in InstantService enum\n */\n service: (InstantService | string)[];\n item_price: number;\n origin: {\n lat: number;\n long: number;\n address: string;\n };\n destination: {\n lat: number;\n long: number;\n address: string;\n };\n weight: number;\n vehicle: \"motor\" | \"mobil\";\n timezone: string;\n};\n\nexport const getPricingInstant = <T = unknown>(\n payload: PricingInstantPayload,\n) => {\n return postJson<KAResponse<T>>(\"/api/mitra/v4/instant/pricing\", payload);\n};\n","import { getPricingExpress } from \"./pricing-express\";\nimport { getPricingInstant } from \"./pricing-instant\";\nimport { address } from \"../address/index\";\n\nexport const coverageArea = {\n ...address,\n pricingExpress: getPricingExpress,\n pricingInstant: getPricingInstant,\n};\n","import type { CreditBalanceResponse } from \"../../types/credit-responses\";\nimport { getJson } from \"../../http/request\";\n\nexport const balance = () =>\n getJson<CreditBalanceResponse>(\"/api/mitra/v6.2/credit/balance\");\n","import { balance } from \"./balance\";\n\nexport const credit = {\n balance,\n};\n","import type { CancelExpressOrderResponse } from \"../../../types/order-responses\";\nimport { requestJson } from \"../../../http/request\";\n\nexport const cancelExpressOrder = (awb: string, reason: string) =>\n requestJson<CancelExpressOrderResponse>(\"/api/mitra/v3/cancel_shipment\", {\n method: \"POST\",\n query: {\n awb,\n reason,\n },\n });\n","import type { KAResponse } from \"../../../types/api-response\";\nimport type { RequestPickupPayload } from \"../../../types/order\";\nimport { postJson } from \"../../../http/request\";\n\nexport const requestPickup = (payload: RequestPickupPayload) =>\n postJson<KAResponse<unknown>>(\"/api/mitra/v6.1/request_pickup\", payload);\n","import type { ExpressTrackingResponse } from \"../../../types/order-responses\";\nimport { postJson } from \"../../../http/request\";\n\nexport const trackExpressOrder = (orderId: string) =>\n postJson<ExpressTrackingResponse>(\"/api/mitra/tracking\", {\n order_id: orderId,\n });\n","import type { CancelInstantOrderResponse } from \"../../../types/order-responses\";\nimport { deleteJson } from \"../../../http/request\";\n\nexport const cancelInstantOrder = (orderId: string) =>\n deleteJson<CancelInstantOrderResponse>(\n `/api/mitra/v4/instant/pickup/void/${orderId}`,\n );\n","import type { CreateInstantPickupResponse } from \"../../../types/order-responses\";\nimport type { InstantPickupPayload } from \"../../../types/order\";\nimport { postJson } from \"../../../http/request\";\n\nexport const createInstantPickup = (payload: InstantPickupPayload) =>\n postJson<CreateInstantPickupResponse>(\n \"/api/mitra/v4/instant/pickup/request\",\n payload,\n );\n","import type { FindNewInstantDriverResponse } from \"../../../types/order-responses\";\nimport { postJson } from \"../../../http/request\";\n\nexport const findNewInstantDriver = (orderId: string) =>\n postJson<FindNewInstantDriverResponse>(\n \"/api/mitra/v4/instant/pickup/find-new-driver\",\n {\n order_id: orderId,\n },\n );\n","import type { InstantTrackingResponse } from \"../../../types/order-responses\";\nimport { getJson } from \"../../../http/request\";\n\nexport const trackInstantOrder = (orderId: string) =>\n getJson<InstantTrackingResponse>(\n `/api/mitra/v4/instant/tracking/${orderId}`,\n );\n","import {\n cancelExpressOrder,\n requestPickup,\n trackExpressOrder,\n} from \"./express\";\nimport {\n cancelInstantOrder,\n createInstantPickup,\n findNewInstantDriver,\n trackInstantOrder,\n} from \"./instant\";\n\nexport const order = {\n express: {\n track: trackExpressOrder,\n cancel: cancelExpressOrder,\n requestPickup,\n },\n instant: {\n create: createInstantPickup,\n findNewDriver: findNewInstantDriver,\n cancel: cancelInstantOrder,\n track: trackInstantOrder,\n },\n};\n","import type { PickupSchedulesResponse } from \"@/types/pickup-responses\";\nimport { postJson } from \"@/http/request\";\n\nexport const getPickupSchedules = () =>\n postJson<PickupSchedulesResponse>(\"/api/mitra/v2/schedules\");\n","import { getPickupSchedules } from \"./schedules\";\n\nexport const pickup = {\n schedules: getPickupSchedules,\n};\n","import type { GetPaymentResponse } from \"../../types/payment-responses\";\nimport { postJson } from \"../../http/request\";\n\nexport const getPayment = (paymentId: string) =>\n postJson<GetPaymentResponse>(\"/api/mitra/v2/get_payment\", {\n payment_id: paymentId,\n });\n","import { getPayment } from \"./get-payment\";\n\nexport const payment = {\n getPayment,\n};\n","import type { CourierDetailResponse } from \"../../types/courier\";\nimport { postJson } from \"../../http/request\";\n\nexport const getCourierDetail = (courierCode: string) =>\n postJson<CourierDetailResponse>(\"/api/mitra/courier_services\", {\n courier_code: courierCode,\n });\n","import type { CourierGroupResponse } from \"../../types/courier\";\nimport { postJson } from \"../../http/request\";\n\nexport const getCourierGroups = () =>\n postJson<CourierGroupResponse>(\"/api/mitra/couriers_group\");\n","import type { CourierListResponse } from \"../../types/courier\";\nimport { postJson } from \"../../http/request\";\n\nexport const listCouriers = () =>\n postJson<CourierListResponse>(\"/api/mitra/couriers\");\n","import type { SetCourierPreferenceResponse } from \"../../types/courier\";\nimport { postJson } from \"../../http/request\";\n\nexport const setWhitelistServices = (services: string[]) =>\n postJson<SetCourierPreferenceResponse>(\n \"/api/mitra/v3/set_whitelist_services\",\n {\n services,\n },\n );\n","import { getCourierDetail } from \"./detail\";\nimport { getCourierGroups } from \"./group\";\nimport { listCouriers } from \"./list\";\nimport { setWhitelistServices } from \"./set-whitelist-services\";\n\nexport const courier = {\n list: listCouriers,\n group: getCourierGroups,\n detail: getCourierDetail,\n setWhitelistServices,\n};\n","import { address } from \"./address/index\";\nimport { coverageArea } from \"./coverage-area/index\";\nimport { credit } from \"./credit/index\";\nimport { order } from \"./order/index\";\nimport { pickup } from \"./pickup/index\";\nimport { payment } from \"./payment/index\";\nimport { courier } from \"./courier/index\";\n\nexport const services = {\n address,\n coverageArea,\n credit,\n order,\n pickup,\n payment,\n courier,\n};\n"],"mappings":"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"}
|
package/dist/adapters/h3.d.ts
CHANGED
|
@@ -103,6 +103,9 @@ export declare const useKiriminAja: (options?: UseKiriminAjaOptions) => {
|
|
|
103
103
|
subDistricts: (kecamatanId: number) => Promise<import('../types/coverage-area-responses').SubDistrictListResponse>;
|
|
104
104
|
districtsByName: (search: string) => Promise<import('../types/coverage-area-responses').DistrictByNameResponse>;
|
|
105
105
|
};
|
|
106
|
+
credit: {
|
|
107
|
+
balance: () => Promise<import('../types/credit-responses').CreditBalanceResponse>;
|
|
108
|
+
};
|
|
106
109
|
order: {
|
|
107
110
|
express: {
|
|
108
111
|
track: (orderId: string) => Promise<import('../types/order-responses').ExpressTrackingResponse>;
|
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require(`./_shared/services.js`);var t={init:e.r,Init:e.r,...e.t};exports.KAEnv=e.i,exports.default=
|
|
1
|
+
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require(`./_shared/services.js`);var t=e=>{if(!e||e.length===0)return{length:0,width:0,height:0};let t=0,n=0,r=0,i=0,a=0,o=0,s=0,c=0,l=0;for(let u of e){let e=u.qty<1?1:u.qty,d=u.length,f=u.width,p=u.height;r+=p*e,d>t&&(t=d),f>n&&(n=f),i+=d*e,p>o&&(o=p),f>a&&(a=f),c+=f*e,p>l&&(l=p),d>s&&(s=d)}let u=t*n*r,d=i*a*o,f=s*c*l;return u<=d&&u<=f?{length:t,width:n,height:r}:d<=f?{length:i,width:a,height:o}:{length:s,width:c,height:l}},n={calculate:t},r={init:e.r,Init:e.r,...e.t,Volumetric:n};exports.KAEnv=e.i,exports.Volumetric=n,exports.calculate=t,exports.default=r;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["import { KAEnv } from \"./config/api\";\nimport { init } from \"./config/client\";\nimport { services } from \"./services/index\";\n\nexport { KAEnv };\n\nconst KiriminAja = {\n init,\n Init: init,\n ...services,\n};\n\nexport default KiriminAja;\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.cjs","names":[],"sources":["../src/utils/volumetric.ts","../src/index.ts"],"sourcesContent":["export interface VolumetricItem {\n qty: number;\n length: number;\n width: number;\n height: number;\n}\n\nexport interface Dimensions {\n length: number;\n width: number;\n height: number;\n}\n\nexport const calculate = (items: VolumetricItem[]): Dimensions => {\n if (!items || items.length === 0) {\n return { length: 0, width: 0, height: 0 };\n }\n\n let lVert = 0,\n wVert = 0,\n hVert = 0;\n let lHor = 0,\n wHor = 0,\n hHor = 0;\n let lSide = 0,\n wSide = 0,\n hSide = 0;\n\n for (const it of items) {\n const qty = it.qty < 1 ? 1 : it.qty;\n const l = it.length;\n const w = it.width;\n const h = it.height;\n\n // Vertical stacking: heights add up\n hVert += h * qty;\n if (l > lVert) lVert = l;\n if (w > wVert) wVert = w;\n\n // Horizontal stacking: lengths add up\n lHor += l * qty;\n if (h > hHor) hHor = h;\n if (w > wHor) wHor = w;\n\n // Side-by-side stacking: widths add up\n wSide += w * qty;\n if (h > hSide) hSide = h;\n if (l > lSide) lSide = l;\n }\n\n const volVert = lVert * wVert * hVert;\n const volHor = lHor * wHor * hHor;\n const volSide = lSide * wSide * hSide;\n\n if (volVert <= volHor && volVert <= volSide) {\n return { length: lVert, width: wVert, height: hVert };\n }\n if (volHor <= volSide) {\n return { length: lHor, width: wHor, height: hHor };\n }\n return { length: lSide, width: wSide, height: hSide };\n};\n\nexport const Volumetric = { calculate };\n","import { KAEnv } from \"./config/api\";\nimport { init } from \"./config/client\";\nimport { services } from \"./services/index\";\nimport { Volumetric } from \"./utils/volumetric\";\n\nexport { KAEnv, Volumetric };\nexport * from \"./utils/volumetric\";\n\nconst KiriminAja = {\n init,\n Init: init,\n ...services,\n Volumetric,\n};\n\nexport default KiriminAja;\n"],"mappings":"wIAaA,IAAa,EAAa,GAAwC,CAC9D,GAAI,CAAC,GAAS,EAAM,SAAW,EAC3B,MAAO,CAAE,OAAQ,EAAG,MAAO,EAAG,OAAQ,EAAG,CAG7C,IAAI,EAAQ,EACR,EAAQ,EACR,EAAQ,EACR,EAAO,EACP,EAAO,EACP,EAAO,EACP,EAAQ,EACR,EAAQ,EACR,EAAQ,EAEZ,IAAK,IAAM,KAAM,EAAO,CACpB,IAAM,EAAM,EAAG,IAAM,EAAI,EAAI,EAAG,IAC1B,EAAI,EAAG,OACP,EAAI,EAAG,MACP,EAAI,EAAG,OAGb,GAAS,EAAI,EACT,EAAI,IAAO,EAAQ,GACnB,EAAI,IAAO,EAAQ,GAGvB,GAAQ,EAAI,EACR,EAAI,IAAM,EAAO,GACjB,EAAI,IAAM,EAAO,GAGrB,GAAS,EAAI,EACT,EAAI,IAAO,EAAQ,GACnB,EAAI,IAAO,EAAQ,GAG3B,IAAM,EAAU,EAAQ,EAAQ,EAC1B,EAAS,EAAO,EAAO,EACvB,EAAU,EAAQ,EAAQ,EAQhC,OANI,GAAW,GAAU,GAAW,EACzB,CAAE,OAAQ,EAAO,MAAO,EAAO,OAAQ,EAAO,CAErD,GAAU,EACH,CAAE,OAAQ,EAAM,MAAO,EAAM,OAAQ,EAAM,CAE/C,CAAE,OAAQ,EAAO,MAAO,EAAO,OAAQ,EAAO,EAG5C,EAAa,CAAE,YAAW,CCvDjC,EAAa,CACf,KAAA,EAAA,EACA,KAAM,EAAA,EACN,GAAG,EAAA,EACH,aACH"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { KAEnv } from './config/api';
|
|
2
|
-
|
|
2
|
+
import { Volumetric } from './utils/volumetric';
|
|
3
|
+
export { KAEnv, Volumetric };
|
|
4
|
+
export * from './utils/volumetric';
|
|
3
5
|
declare const KiriminAja: {
|
|
6
|
+
Volumetric: {
|
|
7
|
+
calculate: (items: import('.').VolumetricItem[]) => import('.').Dimensions;
|
|
8
|
+
};
|
|
4
9
|
address: {
|
|
5
10
|
provinces: () => Promise<import('./types/coverage-area-responses').ProvinceListResponse>;
|
|
6
11
|
cities: (provinsiId: number) => Promise<import('./types/coverage-area-responses').CityListResponse>;
|
|
@@ -17,6 +22,9 @@ declare const KiriminAja: {
|
|
|
17
22
|
subDistricts: (kecamatanId: number) => Promise<import('./types/coverage-area-responses').SubDistrictListResponse>;
|
|
18
23
|
districtsByName: (search: string) => Promise<import('./types/coverage-area-responses').DistrictByNameResponse>;
|
|
19
24
|
};
|
|
25
|
+
credit: {
|
|
26
|
+
balance: () => Promise<import('./types/credit-responses').CreditBalanceResponse>;
|
|
27
|
+
};
|
|
20
28
|
order: {
|
|
21
29
|
express: {
|
|
22
30
|
track: (orderId: string) => Promise<import('./types/order-responses').ExpressTrackingResponse>;
|
package/dist/index.mjs
CHANGED
|
@@ -1,11 +1,37 @@
|
|
|
1
1
|
import { i as e, r as t, t as n } from "./_shared/services.js";
|
|
2
|
-
//#region src/
|
|
3
|
-
var r = {
|
|
2
|
+
//#region src/utils/volumetric.ts
|
|
3
|
+
var r = (e) => {
|
|
4
|
+
if (!e || e.length === 0) return {
|
|
5
|
+
length: 0,
|
|
6
|
+
width: 0,
|
|
7
|
+
height: 0
|
|
8
|
+
};
|
|
9
|
+
let t = 0, n = 0, r = 0, i = 0, a = 0, o = 0, s = 0, c = 0, l = 0;
|
|
10
|
+
for (let u of e) {
|
|
11
|
+
let e = u.qty < 1 ? 1 : u.qty, d = u.length, f = u.width, p = u.height;
|
|
12
|
+
r += p * e, d > t && (t = d), f > n && (n = f), i += d * e, p > o && (o = p), f > a && (a = f), c += f * e, p > l && (l = p), d > s && (s = d);
|
|
13
|
+
}
|
|
14
|
+
let u = t * n * r, d = i * a * o, f = s * c * l;
|
|
15
|
+
return u <= d && u <= f ? {
|
|
16
|
+
length: t,
|
|
17
|
+
width: n,
|
|
18
|
+
height: r
|
|
19
|
+
} : d <= f ? {
|
|
20
|
+
length: i,
|
|
21
|
+
width: a,
|
|
22
|
+
height: o
|
|
23
|
+
} : {
|
|
24
|
+
length: s,
|
|
25
|
+
width: c,
|
|
26
|
+
height: l
|
|
27
|
+
};
|
|
28
|
+
}, i = { calculate: r }, a = {
|
|
4
29
|
init: t,
|
|
5
30
|
Init: t,
|
|
6
|
-
...n
|
|
31
|
+
...n,
|
|
32
|
+
Volumetric: i
|
|
7
33
|
};
|
|
8
34
|
//#endregion
|
|
9
|
-
export { e as KAEnv, r as default };
|
|
35
|
+
export { e as KAEnv, i as Volumetric, r as calculate, a as default };
|
|
10
36
|
|
|
11
37
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["import { KAEnv } from \"./config/api\";\nimport { init } from \"./config/client\";\nimport { services } from \"./services/index\";\n\nexport { KAEnv };\n\nconst KiriminAja = {\n init,\n Init: init,\n ...services,\n};\n\nexport default KiriminAja;\n"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../src/utils/volumetric.ts","../src/index.ts"],"sourcesContent":["export interface VolumetricItem {\n qty: number;\n length: number;\n width: number;\n height: number;\n}\n\nexport interface Dimensions {\n length: number;\n width: number;\n height: number;\n}\n\nexport const calculate = (items: VolumetricItem[]): Dimensions => {\n if (!items || items.length === 0) {\n return { length: 0, width: 0, height: 0 };\n }\n\n let lVert = 0,\n wVert = 0,\n hVert = 0;\n let lHor = 0,\n wHor = 0,\n hHor = 0;\n let lSide = 0,\n wSide = 0,\n hSide = 0;\n\n for (const it of items) {\n const qty = it.qty < 1 ? 1 : it.qty;\n const l = it.length;\n const w = it.width;\n const h = it.height;\n\n // Vertical stacking: heights add up\n hVert += h * qty;\n if (l > lVert) lVert = l;\n if (w > wVert) wVert = w;\n\n // Horizontal stacking: lengths add up\n lHor += l * qty;\n if (h > hHor) hHor = h;\n if (w > wHor) wHor = w;\n\n // Side-by-side stacking: widths add up\n wSide += w * qty;\n if (h > hSide) hSide = h;\n if (l > lSide) lSide = l;\n }\n\n const volVert = lVert * wVert * hVert;\n const volHor = lHor * wHor * hHor;\n const volSide = lSide * wSide * hSide;\n\n if (volVert <= volHor && volVert <= volSide) {\n return { length: lVert, width: wVert, height: hVert };\n }\n if (volHor <= volSide) {\n return { length: lHor, width: wHor, height: hHor };\n }\n return { length: lSide, width: wSide, height: hSide };\n};\n\nexport const Volumetric = { calculate };\n","import { KAEnv } from \"./config/api\";\nimport { init } from \"./config/client\";\nimport { services } from \"./services/index\";\nimport { Volumetric } from \"./utils/volumetric\";\n\nexport { KAEnv, Volumetric };\nexport * from \"./utils/volumetric\";\n\nconst KiriminAja = {\n init,\n Init: init,\n ...services,\n Volumetric,\n};\n\nexport default KiriminAja;\n"],"mappings":";;AAaA,IAAa,KAAa,MAAwC;AAC9D,KAAI,CAAC,KAAS,EAAM,WAAW,EAC3B,QAAO;EAAE,QAAQ;EAAG,OAAO;EAAG,QAAQ;EAAG;CAG7C,IAAI,IAAQ,GACR,IAAQ,GACR,IAAQ,GACR,IAAO,GACP,IAAO,GACP,IAAO,GACP,IAAQ,GACR,IAAQ,GACR,IAAQ;AAEZ,MAAK,IAAM,KAAM,GAAO;EACpB,IAAM,IAAM,EAAG,MAAM,IAAI,IAAI,EAAG,KAC1B,IAAI,EAAG,QACP,IAAI,EAAG,OACP,IAAI,EAAG;AAeb,EAZA,KAAS,IAAI,GACT,IAAI,MAAO,IAAQ,IACnB,IAAI,MAAO,IAAQ,IAGvB,KAAQ,IAAI,GACR,IAAI,MAAM,IAAO,IACjB,IAAI,MAAM,IAAO,IAGrB,KAAS,IAAI,GACT,IAAI,MAAO,IAAQ,IACnB,IAAI,MAAO,IAAQ;;CAG3B,IAAM,IAAU,IAAQ,IAAQ,GAC1B,IAAS,IAAO,IAAO,GACvB,IAAU,IAAQ,IAAQ;AAQhC,QANI,KAAW,KAAU,KAAW,IACzB;EAAE,QAAQ;EAAO,OAAO;EAAO,QAAQ;EAAO,GAErD,KAAU,IACH;EAAE,QAAQ;EAAM,OAAO;EAAM,QAAQ;EAAM,GAE/C;EAAE,QAAQ;EAAO,OAAO;EAAO,QAAQ;EAAO;GAG5C,IAAa,EAAE,cAAW,ECvDjC,IAAa;CACf;CACA,MAAM;CACN,GAAG;CACH;CACH"}
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import { KAResponse } from '../../types/api-response';
|
|
2
|
+
import { ExpressService } from '../../types/courier';
|
|
2
3
|
export type PricingExpressPayload = {
|
|
3
4
|
origin: number;
|
|
4
5
|
destination: number;
|
|
5
6
|
weight: number;
|
|
6
7
|
item_value: string | number;
|
|
7
8
|
insurance: number;
|
|
8
|
-
|
|
9
|
+
/**
|
|
10
|
+
* @description Use string for custom courier codes that not provided in ExpressService enum
|
|
11
|
+
*/
|
|
12
|
+
courier: (ExpressService | string)[];
|
|
9
13
|
};
|
|
10
14
|
export declare const getPricingExpress: <T = unknown>(payload: PricingExpressPayload) => Promise<KAResponse<T>>;
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { KAResponse } from '../../types/api-response';
|
|
2
2
|
import { InstantService } from '../../types/courier';
|
|
3
3
|
export type PricingInstantPayload = {
|
|
4
|
-
|
|
4
|
+
/**
|
|
5
|
+
* @description Use string for custom courier codes that not provided in InstantService enum
|
|
6
|
+
*/
|
|
7
|
+
service: (InstantService | string)[];
|
|
5
8
|
item_price: number;
|
|
6
9
|
origin: {
|
|
7
10
|
lat: number;
|
package/dist/services/index.d.ts
CHANGED
|
@@ -15,6 +15,9 @@ export declare const services: {
|
|
|
15
15
|
subDistricts: (kecamatanId: number) => Promise<import('../types/coverage-area-responses').SubDistrictListResponse>;
|
|
16
16
|
districtsByName: (search: string) => Promise<import('../types/coverage-area-responses').DistrictByNameResponse>;
|
|
17
17
|
};
|
|
18
|
+
credit: {
|
|
19
|
+
balance: () => Promise<import('../types/credit-responses').CreditBalanceResponse>;
|
|
20
|
+
};
|
|
18
21
|
order: {
|
|
19
22
|
express: {
|
|
20
23
|
track: (orderId: string) => Promise<import('../types/order-responses').ExpressTrackingResponse>;
|
package/dist/types/courier.d.ts
CHANGED
|
@@ -45,3 +45,21 @@ export declare enum InstantVehicle {
|
|
|
45
45
|
Bike = "motor",
|
|
46
46
|
Car = "mobil"
|
|
47
47
|
}
|
|
48
|
+
export declare enum ExpressService {
|
|
49
|
+
Tiki = "tiki",
|
|
50
|
+
Pos = "posindonesia",
|
|
51
|
+
Paxel = "paxel",
|
|
52
|
+
Ninja = "ninja",
|
|
53
|
+
RPX = "rpx",
|
|
54
|
+
LionParcel = "lion",
|
|
55
|
+
JTCargo = "jtcargo",
|
|
56
|
+
SentralCargo = "sentral",
|
|
57
|
+
AnterAja = "anteraja",
|
|
58
|
+
NCS = "ncs",
|
|
59
|
+
Sicepat = "sicepat",
|
|
60
|
+
SAP = "sap",
|
|
61
|
+
IDExpress = "idx",
|
|
62
|
+
JNE = "jne",
|
|
63
|
+
JNT = "jnt",
|
|
64
|
+
SPX = "spx"
|
|
65
|
+
}
|
package/dist/types/order.d.ts
CHANGED
|
@@ -1,4 +1,18 @@
|
|
|
1
1
|
import { InstantService, InstantVehicle } from './courier';
|
|
2
|
+
export interface RequestPickupItemMetadata {
|
|
3
|
+
sku?: string;
|
|
4
|
+
variant_label?: string;
|
|
5
|
+
}
|
|
6
|
+
export interface RequestPickupItem {
|
|
7
|
+
name: string;
|
|
8
|
+
price: number;
|
|
9
|
+
qty: number;
|
|
10
|
+
weight: number;
|
|
11
|
+
width?: number;
|
|
12
|
+
length?: number;
|
|
13
|
+
height?: number;
|
|
14
|
+
metadata?: RequestPickupItemMetadata;
|
|
15
|
+
}
|
|
2
16
|
export interface RequestPickupPackage {
|
|
3
17
|
order_id: string;
|
|
4
18
|
destination_name: string;
|
|
@@ -20,6 +34,7 @@ export interface RequestPickupPackage {
|
|
|
20
34
|
cod: number;
|
|
21
35
|
package_type_id: number;
|
|
22
36
|
item_name: string;
|
|
37
|
+
items?: RequestPickupItem[];
|
|
23
38
|
drop?: boolean;
|
|
24
39
|
note?: string;
|
|
25
40
|
}
|
|
@@ -59,7 +74,10 @@ export interface InstantPickupPackage {
|
|
|
59
74
|
item: InstantPickupItem;
|
|
60
75
|
}
|
|
61
76
|
export interface InstantPickupPayload {
|
|
62
|
-
|
|
77
|
+
/**
|
|
78
|
+
* @description Use string for custom courier codes that not provided in InstantService enum
|
|
79
|
+
*/
|
|
80
|
+
service: InstantService | string;
|
|
63
81
|
service_type: string;
|
|
64
82
|
vehicle: InstantVehicle;
|
|
65
83
|
order_prefix: string;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface VolumetricItem {
|
|
2
|
+
qty: number;
|
|
3
|
+
length: number;
|
|
4
|
+
width: number;
|
|
5
|
+
height: number;
|
|
6
|
+
}
|
|
7
|
+
export interface Dimensions {
|
|
8
|
+
length: number;
|
|
9
|
+
width: number;
|
|
10
|
+
height: number;
|
|
11
|
+
}
|
|
12
|
+
export declare const calculate: (items: VolumetricItem[]) => Dimensions;
|
|
13
|
+
export declare const Volumetric: {
|
|
14
|
+
calculate: (items: VolumetricItem[]) => Dimensions;
|
|
15
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kiriminaja",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"type": "git",
|
|
12
12
|
"url": "https://github.com/kiriminaja/node.git"
|
|
13
13
|
},
|
|
14
|
-
"author": "Kiriminaja Team <
|
|
14
|
+
"author": "Kiriminaja Team <tech@kiriminaja.com>",
|
|
15
15
|
"exports": {
|
|
16
16
|
".": {
|
|
17
17
|
"import": {
|