inklok-sdk-node 0.1.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 +21 -0
- package/README.md +44 -0
- package/dist/client.d.ts +29 -0
- package/dist/client.js +41 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +8 -0
- package/package.json +34 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Ryan Erickson
|
|
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,44 @@
|
|
|
1
|
+
# inklok-sdk-node
|
|
2
|
+
|
|
3
|
+
Node.js SDK for Inklok/OpaqueInk public API. Thin wrapper around the public endpoints; no business logic. Used as a middle-man by opaqueink Next.js instead of calling the API directly.
|
|
4
|
+
|
|
5
|
+
## Setup
|
|
6
|
+
|
|
7
|
+
1. Copy `.npmrc.example` to `.npmrc` and configure GitHub Packages auth (for `@ryan-m-erickson/api-spec`):
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
@ryan-m-erickson:registry=https://npm.pkg.github.com
|
|
11
|
+
//npm.pkg.github.com/:_authToken=YOUR_TOKEN
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
2. Install and build:
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm install
|
|
18
|
+
npm run build
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
3. Codegen: Types are generated from the OpenAPI spec (`@ryan-m-erickson/api-spec`). Run `npm run codegen` to regenerate `src/types.d.ts` after updating the spec dependency.
|
|
22
|
+
|
|
23
|
+
## Usage
|
|
24
|
+
|
|
25
|
+
```ts
|
|
26
|
+
import { InklokClient } from "inklok-sdk-node";
|
|
27
|
+
|
|
28
|
+
const client = new InklokClient({
|
|
29
|
+
baseUrl: "https://xxx.execute-api.us-east-2.amazonaws.com/prod",
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
const metadata = await client.listOrkMetadataV1({
|
|
33
|
+
orgId: "org-123",
|
|
34
|
+
accessToken: "jwt-token",
|
|
35
|
+
});
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Contract
|
|
39
|
+
|
|
40
|
+
Request/response shapes are defined by the OpenAPI spec (`@ryan-m-erickson/api-spec`). The SDK uses codegen (`openapi-typescript`) to derive types—no custom type definitions. See `src/types.d.ts` (generated).
|
|
41
|
+
|
|
42
|
+
## CI/CD
|
|
43
|
+
|
|
44
|
+
On merge to `main`, GitHub Actions publishes to npm. Add an **NPM_TOKEN** secret (classic token with "Automation" type from [npmjs.com/settings](https://www.npmjs.com/settings)) to the repo. If `@ryan-m-erickson/api-spec` is private, also add a **GH_PACKAGES_TOKEN** (PAT with `read:packages`) and update the workflow to use it for GitHub Packages auth.
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Inklok SDK client - thin wrapper over the public API.
|
|
3
|
+
* No business logic; fetch and return only.
|
|
4
|
+
*/
|
|
5
|
+
import type { components, operations } from "./types";
|
|
6
|
+
export type OrkMetadata = components["schemas"]["OrkMetadata"];
|
|
7
|
+
/** Request shape for listOrkMetadataV1 (from OpenAPI). */
|
|
8
|
+
export interface ListOrkMetadataV1Params {
|
|
9
|
+
orgId: string;
|
|
10
|
+
accessToken: string;
|
|
11
|
+
}
|
|
12
|
+
/** Response shape for listOrkMetadataV1 (from OpenAPI). */
|
|
13
|
+
export type ListOrkMetadataV1Response = operations["listOrkMetadataV1"]["responses"]["200"]["content"]["application/json"];
|
|
14
|
+
export interface InklokClientOptions {
|
|
15
|
+
/** Base URL of the API (e.g. https://xxx.execute-api.us-east-2.amazonaws.com/prod). */
|
|
16
|
+
baseUrl: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Thin client for Inklok public API. Fetches and returns; no business logic.
|
|
20
|
+
*/
|
|
21
|
+
export declare class InklokClient {
|
|
22
|
+
private readonly baseUrl;
|
|
23
|
+
constructor(options: InklokClientOptions);
|
|
24
|
+
/**
|
|
25
|
+
* GET /v1/ork/metadata - list ORK metadata for an org.
|
|
26
|
+
* Contract from OpenAPI; propagates API errors.
|
|
27
|
+
*/
|
|
28
|
+
listOrkMetadataV1(params: ListOrkMetadataV1Params): Promise<ListOrkMetadataV1Response>;
|
|
29
|
+
}
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Inklok SDK client - thin wrapper over the public API.
|
|
4
|
+
* No business logic; fetch and return only.
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.InklokClient = void 0;
|
|
8
|
+
/**
|
|
9
|
+
* Thin client for Inklok public API. Fetches and returns; no business logic.
|
|
10
|
+
*/
|
|
11
|
+
class InklokClient {
|
|
12
|
+
baseUrl;
|
|
13
|
+
constructor(options) {
|
|
14
|
+
this.baseUrl = options.baseUrl.replace(/\/$/, "");
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* GET /v1/ork/metadata - list ORK metadata for an org.
|
|
18
|
+
* Contract from OpenAPI; propagates API errors.
|
|
19
|
+
*/
|
|
20
|
+
async listOrkMetadataV1(params) {
|
|
21
|
+
const url = `${this.baseUrl}/v1/ork/metadata`;
|
|
22
|
+
const res = await fetch(url, {
|
|
23
|
+
method: "GET",
|
|
24
|
+
headers: {
|
|
25
|
+
"X-Inklok-Org-Id": params.orgId,
|
|
26
|
+
Authorization: `Bearer ${params.accessToken}`,
|
|
27
|
+
Accept: "application/json",
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
if (!res.ok) {
|
|
31
|
+
const body = await res.text();
|
|
32
|
+
const err = new Error(`API error ${res.status}: ${body}`);
|
|
33
|
+
err.status = res.status;
|
|
34
|
+
err.body = body;
|
|
35
|
+
throw err;
|
|
36
|
+
}
|
|
37
|
+
const json = (await res.json());
|
|
38
|
+
return json;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
exports.InklokClient = InklokClient;
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* inklok-sdk-node - Node.js SDK for Inklok/OpaqueInk public API
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.InklokClient = void 0;
|
|
7
|
+
var client_1 = require("./client");
|
|
8
|
+
Object.defineProperty(exports, "InklokClient", { enumerable: true, get: function () { return client_1.InklokClient; } });
|
package/package.json
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "inklok-sdk-node",
|
|
3
|
+
"version": "0.1.3",
|
|
4
|
+
"description": "Node.js SDK for OpaqueInk/Inklok public API - thin wrapper, no business logic",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "https://github.com/ryan-m-erickson/inklok-sdk-node"
|
|
8
|
+
},
|
|
9
|
+
"publishConfig": {
|
|
10
|
+
"access": "public"
|
|
11
|
+
},
|
|
12
|
+
"main": "dist/index.js",
|
|
13
|
+
"types": "dist/index.d.ts",
|
|
14
|
+
"files": [
|
|
15
|
+
"dist"
|
|
16
|
+
],
|
|
17
|
+
"scripts": {
|
|
18
|
+
"codegen": "openapi-typescript node_modules/@ryan-m-erickson/api-spec/openapi.yaml -o src/types.d.ts",
|
|
19
|
+
"prebuild": "npm run codegen",
|
|
20
|
+
"build": "tsc",
|
|
21
|
+
"prepublishOnly": "npm run build"
|
|
22
|
+
},
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"@ryan-m-erickson/api-spec": "^1.0.2"
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"@types/node": "^20.0.0",
|
|
28
|
+
"openapi-typescript": "^7.0.0",
|
|
29
|
+
"typescript": "^5.0.0"
|
|
30
|
+
},
|
|
31
|
+
"engines": {
|
|
32
|
+
"node": ">=18.0.0"
|
|
33
|
+
}
|
|
34
|
+
}
|