@mitralab.io/sdk-core 0.1.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/CHANGELOG.md ADDED
@@ -0,0 +1,10 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project are documented in this file.
4
+
5
+ ## 0.1.0
6
+
7
+ - Add environment-neutral transport and error interfaces.
8
+ - Add shared auth, entity, custom query, Function, and integration modules.
9
+ - Add safe path encoding and structural response validation.
10
+ - Add the canonical SDK parity fixture and testable MCP, JavaScript, and Python matrix.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Mitra Platform
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,91 @@
1
+ # Mitra SDK Core
2
+
3
+ Environment-neutral TypeScript contracts and API modules shared by Mitra JavaScript SDKs.
4
+
5
+ Most application and Server Function code should install a concrete SDK instead:
6
+
7
+ - `@mitralab.io/platform-sdk` for browser applications
8
+ - `@mitralab.io/functions-sdk` for Mitra Server Functions
9
+
10
+ The core package exists so both SDKs build entity, custom query, Function, integration, and current-user requests from one contract.
11
+
12
+ The versioned contract corpus in `contracts/` is the canonical source for the
13
+ MCP, JavaScript, and Python capability matrix. Its manifest identifies the
14
+ current fixture and pins every packaged version with SHA-256. Core executes all
15
+ success operations and response validation. Functions JavaScript inherits those
16
+ checks and owns its HTTP adapter cases. Python consumes all case groups because
17
+ it does not depend on Core, using a digest-pinned snapshot so tests stay offline.
18
+
19
+ ## Boundary
20
+
21
+ The package contains:
22
+
23
+ - common types and data transfer objects
24
+ - safe path segment encoding
25
+ - structural response validation
26
+ - `auth.me`, entities, queries, Functions, and integration modules
27
+ - a minimal transport interface injected by each concrete SDK
28
+
29
+ The package does not contain:
30
+
31
+ - `fetch` or any other HTTP implementation
32
+ - tokens, authorization headers, or environment variables
33
+ - login, sign-up, logout, refresh, browser storage, or auth listeners
34
+ - retry, redirect, timeout, or client lifecycle policy
35
+
36
+ Those concerns stay in the concrete SDK because browser sessions and Server Function runtime credentials have different security and failure semantics.
37
+
38
+ ## Installation
39
+
40
+ ```bash
41
+ npm install @mitralab.io/sdk-core
42
+ ```
43
+
44
+ Node.js 18 or newer is required. The package has no runtime dependencies.
45
+
46
+ ## Transport contract
47
+
48
+ SDK adapters provide one transport per service. A transport receives the service-local path and request options, then returns the parsed response payload.
49
+
50
+ ```typescript
51
+ import { createSdkCore, type Transport } from "@mitralab.io/sdk-core"
52
+
53
+ declare const iam: Transport
54
+ declare const dataManager: Transport
55
+ declare const functions: Transport
56
+ declare const integration: Transport
57
+
58
+ let dataSourceId: string | undefined
59
+
60
+ const core = createSdkCore({
61
+ transports: { auth: iam, dataManager, functions, integration },
62
+ getDataSourceId: () => dataSourceId,
63
+ functions: {
64
+ executeInvocationType: "sync",
65
+ emptyInput: "empty-object",
66
+ },
67
+ })
68
+
69
+ const tasks = await core.entities.getTable("Task").list({ limit: 20 })
70
+ ```
71
+
72
+ The transport owns URL resolution, authentication, serialization, error parsing, redirects, retries, and timeouts. The core never reads or stores credentials.
73
+
74
+ Custom query requests currently target the Data Manager `main` contract and
75
+ send both `dataSourceId` and `parameters`. The recorded `alpha` contract accepts
76
+ that body but ignores `dataSourceId`, resolving the data source from the
77
+ authenticated app instead. The SDK does not retry this POST with another body
78
+ because the first request can already execute.
79
+
80
+ ## Error mapping
81
+
82
+ By default, invalid configuration and invalid responses throw `SdkCoreConfigurationError` and `SdkCoreResponseError`. A concrete SDK can inject an `SdkCoreErrorFactory` so these failures keep that SDK's established public error classes.
83
+
84
+ ## Development
85
+
86
+ ```bash
87
+ npm install
88
+ npm run check
89
+ ```
90
+
91
+ The build produces ESM, CommonJS, `.d.ts`, and `.d.cts` artifacts. Package smoke tests install the generated tarball into a clean consumer and validate both module systems and TypeScript resolution.
@@ -0,0 +1,31 @@
1
+ # Contract fixtures
2
+
3
+ `manifest.json` discovers the current SDK-PARITY-001 contract and every packaged
4
+ version. Each entry pins the exact fixture bytes with SHA-256. The versioned
5
+ fixtures record the semantic MCP to JavaScript to Python mapping and the request,
6
+ response, and error cases shared by the SDK test suites.
7
+
8
+ The fixture is source data, not a public JavaScript API. A breaking fixture
9
+ change requires a new version directory. Consumers may vendor the exact bytes
10
+ and pin their copy with a SHA-256 digest so their tests never depend on network
11
+ access.
12
+
13
+ Core executes one success case for every operation plus Core-owned response
14
+ validation cases. Functions JavaScript inherits those checks from Core and must
15
+ consume every HTTP adapter case itself. Python does not depend on Core, so it
16
+ must consume every success, response-validation, and HTTP adapter case. The
17
+ consumer requirements in the fixture make those obligations machine-readable.
18
+
19
+ ## Custom query transition
20
+
21
+ The `customQueryTransition` section intentionally models two different server
22
+ contracts:
23
+
24
+ - Data Manager `main` consumes `dataSourceId` and `parameters`.
25
+ - Data Manager `alpha` accepts that same body, ignores `dataSourceId` during
26
+ deserialization, and resolves the data source from the authenticated app.
27
+
28
+ The current SDK release still targets `main`, but its body is transport-compatible
29
+ with the recorded `alpha` contract. The semantics differ because alpha ignores
30
+ the supplied identifier. Do not add an automatic POST fallback because the first
31
+ request can already execute and a retry could execute the query twice.
@@ -0,0 +1,11 @@
1
+ {
2
+ "contract": "SDK-PARITY-001",
3
+ "current": "0.1.0",
4
+ "versions": [
5
+ {
6
+ "version": "0.1.0",
7
+ "path": "v0.1.0/sdk-parity.json",
8
+ "sha256": "600be3688cea7cfef16a8cf347516e87949b8e4151efb2c4136a2345557dde70"
9
+ }
10
+ ]
11
+ }