@solvice/routing 0.1.0-beta.1 → 0.17.0-beta.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 +10 -7
- package/dist/index.d.ts +5 -5
- package/dist/index.js +7 -13
- package/dist/v3.d.ts +1973 -1281
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -24,7 +24,7 @@ try {
|
|
|
24
24
|
location: [4.7005, 50.8798], // [longitude, latitude]
|
|
25
25
|
service_duration_s: 300,
|
|
26
26
|
time_windows: [{ from: '2026-04-01T09:00:00+02:00', to: '2026-04-01T12:00:00+02:00' }],
|
|
27
|
-
|
|
27
|
+
delivery_load: { weight: 10 },
|
|
28
28
|
},
|
|
29
29
|
],
|
|
30
30
|
vehicles: [
|
|
@@ -53,7 +53,7 @@ try {
|
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
for (const job of solution.unassigned) {
|
|
56
|
-
console.log(`unassigned ${job.
|
|
56
|
+
console.log(`unassigned ${job.task}: ${job.category}`);
|
|
57
57
|
}
|
|
58
58
|
} catch (err) {
|
|
59
59
|
if (!(err instanceof SolviceError)) throw err;
|
|
@@ -69,7 +69,7 @@ try {
|
|
|
69
69
|
| `solve(request)` | `POST /v3/routing/solve` |
|
|
70
70
|
| `evaluate(request)` | `POST /v3/routing/evaluate` |
|
|
71
71
|
| `suggest(request)` | `POST /v3/routing/suggest` |
|
|
72
|
-
| `validate.solve(request)`, `validate.evaluate(request)`, `validate.suggest(request)` | the same three
|
|
72
|
+
| `validate.solve(request)`, `validate.evaluate(request)`, `validate.suggest(request)` | the same three sent to `/v3/routing/validate/solve`, `/evaluate`, `/suggest`: checked, not run |
|
|
73
73
|
|
|
74
74
|
Any non-2xx response throws a `SolviceError` with the HTTP `status`, the
|
|
75
75
|
`response`, and, when the response carried one, the API's error `body`. A `401`
|
|
@@ -94,13 +94,16 @@ Documentation: <https://docs.solvice.io>
|
|
|
94
94
|
|
|
95
95
|
```bash
|
|
96
96
|
npm run generate # from mintlify/openapi.json
|
|
97
|
-
npm test # builds, typechecks tests/types.ts and examples/, runs the unit tests
|
|
97
|
+
npm test # builds, typechecks tests/types.ts and examples/, runs the unit tests and the solve-response fixture check
|
|
98
98
|
npm run smoke # live calls; needs SOLVICE_API_KEY
|
|
99
99
|
```
|
|
100
100
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
101
|
+
Releases are automatic: when release-plz publishes the GitHub release `vX.Y.Z`, the
|
|
102
|
+
"Publish TypeScript SDK" workflow publishes `X.Y.Z-beta.0`. `version` in `package.json`
|
|
103
|
+
is a placeholder (`0.0.0-development`); the workflow sets the real one from the tag, so
|
|
104
|
+
never bump it. To publish a release that triggered nothing, or re-run a failed one, use
|
|
105
|
+
Actions → Run workflow on `main`: it publishes the latest tag, or the one typed into `tag`.
|
|
106
|
+
It runs `npm run publish:beta` through npm trusted publishing; never publish
|
|
104
107
|
from a branch. The explicit `--tag beta` matters: npm 11 ignores
|
|
105
108
|
`publishConfig.tag` and would move `latest` to the prerelease. Until a stable version
|
|
106
109
|
exists, `latest` still points at the first prerelease (npm gives a package's first
|
package/dist/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export type EvaluateRequest = Schemas["EvaluateRequest"];
|
|
|
6
6
|
export type SuggestRequest = Schemas["SuggestRequest"];
|
|
7
7
|
export type SolveResponse = Schemas["SolveResponse"];
|
|
8
8
|
export type SuggestResponse = Schemas["SuggestResponse"];
|
|
9
|
-
export type
|
|
9
|
+
export type ValidateResponse = Schemas["ValidateResponse"];
|
|
10
10
|
export type ErrorBody = Schemas["ErrorBody"];
|
|
11
11
|
export interface SolviceOptions {
|
|
12
12
|
/** Sent as the `Authorization` header value, with no scheme prefix. */
|
|
@@ -45,11 +45,11 @@ export declare function createSolvice({ apiKey, baseUrl, fetch }: SolviceOptions
|
|
|
45
45
|
solve: (body: SolveRequest, options?: RequestOptions) => Promise<SolveResponse>;
|
|
46
46
|
evaluate: (body: EvaluateRequest, options?: RequestOptions) => Promise<SolveResponse>;
|
|
47
47
|
suggest: (body: SuggestRequest, options?: RequestOptions) => Promise<SuggestResponse>;
|
|
48
|
-
/** The same requests
|
|
48
|
+
/** The same requests sent to `/v3/routing/validate/*`: no matrix fetch, no search, not billed. */
|
|
49
49
|
validate: {
|
|
50
|
-
solve: (body: SolveRequest, options?: RequestOptions) => Promise<
|
|
51
|
-
evaluate: (body: EvaluateRequest, options?: RequestOptions) => Promise<
|
|
52
|
-
suggest: (body: SuggestRequest, options?: RequestOptions) => Promise<
|
|
50
|
+
solve: (body: SolveRequest, options?: RequestOptions) => Promise<ValidateResponse>;
|
|
51
|
+
evaluate: (body: EvaluateRequest, options?: RequestOptions) => Promise<ValidateResponse>;
|
|
52
|
+
suggest: (body: SuggestRequest, options?: RequestOptions) => Promise<ValidateResponse>;
|
|
53
53
|
};
|
|
54
54
|
/** The underlying openapi-fetch client, for anything the methods above do not cover. */
|
|
55
55
|
client: import("openapi-fetch").Client<paths, `${string}/${string}`>;
|
package/dist/index.js
CHANGED
|
@@ -43,23 +43,17 @@ function unwrap({ data, error, response }) {
|
|
|
43
43
|
}
|
|
44
44
|
return data;
|
|
45
45
|
}
|
|
46
|
-
// The spec types every 200 as `Response | ValidateOnlyResponse` (#1626 H).
|
|
47
|
-
// Which one comes back is decided by `validate_only`, which each method below
|
|
48
|
-
// fixes, so these two pick the matching side of the union.
|
|
49
|
-
const result = (r) => unwrap(r);
|
|
50
|
-
const validation = (r) => unwrap(r);
|
|
51
|
-
const VALIDATE_ONLY = { query: { validate_only: true } };
|
|
52
46
|
export function createSolvice({ apiKey, baseUrl = "https://api.solvice.io", fetch }) {
|
|
53
47
|
const client = createClient({ baseUrl, headers: { Authorization: apiKey }, fetch });
|
|
54
48
|
return {
|
|
55
|
-
solve: async (body, options) =>
|
|
56
|
-
evaluate: async (body, options) =>
|
|
57
|
-
suggest: async (body, options) =>
|
|
58
|
-
/** The same requests
|
|
49
|
+
solve: async (body, options) => unwrap(await client.POST("/v3/routing/solve", { body, ...options })),
|
|
50
|
+
evaluate: async (body, options) => unwrap(await client.POST("/v3/routing/evaluate", { body, ...options })),
|
|
51
|
+
suggest: async (body, options) => unwrap(await client.POST("/v3/routing/suggest", { body, ...options })),
|
|
52
|
+
/** The same requests sent to `/v3/routing/validate/*`: no matrix fetch, no search, not billed. */
|
|
59
53
|
validate: {
|
|
60
|
-
solve: async (body, options) =>
|
|
61
|
-
evaluate: async (body, options) =>
|
|
62
|
-
suggest: async (body, options) =>
|
|
54
|
+
solve: async (body, options) => unwrap(await client.POST("/v3/routing/validate/solve", { body, ...options })),
|
|
55
|
+
evaluate: async (body, options) => unwrap(await client.POST("/v3/routing/validate/evaluate", { body, ...options })),
|
|
56
|
+
suggest: async (body, options) => unwrap(await client.POST("/v3/routing/validate/suggest", { body, ...options })),
|
|
63
57
|
},
|
|
64
58
|
/** The underlying openapi-fetch client, for anything the methods above do not cover. */
|
|
65
59
|
client,
|