inklok-sdk-node 0.1.6 → 0.1.8

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/dist/client.d.ts CHANGED
@@ -3,12 +3,24 @@
3
3
  * Each method delegates to one endpoint module for scalability and testability.
4
4
  */
5
5
  import type { components } from "./types";
6
+ import * as documents from "./endpoints/documents";
6
7
  import * as orkMetadata from "./endpoints/ork-metadata";
7
8
  import * as orgMembers from "./endpoints/org-members";
8
9
  import * as meOrgs from "./endpoints/me-orgs";
10
+ export type DocumentMetadata = components["schemas"]["DocumentMetadata"];
9
11
  export type OrkMetadata = components["schemas"]["OrkMetadata"];
10
12
  export type OrgMember = components["schemas"]["OrgMember"];
11
13
  export type MeOrg = components["schemas"]["MeOrg"];
14
+ export type CreateDocumentV1Params = documents.CreateDocumentV1Params;
15
+ export type CreateDocumentV1Response = documents.CreateDocumentV1Response;
16
+ export type ListDocumentsV1Params = documents.ListDocumentsV1Params;
17
+ export type ListDocumentsV1Response = documents.ListDocumentsV1Response;
18
+ export type GetDocumentV1Params = documents.GetDocumentV1Params;
19
+ export type GetDocumentV1Response = documents.GetDocumentV1Response;
20
+ export type UploadDocumentV1Params = documents.UploadDocumentV1Params;
21
+ export type UploadDocumentV1Response = documents.UploadDocumentV1Response;
22
+ export type DeleteDocumentV1Params = documents.DeleteDocumentV1Params;
23
+ export type DeleteDocumentV1Response = documents.DeleteDocumentV1Response;
12
24
  export type ListOrkMetadataV1Params = orkMetadata.ListOrkMetadataV1Params;
13
25
  export type ListOrkMetadataV1Response = orkMetadata.ListOrkMetadataV1Response;
14
26
  export type ListOrgMembersV1Params = orgMembers.ListOrgMembersV1Params;
@@ -34,4 +46,14 @@ export declare class InklokClient {
34
46
  * GET /me/orgs - list organizations for the current user.
35
47
  */
36
48
  listMeOrgs(params: ListMeOrgsParams): Promise<ListMeOrgsResponse>;
49
+ /** POST /v1/documents - create document record (metadata only, draft). */
50
+ createDocumentV1(params: CreateDocumentV1Params): Promise<CreateDocumentV1Response>;
51
+ /** GET /v1/documents - list documents for the org. */
52
+ listDocumentsV1(params: ListDocumentsV1Params): Promise<ListDocumentsV1Response>;
53
+ /** GET /v1/documents/{documentId} - get one document metadata. */
54
+ getDocumentV1(params: GetDocumentV1Params): Promise<GetDocumentV1Response>;
55
+ /** POST /v1/documents/{documentId}/upload - upload PDF (encrypted bytes); finalizes material document. */
56
+ uploadDocumentV1(params: UploadDocumentV1Params): Promise<UploadDocumentV1Response>;
57
+ /** DELETE /v1/documents/{documentId} - delete document (metadata and object). */
58
+ deleteDocumentV1(params: DeleteDocumentV1Params): Promise<void>;
37
59
  }
package/dist/client.js CHANGED
@@ -38,6 +38,7 @@ var __importStar = (this && this.__importStar) || (function () {
38
38
  })();
39
39
  Object.defineProperty(exports, "__esModule", { value: true });
40
40
  exports.InklokClient = void 0;
41
+ const documents = __importStar(require("./endpoints/documents"));
41
42
  const orkMetadata = __importStar(require("./endpoints/ork-metadata"));
42
43
  const orgMembers = __importStar(require("./endpoints/org-members"));
43
44
  const meOrgs = __importStar(require("./endpoints/me-orgs"));
