@apifreaks/openapi-specs 0.3.0 → 0.3.2
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 +75 -99
- package/dist/index.cjs +8702 -2973
- package/dist/index.d.cts +15 -8
- package/dist/index.d.ts +15 -8
- package/dist/index.js +8699 -2973
- package/dist/specs/email-validation/bulk-email-validation.yaml +59 -12
- package/dist/specs/email-validation/email-checker.yaml +52 -10
- package/dist/specs/pdf/{bulk-pdf-generator.yaml → pdf-generator-bulk.yaml} +2 -2
- package/dist/specs/pdf/pdf-generator.yaml +2 -2
- package/package.json +1 -1
- package/specs/README.md +259 -0
- package/specs/email-validation/bulk-email-validation.json +90 -13
- package/specs/email-validation/email-checker.json +67 -11
- package/specs/pdf/{bulk-pdf-generator.json → pdf-generator-bulk.json} +2 -2
- package/specs/pdf/pdf-generator.json +2 -2
- /package/dist/specs/{general → billing}/usage-credits.yaml +0 -0
- /package/dist/specs/{geodb → geography}/administrative-units-details.yaml +0 -0
- /package/dist/specs/{geodb → geography}/administrative-units-levels.yaml +0 -0
- /package/dist/specs/{geodb → geography}/administrative-units.yaml +0 -0
- /package/dist/specs/{geodb → geography}/cities.yaml +0 -0
- /package/dist/specs/{geodb → geography}/countries-details.yaml +0 -0
- /package/dist/specs/{geodb → geography}/countries.yaml +0 -0
- /package/dist/specs/{geodb → geography}/flags-supported.yaml +0 -0
- /package/dist/specs/{geodb → geography}/flags.yaml +0 -0
- /package/dist/specs/{geodb → geography}/regions.yaml +0 -0
- /package/dist/specs/{geodb → geography}/subregions.yaml +0 -0
- /package/dist/specs/pdf/{pdf-split-pages.yaml → split-pdf.yaml} +0 -0
- /package/dist/specs/{phone-validation → phone-number-validation}/bulk-phone-number-validation.yaml +0 -0
- /package/dist/specs/{phone-validation/phone-number-validation.yaml → phone-number-validation/phone-validation.yaml} +0 -0
- /package/dist/specs/{other → weather}/astronomy-data.yaml +0 -0
- /package/specs/{general → billing}/usage-credits.json +0 -0
- /package/specs/{geodb → geography}/administrative-units-details.json +0 -0
- /package/specs/{geodb → geography}/administrative-units-levels.json +0 -0
- /package/specs/{geodb → geography}/administrative-units.json +0 -0
- /package/specs/{geodb → geography}/cities.json +0 -0
- /package/specs/{geodb → geography}/countries-details.json +0 -0
- /package/specs/{geodb → geography}/countries.json +0 -0
- /package/specs/{geodb → geography}/flags-supported.json +0 -0
- /package/specs/{geodb → geography}/flags.json +0 -0
- /package/specs/{geodb → geography}/regions.json +0 -0
- /package/specs/{geodb → geography}/subregions.json +0 -0
- /package/specs/pdf/{pdf-split-pages.json → split-pdf.json} +0 -0
- /package/specs/{phone-validation → phone-number-validation}/bulk-phone-number-validation.json +0 -0
- /package/specs/{phone-validation/phone-number-validation.json → phone-number-validation/phone-validation.json} +0 -0
- /package/specs/{other → weather}/astronomy-data.json +0 -0
package/README.md
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
# @apifreaks/openapi-specs
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/@apifreaks/openapi-specs)
|
|
4
|
+
[](LICENSE)
|
|
5
|
+
|
|
6
|
+
npm package and source repo for the public [OpenAPI 3.1](https://spec.openapis.org/oas/v3.1.1.html) specifications of [APIFreaks](https://apifreaks.com) products.
|
|
7
|
+
|
|
8
|
+
The specs (catalog, authentication, and how to open them in Swagger, Postman, or a code generator) are in **[specs/README.md](specs/README.md)**. This README is the package: install, the typed lookup API, and how the repo is built.
|
|
4
9
|
|
|
5
10
|
## Install
|
|
6
11
|
|
|
@@ -8,149 +13,120 @@ OpenAPI 3.1 specifications for all [APIFreaks](https://apifreaks.com) API produc
|
|
|
8
13
|
npm install @apifreaks/openapi-specs
|
|
9
14
|
```
|
|
10
15
|
|
|
16
|
+
Node.js 18 or later. ESM and CommonJS are both supported.
|
|
17
|
+
|
|
11
18
|
## Usage
|
|
12
19
|
|
|
13
|
-
|
|
20
|
+
Importing anything from `@apifreaks/openapi-specs` (the package entry) loads every spec. Use that when you need to list or look up specs at runtime. For a single product, import the JSON file (see below) so you do not go through that entry.
|
|
21
|
+
|
|
22
|
+
### Lookup
|
|
14
23
|
|
|
15
24
|
```ts
|
|
16
25
|
import {
|
|
17
|
-
|
|
26
|
+
getSpecJson,
|
|
27
|
+
getSpecYaml,
|
|
18
28
|
getSpecsByCategory,
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
SPECS_BY_CATEGORY,
|
|
29
|
+
SpecSlug,
|
|
30
|
+
SpecCategory,
|
|
22
31
|
} from "@apifreaks/openapi-specs";
|
|
23
32
|
|
|
24
|
-
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
const ipSlugs = getSpecsByCategory("ip-intelligence");
|
|
33
|
+
const spec = getSpecJson(SpecSlug.IP_LOCATOR);
|
|
34
|
+
const yaml = getSpecYaml(SpecSlug.IP_LOCATOR);
|
|
35
|
+
const ipSlugs = getSpecsByCategory(SpecCategory.IP_INTELLIGENCE);
|
|
36
|
+
```
|
|
29
37
|
|
|
30
|
-
|
|
31
|
-
console.log(SPEC_SLUGS); // ['ip-locator', 'dns-lookup', ...]
|
|
38
|
+
`SpecSlug` and `SpecCategory` are generated from `specs/`. If you write `SpecSlug.IP_LOCATOR` and that file is later renamed or removed, TypeScript fails at compile time. Raw strings (`getSpecJson("ip-locator")`) still typecheck; unknown slugs return `undefined` at runtime. Unknown categories return `[]`.
|
|
32
39
|
|
|
33
|
-
|
|
34
|
-
console.log(SPEC_CATEGORIES); // ['currency', 'dns', 'ip-intelligence', ...]
|
|
40
|
+
`getSpec` is a deprecated alias for `getSpecJson` and will be removed in the next major version.
|
|
35
41
|
|
|
36
|
-
|
|
37
|
-
console.log(SPECS_BY_CATEGORY);
|
|
38
|
-
```
|
|
42
|
+
### Single spec
|
|
39
43
|
|
|
40
|
-
|
|
44
|
+
JSON is published from `specs/`. TypeScript JSON imports need `"resolveJsonModule": true`.
|
|
41
45
|
|
|
42
46
|
```ts
|
|
43
47
|
import ipLocator from "@apifreaks/openapi-specs/specs/ip-intelligence/ip-locator.json";
|
|
44
48
|
```
|
|
45
49
|
|
|
50
|
+
YAML copies are also generated at build time into `dist/specs/` (not in the GitHub `specs/` folder) and published as files, but the YAML text is also embedded in the manifest — reading it through `getSpecYaml(slug)` at runtime, rather than importing the `.yaml` file, works from any module system (Node can't `import` `.yaml`) and needs no filesystem access.
|
|
51
|
+
|
|
46
52
|
### CommonJS
|
|
47
53
|
|
|
48
54
|
```js
|
|
49
|
-
const {
|
|
55
|
+
const { getSpecJson, getSpecYaml, SpecSlug } = require("@apifreaks/openapi-specs");
|
|
50
56
|
```
|
|
51
57
|
|
|
52
|
-
##
|
|
58
|
+
## Exports
|
|
53
59
|
|
|
54
|
-
|
|
55
|
-
| ------------------------------ | -------------------------------------- | --------------------------------------------------- |
|
|
56
|
-
| `getSpec(slug)` | `(string) => OpenAPISpec \| undefined` | Returns the full spec object for a given slug |
|
|
57
|
-
| `getSpecsByCategory(category)` | `(string) => string[]` | Returns all slugs in a category, or `[]` if unknown |
|
|
58
|
-
| `SPEC_SLUGS` | `string[]` | All 102 spec slugs |
|
|
59
|
-
| `SPEC_CATEGORIES` | `string[]` | All 21 category names |
|
|
60
|
-
| `SPECS` | `Record<string, OpenAPISpec>` | Full spec objects keyed by slug |
|
|
61
|
-
| `SPECS_BY_CATEGORY` | `Record<string, string[]>` | Slugs grouped by category |
|
|
60
|
+
Importing any of these from `@apifreaks/openapi-specs` loads every spec.
|
|
62
61
|
|
|
63
|
-
|
|
62
|
+
| Export | Type | Description |
|
|
63
|
+
| ------ | ---- | ----------- |
|
|
64
|
+
| `getSpecJson(slug)` | `(string) => OpenAPISpec \| undefined` | Spec object for a slug |
|
|
65
|
+
| `getSpecYaml(slug)` | `(string) => string \| undefined` | Pre-rendered YAML text for a slug |
|
|
66
|
+
| `getSpec(slug)` | `(string) => OpenAPISpec \| undefined` | **Deprecated.** Alias for `getSpecJson`, removed in the next major version |
|
|
67
|
+
| `getSpecsByCategory(category)` | `(string) => string[]` | Slugs in a category, or `[]` |
|
|
68
|
+
| `SpecSlug` | `{ IP_LOCATOR: "ip-locator", … }` | Enumerated slugs |
|
|
69
|
+
| `SpecCategory` | `{ IP_INTELLIGENCE: "ip-intelligence", … }` | Enumerated categories |
|
|
70
|
+
| `SPEC_SLUGS` | `string[]` | All slugs |
|
|
71
|
+
| `SPEC_CATEGORIES` | `string[]` | All category names |
|
|
72
|
+
| `SPECS` | `Record<string, OpenAPISpec>` | Spec objects keyed by slug |
|
|
73
|
+
| `SPECS_YAML` | `Record<string, string>` | Pre-rendered YAML text keyed by slug |
|
|
74
|
+
| `SPECS_BY_CATEGORY` | `Record<string, string[]>` | Slugs grouped by category |
|
|
64
75
|
|
|
65
76
|
```ts
|
|
66
|
-
import type {
|
|
67
|
-
|
|
68
|
-
|
|
77
|
+
import type {
|
|
78
|
+
OpenAPISpec,
|
|
79
|
+
SpecSlugValue,
|
|
80
|
+
SpecCategoryValue,
|
|
81
|
+
} from "@apifreaks/openapi-specs";
|
|
69
82
|
```
|
|
70
83
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
| Category | Count | Description |
|
|
74
|
-
| ------------------ | ----- | ------------------------------------------------------- |
|
|
75
|
-
| `commodity` | 5 | Commodity prices, symbols, time series |
|
|
76
|
-
| `currency` | 10 | Exchange rates, conversion, historical data |
|
|
77
|
-
| `dns` | 4 | DNS lookup, reverse DNS, history |
|
|
78
|
-
| `domain` | 4 | Domain search, checker, subdomain lookup |
|
|
79
|
-
| `email-validation` | 2 | Email verification and bulk validation |
|
|
80
|
-
| `financial` | 8 | VAT rates, IBAN/SWIFT validation |
|
|
81
|
-
| `general` | 1 | Usage and credits |
|
|
82
|
-
| `geocoding` | 2 | Forward and reverse geocoding |
|
|
83
|
-
| `geodb` | 10 | Countries, cities, regions, flags, administrative units |
|
|
84
|
-
| `ip-intelligence` | 4 | IP geolocation, threat intelligence, bulk lookup |
|
|
85
|
-
| `other` | 1 | Astronomy data |
|
|
86
|
-
| `pdf` | 19 | PDF manipulation, conversion, encryption |
|
|
87
|
-
| `phone-validation` | 2 | Phone number validation |
|
|
88
|
-
| `scraper` | 1 | Web scraping |
|
|
89
|
-
| `screenshot` | 2 | Website screenshots |
|
|
90
|
-
| `ssl` | 2 | SSL certificate lookup |
|
|
91
|
-
| `timezone` | 2 | Timezone lookup and conversion |
|
|
92
|
-
| `user-agent` | 2 | User-agent parsing |
|
|
93
|
-
| `weather` | 8 | Current, forecast, historical, marine weather |
|
|
94
|
-
| `whois` | 6 | WHOIS lookup, ASN, reverse WHOIS |
|
|
95
|
-
| `zip-code` | 7 | Zip code lookup, distance, radius search |
|
|
84
|
+
`OpenAPISpec` is a typed envelope (`openapi`, `info`, `paths`, …), not a full OpenAPI 3.1 schema.
|
|
96
85
|
|
|
97
86
|
## Development
|
|
98
87
|
|
|
88
|
+
```
|
|
89
|
+
specs/ # OpenAPI JSON. See specs/README.md
|
|
90
|
+
src/
|
|
91
|
+
index.ts # Public API
|
|
92
|
+
types.ts # OpenAPISpec
|
|
93
|
+
manifest.ts # AUTO-GENERATED. Do not edit.
|
|
94
|
+
scripts/
|
|
95
|
+
generate-manifest.ts # Walks specs/, writes src/manifest.ts (embeds JSON + YAML)
|
|
96
|
+
generate-yaml.ts # JSON → dist/specs/**/*.yaml (published files)
|
|
97
|
+
yaml.ts # Shared JSON->YAML dump used by both scripts
|
|
98
|
+
test/
|
|
99
|
+
validate.test.ts # JSON well-formedness; YAML round-trip after build
|
|
100
|
+
```
|
|
101
|
+
|
|
99
102
|
```bash
|
|
100
|
-
# Install deps
|
|
101
103
|
npm install
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
npm run generate
|
|
105
|
-
|
|
106
|
-
# Build (generate + tsup)
|
|
107
|
-
npm run build
|
|
108
|
-
|
|
109
|
-
# Typecheck
|
|
104
|
+
npm run generate # regenerate src/manifest.ts from specs/
|
|
105
|
+
npm run build # generate + bundle + YAML
|
|
110
106
|
npm run typecheck
|
|
111
|
-
|
|
112
|
-
# Test
|
|
113
107
|
npm test
|
|
114
108
|
```
|
|
115
109
|
|
|
116
|
-
|
|
110
|
+
`src/manifest.ts` is produced by `npm run generate`. It imports every spec and builds `SPECS`, `SPECS_YAML`, `SPEC_SLUGS`, `SpecSlug`, and `SpecCategory`.
|
|
117
111
|
|
|
118
|
-
|
|
119
|
-
specs/ # OpenAPI 3.1 JSON files, organized by category
|
|
120
|
-
currency/
|
|
121
|
-
currency-converter.json
|
|
122
|
-
ip-intelligence/
|
|
123
|
-
ip-locator.json
|
|
124
|
-
...
|
|
125
|
-
src/
|
|
126
|
-
index.ts # Public API
|
|
127
|
-
manifest.ts # AUTO-GENERATED — do not edit manually
|
|
128
|
-
types.ts # OpenAPISpec type definition
|
|
129
|
-
scripts/
|
|
130
|
-
generate-manifest.ts # Reads specs/, writes src/manifest.ts
|
|
131
|
-
test/
|
|
132
|
-
validate.test.ts # Validates every spec is valid JSON + well-formed OpenAPI
|
|
133
|
-
```
|
|
134
|
-
|
|
135
|
-
### Adding a new spec
|
|
112
|
+
### Adding a spec
|
|
136
113
|
|
|
137
|
-
1. Add
|
|
138
|
-
2. Run `npm run generate
|
|
139
|
-
3. Run `npm test`
|
|
140
|
-
4. Run `npm run build` to rebuild the package
|
|
114
|
+
1. Add a complete OpenAPI 3.1 document at `specs/<category>/<slug>.json`. Use the same security schemes as the existing files: header `X-apiKey` and query `apiKey`.
|
|
115
|
+
2. Run `npm run generate`. Do not edit `src/manifest.ts` by hand.
|
|
116
|
+
3. Run `npm test`, then `npm run build`.
|
|
141
117
|
|
|
142
|
-
|
|
118
|
+
## Maintainers
|
|
143
119
|
|
|
144
|
-
|
|
120
|
+
`prepublishOnly` runs the build. The published tarball includes `dist/`, `specs/`, `package.json`, README, and LICENSE.
|
|
145
121
|
|
|
146
|
-
|
|
122
|
+
Pushing a tag matching `v*` publishes to npm via GitHub Actions. The bump scripts **test, commit a version, tag, and push**; they will trigger that publish:
|
|
147
123
|
|
|
148
124
|
```bash
|
|
149
|
-
npm
|
|
125
|
+
npm run bump:patch
|
|
126
|
+
npm run bump:minor
|
|
127
|
+
npm run bump:major
|
|
150
128
|
```
|
|
151
129
|
|
|
152
|
-
The published package includes only `dist/` and `specs/`. Tests, scripts, and build configs are excluded.
|
|
153
|
-
|
|
154
130
|
## License
|
|
155
131
|
|
|
156
|
-
MIT
|
|
132
|
+
[MIT](LICENSE)
|