@apicircle/mock-server-core 1.0.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 +110 -0
- package/README.md +55 -0
- package/dist/index.cjs +1078 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +112 -0
- package/dist/index.d.ts +112 -0
- package/dist/index.js +1030 -0
- package/dist/index.js.map +1 -0
- package/package.json +56 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
APICircle Studio License
|
|
2
|
+
Custom Source-Available License, v1.0
|
|
3
|
+
|
|
4
|
+
Copyright (c) 2026 Deva Prakash ("Licensor")
|
|
5
|
+
|
|
6
|
+
The source code in this repository ("the Software") is made available for
|
|
7
|
+
the purposes of transparency, security review, contribution, and personal
|
|
8
|
+
evaluation. This is NOT an open-source license as defined by the Open
|
|
9
|
+
Source Initiative.
|
|
10
|
+
|
|
11
|
+
0. Definitions
|
|
12
|
+
|
|
13
|
+
"Commercial Use" means any use of the Software that is intended for
|
|
14
|
+
or directed toward commercial advantage or monetary compensation,
|
|
15
|
+
whether direct or indirect, including without limitation:
|
|
16
|
+
|
|
17
|
+
(a) using the Software to build, test, develop, deploy, or operate
|
|
18
|
+
any product, service, application, or system that is sold,
|
|
19
|
+
licensed, hosted, distributed, or otherwise made available to
|
|
20
|
+
any third party for a fee or other consideration;
|
|
21
|
+
(b) using the Software in the course of paid employment, paid
|
|
22
|
+
consulting, paid contracting, freelance work, or any other
|
|
23
|
+
revenue-generating activity, regardless of whether the Software
|
|
24
|
+
itself is sold or transferred;
|
|
25
|
+
(c) using the Software internally within a for-profit organization
|
|
26
|
+
beyond the Evaluation Period defined below;
|
|
27
|
+
(d) integrating the Software, or any portion of it, into any tool,
|
|
28
|
+
pipeline, automation, or workflow that supports the commercial
|
|
29
|
+
operations of any business;
|
|
30
|
+
(e) using the Software to provide a hosted, managed, or embedded
|
|
31
|
+
service of any kind to a third party, whether free or paid.
|
|
32
|
+
|
|
33
|
+
"Non-Commercial Use" means any use that is not Commercial Use,
|
|
34
|
+
including personal hobby projects, individual learning, academic
|
|
35
|
+
research, classroom instruction, and good-faith contribution to
|
|
36
|
+
this repository.
|
|
37
|
+
|
|
38
|
+
"Evaluation Period" means a single, continuous period of up to
|
|
39
|
+
thirty (30) days during which a for-profit organization may
|
|
40
|
+
internally evaluate the Software at no charge. After the Evaluation
|
|
41
|
+
Period expires, any further use of the Software by that organization
|
|
42
|
+
constitutes Commercial Use and requires a separate commercial
|
|
43
|
+
license from the Licensor.
|
|
44
|
+
|
|
45
|
+
1. Permitted Use
|
|
46
|
+
|
|
47
|
+
You may, without charge:
|
|
48
|
+
|
|
49
|
+
(a) view, read, and study the source code of the Software;
|
|
50
|
+
(b) run the Software, in source or compiled form, for your own
|
|
51
|
+
Non-Commercial Use, or for Commercial Use solely within the
|
|
52
|
+
Evaluation Period;
|
|
53
|
+
(c) submit improvements to the Software back to this repository via
|
|
54
|
+
pull request, subject to Section 3 (Contributions).
|
|
55
|
+
|
|
56
|
+
2. Prohibited Use
|
|
57
|
+
|
|
58
|
+
Without prior written permission from the Licensor, you may NOT:
|
|
59
|
+
|
|
60
|
+
(a) make any Commercial Use of the Software, in whole or in part,
|
|
61
|
+
except during the Evaluation Period as defined in Section 0;
|
|
62
|
+
(b) redistribute the Software, in source or compiled form, whether
|
|
63
|
+
modified or unmodified, to any third party;
|
|
64
|
+
(c) sublicense, sell, rent, lease, or otherwise transfer the
|
|
65
|
+
Software or any rights granted herein;
|
|
66
|
+
(d) remove, obscure, or alter any copyright, trademark, attribution,
|
|
67
|
+
or license notice contained in the Software;
|
|
68
|
+
(e) use the names "APICircle", "API Circle Studio", or any related
|
|
69
|
+
logos or trademarks, except as required for accurate attribution.
|
|
70
|
+
|
|
71
|
+
3. Contributions
|
|
72
|
+
|
|
73
|
+
By submitting any contribution (including but not limited to code,
|
|
74
|
+
documentation, or assets) to this repository, you grant the Licensor
|
|
75
|
+
a perpetual, worldwide, irrevocable, royalty-free, sublicensable
|
|
76
|
+
license to use, modify, distribute, and relicense your contribution
|
|
77
|
+
under any terms, including the terms of this license or any future
|
|
78
|
+
version thereof.
|
|
79
|
+
|
|
80
|
+
4. No Trademark License
|
|
81
|
+
|
|
82
|
+
This license does not grant permission to use the trade names,
|
|
83
|
+
trademarks, service marks, or product names of the Licensor, except
|
|
84
|
+
as required for reasonable and customary use in describing the
|
|
85
|
+
origin of the Software.
|
|
86
|
+
|
|
87
|
+
5. Termination
|
|
88
|
+
|
|
89
|
+
The rights granted in Section 1 terminate automatically if you
|
|
90
|
+
breach any term of this license. Upon termination, you must cease
|
|
91
|
+
all use of the Software and destroy all copies in your possession.
|
|
92
|
+
|
|
93
|
+
6. Disclaimer of Warranty
|
|
94
|
+
|
|
95
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
96
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
97
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE, AND
|
|
98
|
+
NON-INFRINGEMENT.
|
|
99
|
+
|
|
100
|
+
7. Limitation of Liability
|
|
101
|
+
|
|
102
|
+
IN NO EVENT SHALL THE LICENSOR BE LIABLE FOR ANY CLAIM, DAMAGES, OR
|
|
103
|
+
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT, OR
|
|
104
|
+
OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION WITH THE SOFTWARE
|
|
105
|
+
OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
106
|
+
|
|
107
|
+
8. Commercial Licensing
|
|
108
|
+
|
|
109
|
+
For commercial licensing, redistribution, or any use not permitted
|
|
110
|
+
under Section 1, contact: apicircle365@gmail.com
|
package/README.md
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="https://raw.githubusercontent.com/apicircle/studio/main/assets/logo.png" alt="APICircle Studio" width="120" height="120" />
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
<h1 align="center">@apicircle/mock-server-core</h1>
|
|
6
|
+
|
|
7
|
+
Hono-based mock-server engine for [APICircle Studio](https://github.com/apicircle/studio). Parses OpenAPI / Swagger / Postman / Insomnia files into a `MockEndpoint[]`, then serves them on Node, Bun, or any edge runtime that runs Hono.
|
|
8
|
+
|
|
9
|
+
## Install
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install @apicircle/mock-server-core
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Quickstart
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
import { startMockServer, parseSourceToEndpoints } from '@apicircle/mock-server-core';
|
|
19
|
+
|
|
20
|
+
const { endpoints, warnings } = await parseSourceToEndpoints({
|
|
21
|
+
kind: 'openapi',
|
|
22
|
+
spec: rawYamlOrJson,
|
|
23
|
+
format: 'yaml',
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
const handle = await startMockServer({
|
|
27
|
+
id: 'm1',
|
|
28
|
+
name: 'Petstore',
|
|
29
|
+
source: { kind: 'openapi', spec: rawYamlOrJson, format: 'yaml' },
|
|
30
|
+
endpoints,
|
|
31
|
+
overrides: {},
|
|
32
|
+
defaultPort: 4040,
|
|
33
|
+
cors: { enabled: true, origins: ['*'] },
|
|
34
|
+
createdAt: new Date().toISOString(),
|
|
35
|
+
updatedAt: new Date().toISOString(),
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
// later
|
|
39
|
+
await handle.close();
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## What it parses
|
|
43
|
+
|
|
44
|
+
- **OpenAPI 3.x and Swagger 2.0** — JSON or YAML, including `$ref` deref via `@apidevtools/swagger-parser`.
|
|
45
|
+
- **Postman v2 / v2.1 collections** — recursive item walks, picks first saved response, falls back to a 200 default.
|
|
46
|
+
- **Insomnia v4 exports** — filters resources of `_type: 'request'`.
|
|
47
|
+
- **Manual** — pre-built `MockEndpoint[]` you supply yourself.
|
|
48
|
+
|
|
49
|
+
## Per-endpoint overrides
|
|
50
|
+
|
|
51
|
+
`MockServer.overrides[endpointId]` lets you change status, headers, body, or delay for a single endpoint without touching the source spec — perfect for testing error paths.
|
|
52
|
+
|
|
53
|
+
## License
|
|
54
|
+
|
|
55
|
+
Released under the **APICircle Studio License** — a custom source-available license, not an OSI-approved open-source license. Free for personal, educational, and non-commercial use, plus a 30-day commercial evaluation period; ongoing commercial use requires a separate license. See [LICENSE](./LICENSE) for the full terms, or contact **apicircle365@gmail.com** for commercial licensing.
|