@@ -64,5 +65,25 @@ class InklokClient {
64
65
  async listMeOrgs(params) {
65
66
  return meOrgs.listMeOrgs(this.baseUrl, params);
66
67
  }
68
+ /** POST /v1/documents - create document record (metadata only, draft). */
69
+ async createDocumentV1(params) {
70
+ return documents.createDocumentV1(this.baseUrl, params);
71
+ }
72
+ /** GET /v1/documents - list documents for the org. */
73
+ async listDocumentsV1(params) {
74
+ return documents.listDocumentsV1(this.baseUrl, params);
75
+ }
76
+ /** GET /v1/documents/{documentId} - get one document metadata. */
77
+ async getDocumentV1(params) {
78
+ return documents.getDocumentV1(this.baseUrl, params);
79
+ }
80
+ /** POST /v1/documents/{documentId}/upload - upload PDF (encrypted bytes); finalizes material document. */
81
+ async uploadDocumentV1(params) {
82
+ return documents.uploadDocumentV1(this.baseUrl, params);
83
+ }
84
+ /** DELETE /v1/documents/{documentId} - delete document (metadata and object). */
85
+ async deleteDocumentV1(params) {
86
+ return documents.deleteDocumentV1(this.baseUrl, params);
87
+ }
67
88
  }
68
89
  exports.InklokClient = InklokClient;
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Document lifecycle v1 endpoints: create, list, get, upload.
3
+ * All require Bearer JWT and X-Inklok-Org-Id (orgId in params).
4
+ */
5
+ import type { components, operations } from "../types";
6
+ export type DocumentMetadata = components["schemas"]["DocumentMetadata"];
7
+ export type CreateDocumentV1Response = operations["createDocumentV1"]["responses"]["201"]["content"]["application/json"];
8
+ export type ListDocumentsV1Response = operations["listDocumentsV1"]["responses"]["200"]["content"]["application/json"];
9
+ export type GetDocumentV1Response = operations["getDocumentV1"]["responses"]["200"]["content"]["application/json"];
10
+ export type UploadDocumentV1Response = operations["uploadDocumentV1"]["responses"]["200"]["content"]["application/json"];
11
+ export type DeleteDocumentV1Response = operations["deleteDocumentV1"]["responses"]["204"];
12
+ export interface CreateDocumentV1Params {
13
+ orgId: string;
14
+ accessToken: string;
15
+ /** Optional metadata (implementation in _core). */
16
+ body?: Record<string, unknown>;
17
+ }
18
+ export interface ListDocumentsV1Params {
19
+ orgId: string;
20
+ accessToken: string;
21
+ }
22
+ export interface GetDocumentV1Params {
23
+ documentId: string;
24
+ orgId: string;
25
+ accessToken: string;
26
+ }
27
+ export interface UploadDocumentV1Params {
28
+ documentId: string;
29
+ orgId: string;
30
+ accessToken: string;
31
+ /** Encrypted PDF bytes (opaque to infra). */
32
+ body: ArrayBuffer | Uint8Array;
33
+ }
34
+ export interface DeleteDocumentV1Params {
35
+ documentId: string;
36
+ orgId: string;
37
+ accessToken: string;
38
+ }
39
+ export declare function createDocumentV1(baseUrl: string, params: CreateDocumentV1Params): Promise<CreateDocumentV1Response>;
40
+ export declare function listDocumentsV1(baseUrl: string, params: ListDocumentsV1Params): Promise<ListDocumentsV1Response>;
41
+ export declare function getDocumentV1(baseUrl: string, params: GetDocumentV1Params): Promise<GetDocumentV1Response>;
42
+ export declare function uploadDocumentV1(baseUrl: string, params: UploadDocumentV1Params): Promise<UploadDocumentV1Response>;
43
+ export declare function deleteDocumentV1(baseUrl: string, params: DeleteDocumentV1Params): Promise<void>;
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ /**
3
+ * Document lifecycle v1 endpoints: create, list, get, upload.
4
+ * All require Bearer JWT and X-Inklok-Org-Id (orgId in params).
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.createDocumentV1 = createDocumentV1;
8
+ exports.listDocumentsV1 = listDocumentsV1;
9
+ exports.getDocumentV1 = getDocumentV1;
10
+ exports.uploadDocumentV1 = uploadDocumentV1;
11
+ exports.deleteDocumentV1 = deleteDocumentV1;
12
+ const http_1 = require("../http");
13
+ const base = (url) => url.replace(/\/$/, "");
14
+ async function createDocumentV1(baseUrl, params) {
15
+ const url = `${base(baseUrl)}/v1/documents`;
16
+ return (0, http_1.postAuthenticated)(url, {
17
+ accessToken: params.accessToken,
18
+ orgId: params.orgId,
19
+ }, params.body);
20
+ }
21
+ async function listDocumentsV1(baseUrl, params) {
22
+ const url = `${base(baseUrl)}/v1/documents`;
23
+ return (0, http_1.getAuthenticated)(url, {
24
+ accessToken: params.accessToken,
25
+ orgId: params.orgId,
26
+ });
27
+ }
28
+ async function getDocumentV1(baseUrl, params) {
29
+ const url = `${base(baseUrl)}/v1/documents/${encodeURIComponent(params.documentId)}`;
30
+ return (0, http_1.getAuthenticated)(url, {
31
+ accessToken: params.accessToken,
32
+ orgId: params.orgId,
33
+ });
34
+ }
35
+ async function uploadDocumentV1(baseUrl, params) {
36
+ const url = `${base(baseUrl)}/v1/documents/${encodeURIComponent(params.documentId)}/upload`;
37
+ return (0, http_1.postAuthenticatedBinary)(url, {
38
+ accessToken: params.accessToken,
39
+ orgId: params.orgId,
40
+ }, params.body);
41
+ }
42
+ async function deleteDocumentV1(baseUrl, params) {
43
+ const url = `${base(baseUrl)}/v1/documents/${encodeURIComponent(params.documentId)}`;
44
+ return (0, http_1.deleteAuthenticated)(url, {
45
+ accessToken: params.accessToken,
46
+ orgId: params.orgId,
47
+ });
48
+ }
package/dist/http.d.ts CHANGED
@@ -13,3 +13,26 @@ export interface AuthenticatedGetOptions {
13
13
  * Throws on non-OK response with status and body attached.
14
14
  */
