@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.
Files changed (45) hide show
  1. package/README.md +75 -99
  2. package/dist/index.cjs +8702 -2973
  3. package/dist/index.d.cts +15 -8
  4. package/dist/index.d.ts +15 -8
  5. package/dist/index.js +8699 -2973
  6. package/dist/specs/email-validation/bulk-email-validation.yaml +59 -12
  7. package/dist/specs/email-validation/email-checker.yaml +52 -10
  8. package/dist/specs/pdf/{bulk-pdf-generator.yaml → pdf-generator-bulk.yaml} +2 -2
  9. package/dist/specs/pdf/pdf-generator.yaml +2 -2
  10. package/package.json +1 -1
  11. package/specs/README.md +259 -0
  12. package/specs/email-validation/bulk-email-validation.json +90 -13
  13. package/specs/email-validation/email-checker.json +67 -11
  14. package/specs/pdf/{bulk-pdf-generator.json → pdf-generator-bulk.json} +2 -2
  15. package/specs/pdf/pdf-generator.json +2 -2
  16. /package/dist/specs/{general → billing}/usage-credits.yaml +0 -0
  17. /package/dist/specs/{geodb → geography}/administrative-units-details.yaml +0 -0
  18. /package/dist/specs/{geodb → geography}/administrative-units-levels.yaml +0 -0
  19. /package/dist/specs/{geodb → geography}/administrative-units.yaml +0 -0
  20. /package/dist/specs/{geodb → geography}/cities.yaml +0 -0
  21. /package/dist/specs/{geodb → geography}/countries-details.yaml +0 -0
  22. /package/dist/specs/{geodb → geography}/countries.yaml +0 -0
  23. /package/dist/specs/{geodb → geography}/flags-supported.yaml +0 -0
  24. /package/dist/specs/{geodb → geography}/flags.yaml +0 -0
  25. /package/dist/specs/{geodb → geography}/regions.yaml +0 -0
  26. /package/dist/specs/{geodb → geography}/subregions.yaml +0 -0
  27. /package/dist/specs/pdf/{pdf-split-pages.yaml → split-pdf.yaml} +0 -0
  28. /package/dist/specs/{phone-validation → phone-number-validation}/bulk-phone-number-validation.yaml +0 -0
  29. /package/dist/specs/{phone-validation/phone-number-validation.yaml → phone-number-validation/phone-validation.yaml} +0 -0
  30. /package/dist/specs/{other → weather}/astronomy-data.yaml +0 -0
  31. /package/specs/{general → billing}/usage-credits.json +0 -0
  32. /package/specs/{geodb → geography}/administrative-units-details.json +0 -0
  33. /package/specs/{geodb → geography}/administrative-units-levels.json +0 -0
  34. /package/specs/{geodb → geography}/administrative-units.json +0 -0
  35. /package/specs/{geodb → geography}/cities.json +0 -0
  36. /package/specs/{geodb → geography}/countries-details.json +0 -0
  37. /package/specs/{geodb → geography}/countries.json +0 -0
  38. /package/specs/{geodb → geography}/flags-supported.json +0 -0
  39. /package/specs/{geodb → geography}/flags.json +0 -0
  40. /package/specs/{geodb → geography}/regions.json +0 -0
  41. /package/specs/{geodb → geography}/subregions.json +0 -0
  42. /package/specs/pdf/{pdf-split-pages.json → split-pdf.json} +0 -0
  43. /package/specs/{phone-validation → phone-number-validation}/bulk-phone-number-validation.json +0 -0
  44. /package/specs/{phone-validation/phone-number-validation.json → phone-number-validation/phone-validation.json} +0 -0
  45. /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
- OpenAPI 3.1 specifications for all [APIFreaks](https://apifreaks.com) API products. Ships 102 production specs across 21 categories as typed JSON, importable as ESM, CJS, or raw JSON.
3
+ [![npm](https://img.shields.io/npm/v/@apifreaks/openapi-specs.svg)](https://www.npmjs.com/package/@apifreaks/openapi-specs)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](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
- ### Programmatic API
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
- getSpec,
26
+ getSpecJson,
27
+ getSpecYaml,
18
28
  getSpecsByCategory,
19
- SPEC_SLUGS,
20
- SPEC_CATEGORIES,
21
- SPECS_BY_CATEGORY,
29
+ SpecSlug,
30
+ SpecCategory,
22
31
  } from "@apifreaks/openapi-specs";
23
32
 
24
- // Get a single spec by slug
25
- const spec = getSpec("ip-locator");
26
-
27
- // Get all slugs in a category
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
- // All available slugs
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
- // All categories
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
- // All slugs grouped by category
37
- console.log(SPECS_BY_CATEGORY);
38
- ```
42
+ ### Single spec
39
43
 
40
- ### Direct JSON import (tree-shakable)
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 { getSpec, SPEC_SLUGS } = require("@apifreaks/openapi-specs");
55
+ const { getSpecJson, getSpecYaml, SpecSlug } = require("@apifreaks/openapi-specs");
50
56
  ```
51
57
 
52
- ## API
58
+ ## Exports
53
59
 
54
- | Export | Type | Description |
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
- ### Types
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 { OpenAPISpec } from "@apifreaks/openapi-specs";
67
-
68
- // OpenAPISpec has: openapi, info, servers?, paths?, components?, [key: string]
77
+ import type {
78
+ OpenAPISpec,
79
+ SpecSlugValue,
80
+ SpecCategoryValue,
81
+ } from "@apifreaks/openapi-specs";
69
82
  ```
70
83
 
71
- ## Categories
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
- # Generate manifest (auto-discovers specs/ and writes src/manifest.ts)
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
- ### Project structure
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 the `.json` file under the appropriate category in `specs/`
138
- 2. Run `npm run generate` to regenerate `src/manifest.ts`
139
- 3. Run `npm test` to validate
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
- `src/manifest.ts` is auto-generated and must not be edited by hand.
118
+ ## Maintainers
143
119
 
144
- ## Publishing
120
+ `prepublishOnly` runs the build. The published tarball includes `dist/`, `specs/`, `package.json`, README, and LICENSE.
145
121
 
146
- The package is built automatically before publish via `prepublishOnly`.
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 publish --access public
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)