@1dex-fr/connector 0.2.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/LICENSE +21 -0
- package/README.md +143 -0
- package/package.json +39 -0
- package/src/index.d.ts +520 -0
- package/src/index.js +722 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 1dex
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
# @1dex-fr/connector
|
|
2
|
+
|
|
3
|
+
JavaScript and TypeScript connector for the public and professional `1dex.fr` API surface.
|
|
4
|
+
|
|
5
|
+
Install the npm package:
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm i @1dex-fr/connector
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
```js
|
|
12
|
+
import { OneDexClient } from "@1dex-fr/connector";
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Public reads
|
|
16
|
+
|
|
17
|
+
Public overview access is intended for manual, one-off checks within public quotas. Automation and integrations require active API rights. Some map layers also require an authorized Explorer session; an API key alone does not grant access to detailed DVF or works layers.
|
|
18
|
+
|
|
19
|
+
```js
|
|
20
|
+
import { OneDexClient } from "@1dex-fr/connector";
|
|
21
|
+
|
|
22
|
+
const client = new OneDexClient();
|
|
23
|
+
|
|
24
|
+
const overview = await client.overview.address({
|
|
25
|
+
address: "10 rue des cordeliers aix",
|
|
26
|
+
dvf_radius_m: 600,
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
const suggestions = await client.autocomplete.address({
|
|
30
|
+
q: "10 rue des cordeliers aix",
|
|
31
|
+
limit: 5,
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
const score = await client.score.address({
|
|
35
|
+
items: [{ address: "10 rue des cordeliers aix" }],
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
const viewport = await client.map.viewport({
|
|
39
|
+
layers: "context,iris",
|
|
40
|
+
address: "10 rue des cordeliers aix",
|
|
41
|
+
});
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Authentication and detailed reads
|
|
45
|
+
|
|
46
|
+
Complete address details and unlock flows require a 1dex API key. Professional Free accounts can issue a demo key only when a demo is published in that environment. Demo keys are pinned to the configured address; live keys use the account's subscription and activation rights. Check current offer availability on `1dex.fr`. Keep live keys in your backend, never in browser code or URLs. Create or manage keys at <https://1dex.fr/compte/api>.
|
|
47
|
+
|
|
48
|
+
Pass the key explicitly or through `ONEDEX_API_KEY`:
|
|
49
|
+
|
|
50
|
+
```js
|
|
51
|
+
import { OneDexApiError, OneDexClient } from "@1dex-fr/connector";
|
|
52
|
+
|
|
53
|
+
const client = new OneDexClient({
|
|
54
|
+
apiKey: process.env.ONEDEX_API_KEY,
|
|
55
|
+
});
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Recommended subscriber flow:
|
|
59
|
+
|
|
60
|
+
1. Check the V2 `api_addresses` usage view (or the legacy V1 response during rollout) with `client.account.usage()`.
|
|
61
|
+
2. Try `client.address.details(...)` with an address, parcel, coordinates, or a `normalizedAddressKey`, plus a caller-generated idempotency key.
|
|
62
|
+
3. If the API raises `address_unlock_required`, call `client.address.unlock(...)` with the returned `normalized_address_key`, or post the returned `unlock_request` object when present.
|
|
63
|
+
4. Follow the returned `details_url` with `client.address.detailsUrl(...)`; the helper rejects another origin or route.
|
|
64
|
+
|
|
65
|
+
```js
|
|
66
|
+
import { randomUUID } from "node:crypto";
|
|
67
|
+
|
|
68
|
+
const usage = await client.account.usage();
|
|
69
|
+
|
|
70
|
+
try {
|
|
71
|
+
const details = await client.address.details({
|
|
72
|
+
address: "10 rue des cordeliers aix",
|
|
73
|
+
fields: ["summary", "rail"],
|
|
74
|
+
idempotencyKey: randomUUID(),
|
|
75
|
+
}, { retry: true });
|
|
76
|
+
console.log(details.fields);
|
|
77
|
+
} catch (error) {
|
|
78
|
+
if (!(error instanceof OneDexApiError)) {
|
|
79
|
+
throw error;
|
|
80
|
+
}
|
|
81
|
+
if (error.status !== 402 || error.body?.error !== "address_unlock_required") {
|
|
82
|
+
throw error;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const unlockIdempotencyKey = randomUUID();
|
|
86
|
+
const unlock = error.body.unlock_request
|
|
87
|
+
? await client.address.unlock({
|
|
88
|
+
...error.body.unlock_request,
|
|
89
|
+
idempotencyKey: unlockIdempotencyKey,
|
|
90
|
+
}, { retry: true })
|
|
91
|
+
: await client.address.unlock({
|
|
92
|
+
normalizedAddressKey: error.body.normalized_address_key,
|
|
93
|
+
idempotencyKey: unlockIdempotencyKey,
|
|
94
|
+
}, { retry: true });
|
|
95
|
+
|
|
96
|
+
const details = unlock.details_url
|
|
97
|
+
? await client.address.detailsUrl(unlock.details_url, {
|
|
98
|
+
idempotencyKey: randomUUID(),
|
|
99
|
+
retry: true,
|
|
100
|
+
})
|
|
101
|
+
: await client.address.details({
|
|
102
|
+
normalizedAddressKey: unlock.normalized_address_key,
|
|
103
|
+
fields: ["summary", "rail"],
|
|
104
|
+
idempotencyKey: randomUUID(),
|
|
105
|
+
}, { retry: true });
|
|
106
|
+
|
|
107
|
+
console.log(usage.version, details.fields);
|
|
108
|
+
}
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
`retry: true` retries `202`, `429`, and `503` with the exact same idempotency key and honors `Retry-After`. A `409` is never retried: it means the key identifies another intention. Pass an `AbortSignal` to cancel both the active request and any retry wait.
|
|
112
|
+
|
|
113
|
+
Common professional API errors:
|
|
114
|
+
|
|
115
|
+
- `invalid_api_key`: the API key is missing, invalid, or revoked.
|
|
116
|
+
- `api_subscription_required`: the account needs an active subscription.
|
|
117
|
+
- `api_professional_required`: the endpoint requires a professional plan.
|
|
118
|
+
- `address_unlock_required`: the detailed address must be unlocked before reading.
|
|
119
|
+
- `insufficient_credits`: the account has no remaining address credits for the requested unlock.
|
|
120
|
+
|
|
121
|
+
## Helpers
|
|
122
|
+
|
|
123
|
+
The client exposes helpers for the current `/api/v1` routes:
|
|
124
|
+
|
|
125
|
+
- `client.overview.address(...)`
|
|
126
|
+
- `client.address.details(...)`
|
|
127
|
+
- `client.address.detailsUrl(...)`
|
|
128
|
+
- `client.address.unlock(...)`
|
|
129
|
+
- `client.account.usage()`
|
|
130
|
+
- `client.autocomplete.address(...)`
|
|
131
|
+
- `client.communes.search(...)`
|
|
132
|
+
- `client.score.address(...)`, `client.score.compare(...)`, `client.score.grid(...)`, `client.score.addressSuggest(...)`
|
|
133
|
+
- `client.preview.byPath(...)`
|
|
134
|
+
- `client.addressPages.state(...)`
|
|
135
|
+
- `client.map.layer(...)`, `client.map.viewport(...)`, `client.map.focus.address(...)`, `client.map.focus.publicLocation(...)`, `client.map.focus.parcelle(...)`, `client.map.focus.parcelles(...)`, `client.map.focus.feature(...)`
|
|
136
|
+
|
|
137
|
+
For command-line usage, install `@1dex-fr/1dex`.
|
|
138
|
+
|
|
139
|
+
Supported runtimes: Node 22 and 24. Type declarations cover both legacy account usage and `account-usage-v2` during rollout.
|
|
140
|
+
|
|
141
|
+
## Transport limits
|
|
142
|
+
|
|
143
|
+
The base URL accepts either `https://1dex.fr` or `https://1dex.fr/api/v1`. HTTP redirects are rejected so credentials and mutations are never forwarded to an unexpected URL. A retry wait budget stops retries when `Retry-After` exceeds it; it never shortens the server’s delay. Errors retain the HTTP status even when an upstream response contains text or HTML.
|
package/package.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@1dex-fr/connector",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "JavaScript connector for the public and professional 1dex API surface: overview, subscriber address details, autocomplete, score, preview, account usage, and map routes.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": {
|
|
8
|
+
"types": "./src/index.d.ts",
|
|
9
|
+
"default": "./src/index.js"
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
"src",
|
|
14
|
+
"README.md",
|
|
15
|
+
"LICENSE"
|
|
16
|
+
],
|
|
17
|
+
"keywords": [
|
|
18
|
+
"1dex",
|
|
19
|
+
"cadastre",
|
|
20
|
+
"dvf",
|
|
21
|
+
"travaux",
|
|
22
|
+
"parcelles",
|
|
23
|
+
"geojson",
|
|
24
|
+
"sdk"
|
|
25
|
+
],
|
|
26
|
+
"homepage": "https://blipn.github.io/1dex-connector/",
|
|
27
|
+
"repository": {
|
|
28
|
+
"type": "git",
|
|
29
|
+
"url": "git+https://github.com/blipn/1dex-connector.git",
|
|
30
|
+
"directory": "packages/js"
|
|
31
|
+
},
|
|
32
|
+
"bugs": {
|
|
33
|
+
"url": "https://github.com/blipn/1dex-connector/issues"
|
|
34
|
+
},
|
|
35
|
+
"engines": {
|
|
36
|
+
"node": ">=22"
|
|
37
|
+
},
|
|
38
|
+
"license": "MIT"
|
|
39
|
+
}
|