15
15
  export declare function getAuthenticated<T>(url: string, options: AuthenticatedGetOptions): Promise<T>;
16
+ export interface AuthenticatedPostOptions {
17
+ accessToken: string;
18
+ orgId?: string;
19
+ }
20
+ /**
21
+ * Performs an authenticated POST with optional JSON body and returns parsed JSON.
22
+ * Throws on non-OK response with status and body attached.
23
+ */
24
+ export declare function postAuthenticated<T>(url: string, options: AuthenticatedPostOptions, body?: Record<string, unknown>): Promise<T>;
25
+ export interface AuthenticatedDeleteOptions {
26
+ accessToken: string;
27
+ orgId?: string;
28
+ }
29
+ /**
30
+ * Performs an authenticated DELETE. Expects 204 No Content on success.
31
+ * Throws on non-OK response with status and body attached.
32
+ */
33
+ export declare function deleteAuthenticated(url: string, options: AuthenticatedDeleteOptions): Promise<void>;
34
+ /**
35
+ * Performs an authenticated POST with binary body (e.g. application/octet-stream) and returns parsed JSON.
36
+ * Throws on non-OK response with status and body attached.
37
+ */
38
+ export declare function postAuthenticatedBinary<T>(url: string, options: AuthenticatedPostOptions, body: ArrayBuffer | Uint8Array): Promise<T>;
package/dist/http.js CHANGED
@@ -5,6 +5,9 @@
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.getAuthenticated = getAuthenticated;
8
+ exports.postAuthenticated = postAuthenticated;
9
+ exports.deleteAuthenticated = deleteAuthenticated;
10
+ exports.postAuthenticatedBinary = postAuthenticatedBinary;
8
11
  /**
9
12
  * Performs an authenticated GET and returns parsed JSON.
10
13
  * Throws on non-OK response with status and body attached.
@@ -27,3 +30,78 @@ async function getAuthenticated(url, options) {
27
30
  }
28
31
  return (await res.json());
29
32
  }
33
+ /**
34
+ * Performs an authenticated POST with optional JSON body and returns parsed JSON.
35
+ * Throws on non-OK response with status and body attached.
36
+ */
37
+ async function postAuthenticated(url, options, body) {
38
+ const headers = {
39
+ Authorization: `Bearer ${options.accessToken}`,
40
+ "Content-Type": "application/json",
41
+ Accept: "application/json",
42
+ };
43
+ if (options.orgId != null) {
44
+ headers["X-Inklok-Org-Id"] = options.orgId;
45
+ }
46
+ const res = await fetch(url, {
47
+ method: "POST",
48
+ headers,
49
+ body: body != null ? JSON.stringify(body) : undefined,
50
+ });
51
+ if (!res.ok) {
52
+ const text = await res.text();
53
+ const err = new Error(`API error ${res.status}: ${text}`);
54
+ err.status = res.status;
55
+ err.body = text;
56
+ throw err;
57
+ }
58
+ return (await res.json());
59
+ }
60
+ /**
61
+ * Performs an authenticated DELETE. Expects 204 No Content on success.
62
+ * Throws on non-OK response with status and body attached.
63
+ */
64
+ async function deleteAuthenticated(url, options) {
65
+ const headers = {
66
+ Authorization: `Bearer ${options.accessToken}`,
67
+ Accept: "application/json",
68
+ };
69
+ if (options.orgId != null) {
70
+ headers["X-Inklok-Org-Id"] = options.orgId;
71
+ }
72
+ const res = await fetch(url, { method: "DELETE", headers });
73
+ if (!res.ok) {
74
+ const text = await res.text();
75
+ const err = new Error(`API error ${res.status}: ${text}`);
76
+ err.status = res.status;
77
+ err.body = text;
78
+ throw err;
79
+ }
80
+ }
81
+ /**
82
+ * Performs an authenticated POST with binary body (e.g. application/octet-stream) and returns parsed JSON.
83
+ * Throws on non-OK response with status and body attached.
84
+ */
85
+ async function postAuthenticatedBinary(url, options, body) {
86
+ const headers = {
87
+ Authorization: `Bearer ${options.accessToken}`,
88
+ "Content-Type": "application/octet-stream",
89
+ Accept: "application/json",
90
+ };
91
+ if (options.orgId != null) {
92
+ headers["X-Inklok-Org-Id"] = options.orgId;
93
+ }
94
+ const res = await fetch(url, {
95
+ method: "POST",
96
+ headers,
97
+ body,
98
+ });
99
+ if (!res.ok) {
100
+ const text = await res.text();
101
+ const err = new Error(`API error ${res.status}: ${text}`);
102
+ err.status = res.status;
103
+ err.body = text;
104
+ throw err;
105
+ }
106
+ return (await res.json());
107
+ }
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, type ListMeOrgsParams, type ListMeOrgsResponse, type ListOrkMetadataV1Params, type ListOrkMetadataV1Response, type ListOrgMembersV1Params, type ListOrgMembersV1Response, type MeOrg, type OrkMetadata, type OrgMember, } from "./client";
4
+ export { InklokClient, type CreateDocumentV1Params, type CreateDocumentV1Response, type DocumentMetadata, type GetDocumentV1Params, type GetDocumentV1Response, type ListDocumentsV1Params, type ListDocumentsV1Response, type ListMeOrgsParams, type ListMeOrgsResponse, type ListOrkMetadataV1Params, type ListOrkMetadataV1Response, type ListOrgMembersV1Params, type ListOrgMembersV1Response, type MeOrg, type OrkMetadata, type OrgMember, type UploadDocumentV1Params, type UploadDocumentV1Response, type DeleteDocumentV1Params, type DeleteDocumentV1Response, } from "./client";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "inklok-sdk-node",
3
- "version": "0.1.6",
3
+ "version": "0.1.8",
4
4
  "description": "Node.js SDK for Inklok public API",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -11,7 +11,8 @@
11
11
  "dist"
12
12
  ],
13
13
  "scripts": {
14
- "codegen": "openapi-typescript node_modules/@ryan-m-erickson/api-spec/openapi.yaml -o src/types.d.ts",
14
+ "codegen": "node scripts/codegen.js",
15
+ "codegen:spec": "openapi-typescript node_modules/@ryan-m-erickson/api-spec/openapi.yaml -o src/types.d.ts",
15
16
  "prebuild": "npm run codegen",
16
17
  "build": "tsc",
17
18
  "prepublishOnly": "npm run build"