inklok-sdk-node 0.1.3 → 0.1.5
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/README.md +22 -18
- package/dist/client.d.ts +14 -14
- package/dist/client.js +44 -24
- package/dist/endpoints/org-members.d.ts +14 -0
- package/dist/endpoints/org-members.js +19 -0
- package/dist/endpoints/ork-metadata.d.ts +13 -0
- package/dist/endpoints/ork-metadata.js +17 -0
- package/dist/http.d.ts +15 -0
- package/dist/http.js +29 -0
- package/dist/index.d.ts +1 -1
- package/package.json +2 -6
package/README.md
CHANGED
|
@@ -2,23 +2,11 @@
|
|
|
2
2
|
|
|
3
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
4
|
|
|
5
|
-
##
|
|
5
|
+
## Install
|
|
6
6
|
|
|
7
|
-
|
|
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.
|
|
7
|
+
```bash
|
|
8
|
+
npm install inklok-sdk-node
|
|
9
|
+
```
|
|
22
10
|
|
|
23
11
|
## Usage
|
|
24
12
|
|
|
@@ -33,12 +21,28 @@ const metadata = await client.listOrkMetadataV1({
|
|
|
33
21
|
orgId: "org-123",
|
|
34
22
|
accessToken: "jwt-token",
|
|
35
23
|
});
|
|
24
|
+
|
|
25
|
+
const members = await client.listOrgMembersV1({
|
|
26
|
+
orgId: "org-123",
|
|
27
|
+
accessToken: "jwt-token",
|
|
28
|
+
});
|
|
36
29
|
```
|
|
37
30
|
|
|
38
31
|
## Contract
|
|
39
32
|
|
|
40
|
-
Request/response shapes
|
|
33
|
+
Request/response shapes come from the OpenAPI spec (see `api-spec` dependency). Types are generated with `openapi-typescript`; see `src/types.d.ts` (generated).
|
|
34
|
+
|
|
35
|
+
## Development
|
|
36
|
+
|
|
37
|
+
To build from source: copy `.npmrc.example` to `.npmrc` and configure GitHub Packages auth (see that file), then:
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
npm install
|
|
41
|
+
npm run build
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Types are regenerated from the spec on build; run `npm run codegen` to regenerate only `src/types.d.ts`.
|
|
41
45
|
|
|
42
46
|
## CI/CD
|
|
43
47
|
|
|
44
|
-
On merge to `main`, GitHub Actions publishes to npm. Add an **NPM_TOKEN** secret (classic token
|
|
48
|
+
On merge to `main`, GitHub Actions publishes to npm. Add an **NPM_TOKEN** secret (classic token, "Automation" type, from [npmjs.com/settings](https://www.npmjs.com/settings)). If the api-spec dependency is private, add **GH_PACKAGES_TOKEN** (PAT with `read:packages`) and wire the workflow to use it for GitHub Packages.
|
package/dist/client.d.ts
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Inklok SDK client - thin
|
|
3
|
-
*
|
|
2
|
+
* Inklok SDK client - thin facade over endpoint modules.
|
|
3
|
+
* Each method delegates to one endpoint module for scalability and testability.
|
|
4
4
|
*/
|
|
5
|
-
import type { components
|
|
5
|
+
import type { components } from "./types";
|
|
6
|
+
import * as orkMetadata from "./endpoints/ork-metadata";
|
|
7
|
+
import * as orgMembers from "./endpoints/org-members";
|
|
6
8
|
export type OrkMetadata = components["schemas"]["OrkMetadata"];
|
|
7
|
-
|
|
8
|
-
export
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
/** Response shape for listOrkMetadataV1 (from OpenAPI). */
|
|
13
|
-
export type ListOrkMetadataV1Response = operations["listOrkMetadataV1"]["responses"]["200"]["content"]["application/json"];
|
|
9
|
+
export type OrgMember = components["schemas"]["OrgMember"];
|
|
10
|
+
export type ListOrkMetadataV1Params = orkMetadata.ListOrkMetadataV1Params;
|
|
11
|
+
export type ListOrkMetadataV1Response = orkMetadata.ListOrkMetadataV1Response;
|
|
12
|
+
export type ListOrgMembersV1Params = orgMembers.ListOrgMembersV1Params;
|
|
13
|
+
export type ListOrgMembersV1Response = orgMembers.ListOrgMembersV1Response;
|
|
14
14
|
export interface InklokClientOptions {
|
|
15
15
|
/** Base URL of the API (e.g. https://xxx.execute-api.us-east-2.amazonaws.com/prod). */
|
|
16
16
|
baseUrl: string;
|
|
17
17
|
}
|
|
18
|
-
/**
|
|
19
|
-
* Thin client for Inklok public API. Fetches and returns; no business logic.
|
|
20
|
-
*/
|
|
21
18
|
export declare class InklokClient {
|
|
22
19
|
private readonly baseUrl;
|
|
23
20
|
constructor(options: InklokClientOptions);
|
|
24
21
|
/**
|
|
25
22
|
* GET /v1/ork/metadata - list ORK metadata for an org.
|
|
26
|
-
* Contract from OpenAPI; propagates API errors.
|
|
27
23
|
*/
|
|
28
24
|
listOrkMetadataV1(params: ListOrkMetadataV1Params): Promise<ListOrkMetadataV1Response>;
|
|
25
|
+
/**
|
|
26
|
+
* GET /v1/orgs/{orgId}/members - list members of an organization.
|
|
27
|
+
*/
|
|
28
|
+
listOrgMembersV1(params: ListOrgMembersV1Params): Promise<ListOrgMembersV1Response>;
|
|
29
29
|
}
|
package/dist/client.js
CHANGED
|
@@ -1,13 +1,45 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
|
-
* Inklok SDK client - thin
|
|
4
|
-
*
|
|
3
|
+
* Inklok SDK client - thin facade over endpoint modules.
|
|
4
|
+
* Each method delegates to one endpoint module for scalability and testability.
|
|
5
5
|
*/
|
|
6
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
7
|
+
if (k2 === undefined) k2 = k;
|
|
8
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
9
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
10
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
11
|
+
}
|
|
12
|
+
Object.defineProperty(o, k2, desc);
|
|
13
|
+
}) : (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
o[k2] = m[k];
|
|
16
|
+
}));
|
|
17
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
18
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
19
|
+
}) : function(o, v) {
|
|
20
|
+
o["default"] = v;
|
|
21
|
+
});
|
|
22
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
23
|
+
var ownKeys = function(o) {
|
|
24
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
25
|
+
var ar = [];
|
|
26
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
27
|
+
return ar;
|
|
28
|
+
};
|
|
29
|
+
return ownKeys(o);
|
|
30
|
+
};
|
|
31
|
+
return function (mod) {
|
|
32
|
+
if (mod && mod.__esModule) return mod;
|
|
33
|
+
var result = {};
|
|
34
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
35
|
+
__setModuleDefault(result, mod);
|
|
36
|
+
return result;
|
|
37
|
+
};
|
|
38
|
+
})();
|
|
6
39
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
40
|
exports.InklokClient = void 0;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
*/
|
|
41
|
+
const orkMetadata = __importStar(require("./endpoints/ork-metadata"));
|
|
42
|
+
const orgMembers = __importStar(require("./endpoints/org-members"));
|
|
11
43
|
class InklokClient {
|
|
12
44
|
baseUrl;
|
|
13
45
|
constructor(options) {
|
|
@@ -15,27 +47,15 @@ class InklokClient {
|
|
|
15
47
|
}
|
|
16
48
|
/**
|
|
17
49
|
* GET /v1/ork/metadata - list ORK metadata for an org.
|
|
18
|
-
* Contract from OpenAPI; propagates API errors.
|
|
19
50
|
*/
|
|
20
51
|
async listOrkMetadataV1(params) {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
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;
|
|
52
|
+
return orkMetadata.listOrkMetadataV1(this.baseUrl, params);
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* GET /v1/orgs/{orgId}/members - list members of an organization.
|
|
56
|
+
*/
|
|
57
|
+
async listOrgMembersV1(params) {
|
|
58
|
+
return orgMembers.listOrgMembersV1(this.baseUrl, params);
|
|
39
59
|
}
|
|
40
60
|
}
|
|
41
61
|
exports.InklokClient = InklokClient;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Org members endpoint: GET /v1/orgs/{orgId}/members
|
|
3
|
+
*/
|
|
4
|
+
import type { operations } from "../types";
|
|
5
|
+
export type ListOrgMembersV1Response = operations["listOrgMembersV1"]["responses"]["200"]["content"]["application/json"];
|
|
6
|
+
export interface ListOrgMembersV1Params {
|
|
7
|
+
orgId: string;
|
|
8
|
+
accessToken: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* GET /v1/orgs/{orgId}/members - list members of an organization.
|
|
12
|
+
* Matches the public API contract used by the OpaqueInk /org page.
|
|
13
|
+
*/
|
|
14
|
+
export declare function listOrgMembersV1(baseUrl: string, params: ListOrgMembersV1Params): Promise<ListOrgMembersV1Response>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Org members endpoint: GET /v1/orgs/{orgId}/members
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.listOrgMembersV1 = listOrgMembersV1;
|
|
7
|
+
const http_1 = require("../http");
|
|
8
|
+
/**
|
|
9
|
+
* GET /v1/orgs/{orgId}/members - list members of an organization.
|
|
10
|
+
* Matches the public API contract used by the OpaqueInk /org page.
|
|
11
|
+
*/
|
|
12
|
+
async function listOrgMembersV1(baseUrl, params) {
|
|
13
|
+
const base = baseUrl.replace(/\/$/, "");
|
|
14
|
+
const url = `${base}/v1/orgs/${encodeURIComponent(params.orgId)}/members`;
|
|
15
|
+
return (0, http_1.getAuthenticated)(url, {
|
|
16
|
+
accessToken: params.accessToken,
|
|
17
|
+
orgId: params.orgId,
|
|
18
|
+
});
|
|
19
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ORK metadata endpoint: GET /v1/ork/metadata
|
|
3
|
+
*/
|
|
4
|
+
import type { operations } from "../types";
|
|
5
|
+
export type ListOrkMetadataV1Response = operations["listOrkMetadataV1"]["responses"]["200"]["content"]["application/json"];
|
|
6
|
+
export interface ListOrkMetadataV1Params {
|
|
7
|
+
orgId: string;
|
|
8
|
+
accessToken: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* GET /v1/ork/metadata - list ORK metadata for an org.
|
|
12
|
+
*/
|
|
13
|
+
export declare function listOrkMetadataV1(baseUrl: string, params: ListOrkMetadataV1Params): Promise<ListOrkMetadataV1Response>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* ORK metadata endpoint: GET /v1/ork/metadata
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.listOrkMetadataV1 = listOrkMetadataV1;
|
|
7
|
+
const http_1 = require("../http");
|
|
8
|
+
/**
|
|
9
|
+
* GET /v1/ork/metadata - list ORK metadata for an org.
|
|
10
|
+
*/
|
|
11
|
+
async function listOrkMetadataV1(baseUrl, params) {
|
|
12
|
+
const url = `${baseUrl.replace(/\/$/, "")}/v1/ork/metadata`;
|
|
13
|
+
return (0, http_1.getAuthenticated)(url, {
|
|
14
|
+
accessToken: params.accessToken,
|
|
15
|
+
orgId: params.orgId,
|
|
16
|
+
});
|
|
17
|
+
}
|
package/dist/http.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared HTTP helper for authenticated GET requests.
|
|
3
|
+
* Used by endpoint modules to avoid duplicating fetch/error logic.
|
|
4
|
+
*/
|
|
5
|
+
export interface AuthenticatedGetOptions {
|
|
6
|
+
/** Bearer token (JWT). */
|
|
7
|
+
accessToken: string;
|
|
8
|
+
/** If set, adds X-Inklok-Org-Id header. */
|
|
9
|
+
orgId?: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Performs an authenticated GET and returns parsed JSON.
|
|
13
|
+
* Throws on non-OK response with status and body attached.
|
|
14
|
+
*/
|
|
15
|
+
export declare function getAuthenticated<T>(url: string, options: AuthenticatedGetOptions): Promise<T>;
|
package/dist/http.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Shared HTTP helper for authenticated GET requests.
|
|
4
|
+
* Used by endpoint modules to avoid duplicating fetch/error logic.
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.getAuthenticated = getAuthenticated;
|
|
8
|
+
/**
|
|
9
|
+
* Performs an authenticated GET and returns parsed JSON.
|
|
10
|
+
* Throws on non-OK response with status and body attached.
|
|
11
|
+
*/
|
|
12
|
+
async function getAuthenticated(url, options) {
|
|
13
|
+
const headers = {
|
|
14
|
+
Authorization: `Bearer ${options.accessToken}`,
|
|
15
|
+
Accept: "application/json",
|
|
16
|
+
};
|
|
17
|
+
if (options.orgId != null) {
|
|
18
|
+
headers["X-Inklok-Org-Id"] = options.orgId;
|
|
19
|
+
}
|
|
20
|
+
const res = await fetch(url, { method: "GET", headers });
|
|
21
|
+
if (!res.ok) {
|
|
22
|
+
const body = await res.text();
|
|
23
|
+
const err = new Error(`API error ${res.status}: ${body}`);
|
|
24
|
+
err.status = res.status;
|
|
25
|
+
err.body = body;
|
|
26
|
+
throw err;
|
|
27
|
+
}
|
|
28
|
+
return (await res.json());
|
|
29
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* inklok-sdk-node - Node.js SDK for Inklok/OpaqueInk public API
|
|
3
3
|
*/
|
|
4
|
-
export { InklokClient, ListOrkMetadataV1Params, ListOrkMetadataV1Response, OrkMetadata } from "./client";
|
|
4
|
+
export { InklokClient, type ListOrkMetadataV1Params, type ListOrkMetadataV1Response, type ListOrgMembersV1Params, type ListOrgMembersV1Response, type OrkMetadata, type OrgMember, } from "./client";
|
package/package.json
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "inklok-sdk-node",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "Node.js SDK for
|
|
5
|
-
"repository": {
|
|
6
|
-
"type": "git",
|
|
7
|
-
"url": "https://github.com/ryan-m-erickson/inklok-sdk-node"
|
|
8
|
-
},
|
|
3
|
+
"version": "0.1.5",
|
|
4
|
+
"description": "Node.js SDK for Inklok public API",
|
|
9
5
|
"publishConfig": {
|
|
10
6
|
"access": "public"
|
|
11
7
|
},
|