@apicircle/shared 1.0.1 → 1.0.3

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 CHANGED
@@ -1,110 +1,110 @@
1
- API Circle 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 "API Circle", "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
1
+ API Circle 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 "API Circle", "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 CHANGED
@@ -4,23 +4,122 @@
4
4
 
5
5
  <h1 align="center">@apicircle/shared</h1>
6
6
 
7
- Shared foundation for [API Circle Studio](https://github.com/apicircle/studio) — the TypeScript types, ID generation, validators, and encryption helpers every other `@apicircle/*` package builds on.
7
+ <p align="center">
8
+ <strong>The TypeScript contract for everything API Circle Studio reads, writes, and ships.</strong><br />
9
+ One package, one source of truth — types, IDs, validators, crypto, and the MCP tool catalog.
10
+ </p>
11
+
12
+ <p align="center">
13
+ <a href="https://www.npmjs.com/package/@apicircle/shared"><img src="https://img.shields.io/npm/v/@apicircle/shared?color=cb3837&logo=npm" alt="npm version" /></a>
14
+ <img src="https://img.shields.io/badge/types-included-blue?logo=typescript" alt="TypeScript types included" />
15
+ <img src="https://img.shields.io/badge/node-%E2%89%A5%2020-brightgreen" alt="Node ≥ 20" />
16
+ <img src="https://img.shields.io/badge/zero%20runtime%20deps-yes-success" alt="Zero runtime dependencies" />
17
+ </p>
18
+
19
+ ---
20
+
21
+ ## Why this package exists
22
+
23
+ Every other `@apicircle/*` package — the request engine, the mock server, the
24
+ MCP host, the CLI, the desktop app — agrees on **one workspace schema**.
25
+ That schema lives here.
26
+
27
+ If you are building a third-party tool that reads, writes, syncs, lints, or
28
+ visualises an API Circle workspace, this is the only dependency you need to
29
+ stay byte-for-byte compatible with Studio.
30
+
31
+ > **Use this directly when** you are writing a custom MCP client, a workspace
32
+ > linter, a Git pre-commit hook, a migration script, or any other tool that
33
+ > needs to understand the Studio workspace format without pulling in the
34
+ > full execution engine.
8
35
 
9
36
  ## Install
10
37
 
11
38
  ```bash
12
39
  npm install @apicircle/shared
40
+ # pnpm add @apicircle/shared
41
+ # yarn add @apicircle/shared
42
+ ```
43
+
44
+ Ships dual ESM + CJS builds and full `.d.ts` types. Zero runtime dependencies.
45
+
46
+ ## What's in the box
47
+
48
+ | Surface | What you get |
49
+ | -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ |
50
+ | **Workspace schema** | `WorkspaceSynced` (the git-tracked document) and `WorkspaceLocal` (per-device state) — every entity type Studio knows about, fully typed. |
51
+ | **Entity types** | Requests, folders, environments, mock-server definitions, plans, assertions, releases, linked workspaces, global assets, history runs, secret-crypto blobs. |
52
+ | **`generateId()`** | The only sanctioned way to mint entity IDs — collision-resistant, URL-safe, length-bounded. |
53
+ | **Validators** | Lightweight shape checks for workspace documents and imported specs — handy when you're loading untrusted JSON. |
54
+ | **Crypto helpers** | AES-GCM via WebCrypto for at-rest secret material. Browser-safe, no Node-only modules. |
55
+ | **MCP catalog** | `MCP_TOOL_NAMES` — the canonical list of every tool the MCP server exposes, plus the `McpToolName` union type. Stay in lockstep with the server, by version. |
56
+ | **Envelope types** | Discriminated unions for MCP responses (`multiple-workspaces`, error envelopes, etc.) so your client gets exhaustive narrowing for free. |
57
+
58
+ ## A taste of it
59
+
60
+ ```ts
61
+ import {
62
+ MCP_TOOL_NAMES,
63
+ generateId,
64
+ type McpToolName,
65
+ type WorkspaceSynced,
66
+ type Request,
67
+ } from '@apicircle/shared';
68
+
69
+ // Build a request the way Studio would — same ID shape, same schema.
70
+ const req: Request = {
71
+ id: generateId(),
72
+ name: 'List Pets',
73
+ method: 'GET',
74
+ url: 'https://api.example.com/pets',
75
+ headers: [],
76
+ params: [],
77
+ auth: { type: 'none' },
78
+ bodies: {},
79
+ activeBody: 'none',
80
+ };
81
+
82
+ // Validate a workspace document loaded from disk / Git.
83
+ const synced: WorkspaceSynced = JSON.parse(raw);
84
+
85
+ // Iterate every MCP tool the server knows about — useful for building
86
+ // custom MCP clients, dashboards, or documentation generators.
87
+ for (const name of MCP_TOOL_NAMES) {
88
+ console.log(name); // 'workspace.list', 'request.create', 'mock.start', ...
89
+ }
90
+
91
+ function dispatch(name: McpToolName) {
92
+ // McpToolName is a string literal union, so the switch is exhaustive.
93
+ }
13
94
  ```
14
95
 
15
- ## What's inside
96
+ ## Where this fits in the ecosystem
97
+
98
+ ```
99
+ @apicircle/shared ◀── you are here (types + utilities)
100
+ ├── @apicircle/core (request engine, auth, imports, applyMutation)
101
+ ├── @apicircle/mock-server-core (Hono mock-server runtime)
102
+ ├── @apicircle/mcp-server (MCP stdio host + tool catalog)
103
+ └── @apicircle/cli (apicircle binary)
104
+ ```
105
+
106
+ Most users will install `@apicircle/cli` or `@apicircle/mcp-server` and never
107
+ touch this package directly. You only need `@apicircle/shared` when you're
108
+ the one **building** something that talks to a Studio workspace.
109
+
110
+ ## Stability
111
+
112
+ The workspace schema is the public contract API Circle Studio cares about most.
113
+ Breaking changes are versioned per [semver](https://semver.org); the schema
114
+ is exercised by **1,900+ unit and integration tests** across the wider Studio
115
+ codebase, and every Studio release (desktop, web, CLI, MCP) pins the same
116
+ `@apicircle/shared` version.
16
117
 
17
- - **Workspace types** — the canonical `WorkspaceSynced` / `WorkspaceLocal` schema and every entity type (requests, folders, environments, mock servers, plans, releases).
18
- - **`generateId()`** — collision-resistant ID generation; the only sanctioned way to mint entity IDs.
19
- - **Validators** — shape checks for workspace documents and imported specs.
20
- - **Encryption helpers** — AES-GCM via WebCrypto for at-rest secret material.
21
- - **MCP envelopes** — the request/response envelope types shared with `@apicircle/mcp-server`.
118
+ ## Learn more
22
119
 
23
- This package is mostly consumed indirectly through the other API Circle packages — install it directly when you are building tooling against the workspace format.
120
+ - **Studio repo & docs**: <https://github.com/apicircle/studio>
121
+ - **MCP tool reference**: <https://github.com/apicircle/studio/blob/main/docs/mcp-tools-reference.md>
122
+ - **Architecture overview**: <https://github.com/apicircle/studio/blob/main/docs/architecture/platform.md>
24
123
 
25
124
  ## License
26
125
 
package/dist/index.cjs CHANGED
@@ -81,7 +81,7 @@ function validateUrl(value) {
81
81
  const trimmed = value.trim();
82
82
  if (!trimmed) return fail("URL is required.");
83
83
  if (/^\s*\{\{\s*[^{}]+\s*\}\}/.test(trimmed)) return OK;
84
- const probe = trimmed.replace(/\{\{[^{}]+\}\}/g, "placeholder");
84
+ const probe = trimmed.replace(/\{\{[^{}]+\}\}/g, "1");
85
85
  try {
86
86
  const u = new URL(probe);
87
87
  if (!/^https?:|^file:$/i.test(u.protocol)) {
@@ -403,6 +403,7 @@ var MCP_TOOL_NAMES = [
403
403
  "import.insomnia",
404
404
  "import.har",
405
405
  "generate.code",
406
+ "workspace.list",
406
407
  "workspace.read",
407
408
  "workspace.write",
408
409
  "request.create",