@greensecurity/javascript-sdk 0.10.2 → 0.12.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.
Files changed (177) hide show
  1. package/README.md +53 -0
  2. package/bin/mcp-server.js +39429 -0
  3. package/bin/mcp-server.js.map +301 -0
  4. package/funcs/organizationsGetFacility.js +1 -1
  5. package/funcs/organizationsGetFacility.js.map +1 -1
  6. package/funcs/organizationsListOrSearchFacilities.js +1 -1
  7. package/funcs/organizationsListOrSearchFacilities.js.map +1 -1
  8. package/funcs/userGetCurrentUser.js +1 -1
  9. package/funcs/userGetCurrentUser.js.map +1 -1
  10. package/funcs/userGetUserById.js +1 -1
  11. package/funcs/userGetUserById.js.map +1 -1
  12. package/funcs/userLogsUserIntoTheSystem.js +1 -1
  13. package/funcs/userLogsUserIntoTheSystem.js.map +1 -1
  14. package/funcs/userMagiclink.js +1 -1
  15. package/funcs/userMagiclink.js.map +1 -1
  16. package/funcs/userPassword.js +1 -1
  17. package/funcs/userPassword.js.map +1 -1
  18. package/funcs/userPasswordResetRequest.js +1 -1
  19. package/funcs/userPasswordResetRequest.js.map +1 -1
  20. package/funcs/vendorsCreateVendorRegistration.js +1 -1
  21. package/funcs/vendorsCreateVendorRegistration.js.map +1 -1
  22. package/funcs/vendorsListVendorJobTitles.js +1 -1
  23. package/funcs/vendorsListVendorJobTitles.js.map +1 -1
  24. package/jsr.json +1 -1
  25. package/lib/config.d.ts +6 -6
  26. package/lib/config.d.ts.map +1 -1
  27. package/lib/config.js +3 -3
  28. package/lib/config.js.map +1 -1
  29. package/lib/files.js.map +1 -1
  30. package/lib/primitives.d.ts +3 -0
  31. package/lib/primitives.d.ts.map +1 -1
  32. package/lib/primitives.js +7 -0
  33. package/lib/primitives.js.map +1 -1
  34. package/mcp-server/build.d.mts.map +1 -0
  35. package/mcp-server/build.mjs +14 -0
  36. package/mcp-server/build.mjs.map +1 -0
  37. package/mcp-server/cli/start/command.d.ts +2 -0
  38. package/mcp-server/cli/start/command.d.ts.map +1 -0
  39. package/mcp-server/cli/start/command.js +137 -0
  40. package/mcp-server/cli/start/command.js.map +1 -0
  41. package/mcp-server/cli/start/impl.d.ts +18 -0
  42. package/mcp-server/cli/start/impl.d.ts.map +1 -0
  43. package/mcp-server/cli/start/impl.js +102 -0
  44. package/mcp-server/cli/start/impl.js.map +1 -0
  45. package/mcp-server/cli.d.ts +6 -0
  46. package/mcp-server/cli.d.ts.map +1 -0
  47. package/mcp-server/cli.js +10 -0
  48. package/mcp-server/cli.js.map +1 -0
  49. package/mcp-server/console-logger.d.ts +7 -0
  50. package/mcp-server/console-logger.d.ts.map +1 -0
  51. package/mcp-server/console-logger.js +59 -0
  52. package/mcp-server/console-logger.js.map +1 -0
  53. package/mcp-server/mcp-server.d.ts +2 -0
  54. package/mcp-server/mcp-server.d.ts.map +1 -0
  55. package/mcp-server/mcp-server.js +29 -0
  56. package/mcp-server/mcp-server.js.map +1 -0
  57. package/mcp-server/resources.d.ts +27 -0
  58. package/mcp-server/resources.d.ts.map +1 -0
  59. package/mcp-server/resources.js +51 -0
  60. package/mcp-server/resources.js.map +1 -0
  61. package/mcp-server/scopes.d.ts +3 -0
  62. package/mcp-server/scopes.d.ts.map +1 -0
  63. package/mcp-server/scopes.js +8 -0
  64. package/mcp-server/scopes.js.map +1 -0
  65. package/mcp-server/server.d.ts +12 -0
  66. package/mcp-server/server.d.ts.map +1 -0
  67. package/mcp-server/server.js +45 -0
  68. package/mcp-server/server.js.map +1 -0
  69. package/mcp-server/shared.d.ts +7 -0
  70. package/mcp-server/shared.d.ts.map +1 -0
  71. package/mcp-server/shared.js +98 -0
  72. package/mcp-server/shared.js.map +1 -0
  73. package/mcp-server/tools/organizationsGetFacility.d.ts +8 -0
  74. package/mcp-server/tools/organizationsGetFacility.d.ts.map +1 -0
  75. package/mcp-server/tools/organizationsGetFacility.js +64 -0
  76. package/mcp-server/tools/organizationsGetFacility.js.map +1 -0
  77. package/mcp-server/tools/organizationsListOrSearchFacilities.d.ts +8 -0
  78. package/mcp-server/tools/organizationsListOrSearchFacilities.d.ts.map +1 -0
  79. package/mcp-server/tools/organizationsListOrSearchFacilities.js +77 -0
  80. package/mcp-server/tools/organizationsListOrSearchFacilities.js.map +1 -0
  81. package/mcp-server/tools/userGetCurrentUser.d.ts +3 -0
  82. package/mcp-server/tools/userGetCurrentUser.d.ts.map +1 -0
  83. package/mcp-server/tools/userGetCurrentUser.js +26 -0
  84. package/mcp-server/tools/userGetCurrentUser.js.map +1 -0
  85. package/mcp-server/tools/userGetUserById.d.ts +8 -0
  86. package/mcp-server/tools/userGetUserById.d.ts.map +1 -0
  87. package/mcp-server/tools/userGetUserById.js +64 -0
  88. package/mcp-server/tools/userGetUserById.js.map +1 -0
  89. package/mcp-server/tools/userLogsUserIntoTheSystem.d.ts +8 -0
  90. package/mcp-server/tools/userLogsUserIntoTheSystem.d.ts.map +1 -0
  91. package/mcp-server/tools/userLogsUserIntoTheSystem.js +94 -0
  92. package/mcp-server/tools/userLogsUserIntoTheSystem.js.map +1 -0
  93. package/mcp-server/tools/userMagiclink.d.ts +8 -0
  94. package/mcp-server/tools/userMagiclink.d.ts.map +1 -0
  95. package/mcp-server/tools/userMagiclink.js +64 -0
  96. package/mcp-server/tools/userMagiclink.js.map +1 -0
  97. package/mcp-server/tools/userPassword.d.ts +8 -0
  98. package/mcp-server/tools/userPassword.d.ts.map +1 -0
  99. package/mcp-server/tools/userPassword.js +65 -0
  100. package/mcp-server/tools/userPassword.js.map +1 -0
  101. package/mcp-server/tools/userPasswordResetRequest.d.ts +8 -0
  102. package/mcp-server/tools/userPasswordResetRequest.d.ts.map +1 -0
  103. package/mcp-server/tools/userPasswordResetRequest.js +64 -0
  104. package/mcp-server/tools/userPasswordResetRequest.js.map +1 -0
  105. package/mcp-server/tools/vendorsCreateVendorRegistration.d.ts +8 -0
  106. package/mcp-server/tools/vendorsCreateVendorRegistration.d.ts.map +1 -0
  107. package/mcp-server/tools/vendorsCreateVendorRegistration.js +64 -0
  108. package/mcp-server/tools/vendorsCreateVendorRegistration.js.map +1 -0
  109. package/mcp-server/tools/vendorsListVendorJobTitles.d.ts +8 -0
  110. package/mcp-server/tools/vendorsListVendorJobTitles.d.ts.map +1 -0
  111. package/mcp-server/tools/vendorsListVendorJobTitles.js +64 -0
  112. package/mcp-server/tools/vendorsListVendorJobTitles.js.map +1 -0
  113. package/mcp-server/tools.d.ts +25 -0
  114. package/mcp-server/tools.d.ts.map +1 -0
  115. package/mcp-server/tools.js +74 -0
  116. package/mcp-server/tools.js.map +1 -0
  117. package/models/components/facility.d.ts +0 -4
  118. package/models/components/facility.d.ts.map +1 -1
  119. package/models/components/facility.js +0 -4
  120. package/models/components/facility.js.map +1 -1
  121. package/models/components/user.d.ts +6 -0
  122. package/models/components/user.d.ts.map +1 -1
  123. package/models/components/user.js +5 -0
  124. package/models/components/user.js.map +1 -1
  125. package/models/operations/password.d.ts +2 -2
  126. package/models/operations/password.d.ts.map +1 -1
  127. package/models/operations/password.js +2 -2
  128. package/models/operations/password.js.map +1 -1
  129. package/package.json +18 -2
  130. package/src/__tests__/assertions.ts +13 -0
  131. package/src/__tests__/files.ts +56 -0
  132. package/src/__tests__/organizations.test.ts +244 -0
  133. package/src/__tests__/testclient.ts +48 -0
  134. package/src/__tests__/user.test.ts +200 -0
  135. package/src/__tests__/vendors.test.ts +65 -0
  136. package/src/funcs/organizationsGetFacility.ts +1 -1
  137. package/src/funcs/organizationsListOrSearchFacilities.ts +1 -1
  138. package/src/funcs/userGetCurrentUser.ts +1 -1
  139. package/src/funcs/userGetUserById.ts +1 -1
  140. package/src/funcs/userLogsUserIntoTheSystem.ts +1 -1
  141. package/src/funcs/userMagiclink.ts +1 -1
  142. package/src/funcs/userPassword.ts +1 -1
  143. package/src/funcs/userPasswordResetRequest.ts +1 -1
  144. package/src/funcs/vendorsCreateVendorRegistration.ts +1 -1
  145. package/src/funcs/vendorsListVendorJobTitles.ts +1 -1
  146. package/src/lib/config.ts +9 -6
  147. package/src/lib/files.ts +1 -1
  148. package/src/lib/primitives.ts +14 -0
  149. package/src/mcp-server/cli/start/command.ts +106 -0
  150. package/src/mcp-server/cli/start/impl.ts +132 -0
  151. package/src/mcp-server/cli.ts +13 -0
  152. package/src/mcp-server/console-logger.ts +71 -0
  153. package/src/mcp-server/mcp-server.ts +26 -0
  154. package/src/mcp-server/resources.ts +96 -0
  155. package/src/mcp-server/scopes.ts +7 -0
  156. package/src/mcp-server/server.ts +54 -0
  157. package/src/mcp-server/shared.ts +75 -0
  158. package/src/mcp-server/tools/organizationsGetFacility.ts +37 -0
  159. package/src/mcp-server/tools/organizationsListOrSearchFacilities.ts +52 -0
  160. package/src/mcp-server/tools/userGetCurrentUser.ts +30 -0
  161. package/src/mcp-server/tools/userGetUserById.ts +37 -0
  162. package/src/mcp-server/tools/userLogsUserIntoTheSystem.ts +67 -0
  163. package/src/mcp-server/tools/userMagiclink.ts +37 -0
  164. package/src/mcp-server/tools/userPassword.ts +38 -0
  165. package/src/mcp-server/tools/userPasswordResetRequest.ts +37 -0
  166. package/src/mcp-server/tools/vendorsCreateVendorRegistration.ts +38 -0
  167. package/src/mcp-server/tools/vendorsListVendorJobTitles.ts +37 -0
  168. package/src/mcp-server/tools.ts +116 -0
  169. package/src/models/components/facility.ts +0 -8
  170. package/src/models/components/user.ts +15 -0
  171. package/src/models/operations/password.ts +4 -4
  172. package/src/vitest.config.js +5 -0
  173. package/vitest.config.d.ts +7 -0
  174. package/vitest.config.d.ts.map +1 -0
  175. package/vitest.config.js +8 -0
  176. package/vitest.config.js.map +1 -0
  177. package/vitest.config.ts +8 -0
@@ -0,0 +1,71 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ export const consoleLoggerLevels = [
6
+ "debug",
7
+ "warning",
8
+ "info",
9
+ "error",
10
+ ] as const;
11
+
12
+ export type ConsoleLoggerLevel = (typeof consoleLoggerLevels)[number];
13
+
14
+ export type ConsoleLogger = {
15
+ [key in ConsoleLoggerLevel]: (
16
+ message: string,
17
+ data?: Record<string, unknown>,
18
+ ) => void;
19
+ };
20
+
21
+ export function createConsoleLogger(level: ConsoleLoggerLevel): ConsoleLogger {
22
+ const min = consoleLoggerLevels.indexOf(level);
23
+ const noop = () => {};
24
+
25
+ const logger: ConsoleLogger = {
26
+ debug: noop,
27
+ warning: noop,
28
+ info: noop,
29
+ error: noop,
30
+ };
31
+
32
+ return consoleLoggerLevels.reduce((logger, level, i) => {
33
+ if (i < min) {
34
+ return logger;
35
+ }
36
+
37
+ logger[level] = log.bind(null, level);
38
+
39
+ return logger;
40
+ }, logger);
41
+ }
42
+
43
+ function log(
44
+ level: ConsoleLoggerLevel,
45
+ message: string,
46
+ data?: Record<string, unknown>,
47
+ ) {
48
+ let line = "";
49
+ const allData = [{ msg: message, l: level }, data];
50
+
51
+ for (const ctx of allData) {
52
+ for (const [key, value] of Object.entries(ctx || {})) {
53
+ if (value == null) {
54
+ line += ` ${key}=<${value}>`;
55
+ } else if (typeof value === "function") {
56
+ line += ` ${key}=<function>`;
57
+ } else if (typeof value === "symbol") {
58
+ line += ` ${key}=${value.toString()}`;
59
+ } else if (typeof value === "string") {
60
+ const v = value.search(/\s/g) >= 0 ? JSON.stringify(value) : value;
61
+ line += ` ${key}=${v}`;
62
+ } else if (typeof value !== "object") {
63
+ line += ` ${key}=${value}`;
64
+ } else {
65
+ line += ` ${key}="${JSON.stringify(value)}"`;
66
+ }
67
+ }
68
+ }
69
+
70
+ console.error(line);
71
+ }
@@ -0,0 +1,26 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import { buildApplication, buildRouteMap, run } from "@stricli/core";
6
+ import process from "node:process";
7
+ import { buildContext } from "./cli.js";
8
+ import { startCommand } from "./cli/start/command.js";
9
+
10
+ const routes = buildRouteMap({
11
+ routes: {
12
+ start: startCommand,
13
+ },
14
+ docs: {
15
+ brief: "MCP server CLI",
16
+ },
17
+ });
18
+
19
+ export const app = buildApplication(routes, {
20
+ name: "mcp",
21
+ versionInfo: {
22
+ currentVersion: "0.12.0",
23
+ },
24
+ });
25
+
26
+ run(app, process.argv.slice(2), buildContext(process));
@@ -0,0 +1,96 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import { ResourceTemplate } from "@modelcontextprotocol/sdk/server/mcp.js";
6
+ import { RequestHandlerExtra } from "@modelcontextprotocol/sdk/shared/protocol.js";
7
+ import { Variables } from "@modelcontextprotocol/sdk/shared/uriTemplate.js";
8
+ import { ReadResourceResult } from "@modelcontextprotocol/sdk/types.js";
9
+ import { GreenSecurityCore } from "../core.js";
10
+ import { Result } from "../types/fp.js";
11
+ import { MCPScope } from "./scopes.js";
12
+ import { isAsyncIterable, isBinaryData, valueToBase64 } from "./shared.js";
13
+
14
+ export type ReadResourceCallback = (
15
+ client: GreenSecurityCore,
16
+ uri: URL,
17
+ extra: RequestHandlerExtra,
18
+ ) => ReadResourceResult | Promise<ReadResourceResult>;
19
+
20
+ export type ResourceDefinition = {
21
+ name: string;
22
+ description: string;
23
+ scopes?: MCPScope[];
24
+ resource: string;
25
+ read: ReadResourceCallback;
26
+ };
27
+
28
+ export type ReadResourceTemplateCallback = (
29
+ client: GreenSecurityCore,
30
+ uri: URL,
31
+ vars: Variables,
32
+ extra: RequestHandlerExtra,
33
+ ) => ReadResourceResult | Promise<ReadResourceResult>;
34
+
35
+ export type ResourceTemplateDefinition = {
36
+ name: string;
37
+ description: string;
38
+ scopes?: MCPScope[];
39
+ resource: ResourceTemplate;
40
+ read: ReadResourceTemplateCallback;
41
+ };
42
+
43
+ export async function formatResult(
44
+ result: Result<unknown, Error>,
45
+ uri: URL,
46
+ init: { response?: Response | undefined },
47
+ ): Promise<ReadResourceResult> {
48
+ if (!result.ok) {
49
+ throw result.error;
50
+ }
51
+
52
+ const { value } = result;
53
+ if (typeof value === "undefined") {
54
+ return { contents: [] };
55
+ }
56
+
57
+ const { response } = init;
58
+ const mimeType = response?.headers.get("content-type") ?? "";
59
+ let contents: ReadResourceResult["contents"] = [];
60
+
61
+ if (mimeType.search(/\bjson\b/g)) {
62
+ contents = [{ uri: uri.toString(), mimeType, text: JSON.stringify(value) }];
63
+ } else if (
64
+ mimeType.startsWith("text/event-stream")
65
+ && isAsyncIterable(value)
66
+ ) {
67
+ contents = [
68
+ {
69
+ uri: uri.toString(),
70
+ mimeType: "application/json",
71
+ text: await stringifySSEToJSON(value),
72
+ },
73
+ ];
74
+ } else if (mimeType.startsWith("text/") && typeof value === "string") {
75
+ contents = [{ uri: uri.toString(), mimeType, text: value }];
76
+ } else if (isBinaryData(value)) {
77
+ const blob = await valueToBase64(value);
78
+ contents = blob == null ? [] : [{ uri: uri.toString(), blob, mimeType }];
79
+ } else {
80
+ throw new Error(`Unsupported content type: "${mimeType}"`);
81
+ }
82
+
83
+ return { contents };
84
+ }
85
+
86
+ async function stringifySSEToJSON(
87
+ value: AsyncIterable<unknown>,
88
+ ): Promise<string> {
89
+ const payloads = [];
90
+
91
+ for await (const chunk of value) {
92
+ payloads.push(chunk);
93
+ }
94
+
95
+ return JSON.stringify(payloads);
96
+ }
@@ -0,0 +1,7 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ export const mcpScopes = [] as const;
6
+
7
+ export type MCPScope = (typeof mcpScopes)[number];
@@ -0,0 +1,54 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
6
+ import { GreenSecurityCore } from "../core.js";
7
+ import { SDKOptions } from "../lib/config.js";
8
+ import type { ConsoleLogger } from "./console-logger.js";
9
+ import { MCPScope, mcpScopes } from "./scopes.js";
10
+ import { createRegisterTool } from "./tools.js";
11
+ import { tool$organizationsGetFacility } from "./tools/organizationsGetFacility.js";
12
+ import { tool$organizationsListOrSearchFacilities } from "./tools/organizationsListOrSearchFacilities.js";
13
+ import { tool$userGetCurrentUser } from "./tools/userGetCurrentUser.js";
14
+ import { tool$userGetUserById } from "./tools/userGetUserById.js";
15
+ import { tool$userLogsUserIntoTheSystem } from "./tools/userLogsUserIntoTheSystem.js";
16
+ import { tool$userMagiclink } from "./tools/userMagiclink.js";
17
+ import { tool$userPassword } from "./tools/userPassword.js";
18
+ import { tool$userPasswordResetRequest } from "./tools/userPasswordResetRequest.js";
19
+ import { tool$vendorsCreateVendorRegistration } from "./tools/vendorsCreateVendorRegistration.js";
20
+ import { tool$vendorsListVendorJobTitles } from "./tools/vendorsListVendorJobTitles.js";
21
+
22
+ export function createMCPServer(deps: {
23
+ logger: ConsoleLogger;
24
+ scopes?: MCPScope[] | undefined;
25
+ serverURL?: string | undefined;
26
+ security?: SDKOptions["security"] | undefined;
27
+ serverIdx?: SDKOptions["serverIdx"] | undefined;
28
+ }) {
29
+ const server = new McpServer({
30
+ name: "GreenSecurity",
31
+ version: "0.12.0",
32
+ });
33
+
34
+ const client = new GreenSecurityCore({
35
+ security: deps.security,
36
+ serverURL: deps.serverURL,
37
+ serverIdx: deps.serverIdx,
38
+ });
39
+ const scopes = new Set(deps.scopes ?? mcpScopes);
40
+ const tool = createRegisterTool(deps.logger, server, client, scopes);
41
+
42
+ tool(tool$vendorsCreateVendorRegistration);
43
+ tool(tool$vendorsListVendorJobTitles);
44
+ tool(tool$userGetCurrentUser);
45
+ tool(tool$userGetUserById);
46
+ tool(tool$userLogsUserIntoTheSystem);
47
+ tool(tool$userMagiclink);
48
+ tool(tool$userPasswordResetRequest);
49
+ tool(tool$userPassword);
50
+ tool(tool$organizationsListOrSearchFacilities);
51
+ tool(tool$organizationsGetFacility);
52
+
53
+ return server;
54
+ }
@@ -0,0 +1,75 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import * as z from "zod";
6
+ import { bytesToBase64 } from "../lib/base64.js";
7
+
8
+ type BinaryData =
9
+ | Uint8Array
10
+ | ArrayBuffer
11
+ | Blob
12
+ | ReadableStream
13
+ | Response
14
+ | string;
15
+
16
+ export async function consumeStream(
17
+ stream: ReadableStream<Uint8Array>,
18
+ ): Promise<Uint8Array> {
19
+ const reader = stream.getReader();
20
+ const chunks: Uint8Array[] = [];
21
+
22
+ try {
23
+ while (true) {
24
+ const { done, value } = await reader.read();
25
+ if (value != null) chunks.push(value);
26
+ if (done) break;
27
+ }
28
+ } finally {
29
+ reader.releaseLock();
30
+ }
31
+
32
+ return new Uint8Array(await new Blob(chunks).arrayBuffer());
33
+ }
34
+
35
+ export function isAsyncIterable(
36
+ value: unknown,
37
+ ): value is AsyncIterable<string> {
38
+ return (
39
+ typeof value === "object" && value != null && Symbol.asyncIterator in value
40
+ );
41
+ }
42
+
43
+ export function isBinaryData(value: unknown): value is BinaryData {
44
+ return (
45
+ value instanceof Uint8Array
46
+ || value instanceof ArrayBuffer
47
+ || value instanceof Blob
48
+ || value instanceof ReadableStream
49
+ || value instanceof Response
50
+ || typeof value === "string"
51
+ );
52
+ }
53
+
54
+ const base64Schema = z.string().base64();
55
+
56
+ export async function valueToBase64(
57
+ value: BinaryData | null | undefined,
58
+ ): Promise<string | null> {
59
+ if (value == null) {
60
+ return null;
61
+ } else if (value instanceof Uint8Array) {
62
+ return bytesToBase64(value);
63
+ } else if (value instanceof ArrayBuffer) {
64
+ return bytesToBase64(new Uint8Array(value));
65
+ } else if (value instanceof Response || value instanceof Blob) {
66
+ return bytesToBase64(new Uint8Array(await value.arrayBuffer()));
67
+ } else if (value instanceof ReadableStream) {
68
+ return bytesToBase64(await consumeStream(value));
69
+ } else if (typeof value === "string") {
70
+ return base64Schema.parse(value);
71
+ } else {
72
+ value satisfies never;
73
+ throw new Error(`Unsupported image value type: ${typeof value}`);
74
+ }
75
+ }
@@ -0,0 +1,37 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import { organizationsGetFacility } from "../../funcs/organizationsGetFacility.js";
6
+ import * as operations from "../../models/operations/index.js";
7
+ import { formatResult, ToolDefinition } from "../tools.js";
8
+
9
+ const args = {
10
+ request: operations.GetFacilityRequest$inboundSchema,
11
+ };
12
+
13
+ export const tool$organizationsGetFacility: ToolDefinition<typeof args> = {
14
+ name: "organizations_get-facility",
15
+ description: `Get facility
16
+
17
+ Retrieve an individual facility.`,
18
+ args,
19
+ tool: async (client, args, ctx) => {
20
+ const [result, apiCall] = await organizationsGetFacility(
21
+ client,
22
+ args.request,
23
+ { fetchOptions: { signal: ctx.signal } },
24
+ ).$inspect();
25
+
26
+ if (!result.ok) {
27
+ return {
28
+ content: [{ type: "text", text: result.error.message }],
29
+ isError: true,
30
+ };
31
+ }
32
+
33
+ const value = result.value;
34
+
35
+ return formatResult(value, apiCall);
36
+ },
37
+ };
@@ -0,0 +1,52 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import { organizationsListOrSearchFacilities } from "../../funcs/organizationsListOrSearchFacilities.js";
6
+ import * as operations from "../../models/operations/index.js";
7
+ import { formatResult, ToolDefinition } from "../tools.js";
8
+
9
+ const args = {
10
+ request: operations.ListOrSearchFacilitiesRequest$inboundSchema,
11
+ };
12
+
13
+ export const tool$organizationsListOrSearchFacilities: ToolDefinition<
14
+ typeof args
15
+ > = {
16
+ name: "organizations_list-or-search-facilities",
17
+ description: `List or search facilities
18
+
19
+ List or search facilities.
20
+
21
+ Available \`expand\` scopes are:
22
+
23
+ - facility.appointment_policy
24
+ - facility.contacts
25
+ - facility.vendor_counts
26
+ - facility.flu_credential
27
+ - facility.scrubs_policy
28
+ - facility.system
29
+ - facility.vendor_guest_policy
30
+ - facility.vendor_policy
31
+ - facility.visitor_policy
32
+ - facility.workflow`,
33
+ args,
34
+ tool: async (client, args, ctx) => {
35
+ const [result, apiCall] = await organizationsListOrSearchFacilities(
36
+ client,
37
+ args.request,
38
+ { fetchOptions: { signal: ctx.signal } },
39
+ ).$inspect();
40
+
41
+ if (!result.ok) {
42
+ return {
43
+ content: [{ type: "text", text: result.error.message }],
44
+ isError: true,
45
+ };
46
+ }
47
+
48
+ const value = result.value;
49
+
50
+ return formatResult(value, apiCall);
51
+ },
52
+ };
@@ -0,0 +1,30 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import { userGetCurrentUser } from "../../funcs/userGetCurrentUser.js";
6
+ import { formatResult, ToolDefinition } from "../tools.js";
7
+
8
+ export const tool$userGetCurrentUser: ToolDefinition = {
9
+ name: "user_get-current-user",
10
+ description: `Get current user
11
+
12
+ Returns a user object for the user represented by the authorization token`,
13
+ tool: async (client, ctx) => {
14
+ const [result, apiCall] = await userGetCurrentUser(
15
+ client,
16
+ { fetchOptions: { signal: ctx.signal } },
17
+ ).$inspect();
18
+
19
+ if (!result.ok) {
20
+ return {
21
+ content: [{ type: "text", text: result.error.message }],
22
+ isError: true,
23
+ };
24
+ }
25
+
26
+ const value = result.value;
27
+
28
+ return formatResult(value, apiCall);
29
+ },
30
+ };
@@ -0,0 +1,37 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import { userGetUserById } from "../../funcs/userGetUserById.js";
6
+ import * as operations from "../../models/operations/index.js";
7
+ import { formatResult, ToolDefinition } from "../tools.js";
8
+
9
+ const args = {
10
+ request: operations.GetUserByIdRequest$inboundSchema,
11
+ };
12
+
13
+ export const tool$userGetUserById: ToolDefinition<typeof args> = {
14
+ name: "user_get-user-by-id",
15
+ description: `Get user by id
16
+
17
+ Returns a user object for the user represented by the identifier in the path.`,
18
+ args,
19
+ tool: async (client, args, ctx) => {
20
+ const [result, apiCall] = await userGetUserById(
21
+ client,
22
+ args.request,
23
+ { fetchOptions: { signal: ctx.signal } },
24
+ ).$inspect();
25
+
26
+ if (!result.ok) {
27
+ return {
28
+ content: [{ type: "text", text: result.error.message }],
29
+ isError: true,
30
+ };
31
+ }
32
+
33
+ const value = result.value;
34
+
35
+ return formatResult(value, apiCall);
36
+ },
37
+ };
@@ -0,0 +1,67 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import { userLogsUserIntoTheSystem } from "../../funcs/userLogsUserIntoTheSystem.js";
6
+ import * as operations from "../../models/operations/index.js";
7
+ import { formatResult, ToolDefinition } from "../tools.js";
8
+
9
+ const args = {
10
+ request: operations.LogsUserIntoTheSystemRequestBody$inboundSchema,
11
+ };
12
+
13
+ export const tool$userLogsUserIntoTheSystem: ToolDefinition<typeof args> = {
14
+ name: "user_logs-user-into-the-system",
15
+ description: `Logs user into the system
16
+
17
+ This endpoint allows a user to authenticate themselves and retrieve a permanent token for access.
18
+
19
+ Permanent tokens should only ever be stored in an encrypted storage because they represent a fully logged in user.
20
+
21
+ Users may log in with \`email/password\`, \`SAML\`, \`magic link\` or \`mfa\`. The application should handle all of the above as equally valid login methods.
22
+
23
+ The most common way to authenticate a user is to log in with an email and password. If the user provides valid credentials, the server will either respond with a full user object including the token.
24
+
25
+ When the user's account is protected via MFA, the server will send a 6 digit code to the user via their default MFA provider. You should collect that code and resend the email, password and mfa_code together to get a successful authentication.
26
+
27
+ The ideal flow for a login sequence is the following:
28
+
29
+ 1. Present an email address field only and allow the user to submit
30
+ 2. Send \`email\` and \`return_url\` payload to this endpoint
31
+ 3. Follow the flow based on the response \`requires\` field
32
+
33
+ Requires: \`password\`
34
+
35
+ 1. Show a password field for the user to fill out
36
+ 2. Submit the \`email\` and \`password\` to this endpoint
37
+ 3. If the response is \`200\`, the login is done. If the response is \`201\`, then check if \`requires: mfa_code\` is returned and show MFA flow
38
+ 4. Submit \`email\`, \`password\`, \`mfa_code\` to this endpoint
39
+ 5. If the response is \`200\`, the login is done. Otherwise, show the appropriate error to the user and go back to step 1 or 3 depending on the error.
40
+
41
+ Requires: \`saml_login\`
42
+
43
+ 1. [Open a browser](https://docs.expo.dev/versions/latest/sdk/webbrowser/#webbrowseropenauthsessionasyncurl-redirecturl-options) to the url returned in \`sso_url\`
44
+ 2. User completes sign-in using their configured SAML IdP
45
+ 3. Site redirects to your selected \`return_url\`
46
+ 4. The \`user_token\` will be appended as a query string parameter to your \`return_url\` - you must parse this token and store it
47
+ 5. Fetch the user object from \`/users/me\` using the token`,
48
+ args,
49
+ tool: async (client, args, ctx) => {
50
+ const [result, apiCall] = await userLogsUserIntoTheSystem(
51
+ client,
52
+ args.request,
53
+ { fetchOptions: { signal: ctx.signal } },
54
+ ).$inspect();
55
+
56
+ if (!result.ok) {
57
+ return {
58
+ content: [{ type: "text", text: result.error.message }],
59
+ isError: true,
60
+ };
61
+ }
62
+
63
+ const value = result.value;
64
+
65
+ return formatResult(value, apiCall);
66
+ },
67
+ };
@@ -0,0 +1,37 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import { userMagiclink } from "../../funcs/userMagiclink.js";
6
+ import * as operations from "../../models/operations/index.js";
7
+ import { formatResult, ToolDefinition } from "../tools.js";
8
+
9
+ const args = {
10
+ request: operations.MagiclinkRequestBody$inboundSchema,
11
+ };
12
+
13
+ export const tool$userMagiclink: ToolDefinition<typeof args> = {
14
+ name: "user_magiclink",
15
+ description: `Magic link
16
+
17
+ It sends an email with a magic link to allow the user to log in.`,
18
+ args,
19
+ tool: async (client, args, ctx) => {
20
+ const [result, apiCall] = await userMagiclink(
21
+ client,
22
+ args.request,
23
+ { fetchOptions: { signal: ctx.signal } },
24
+ ).$inspect();
25
+
26
+ if (!result.ok) {
27
+ return {
28
+ content: [{ type: "text", text: result.error.message }],
29
+ isError: true,
30
+ };
31
+ }
32
+
33
+ const value = result.value;
34
+
35
+ return formatResult(value, apiCall);
36
+ },
37
+ };
@@ -0,0 +1,38 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import { userPassword } from "../../funcs/userPassword.js";
6
+ import * as operations from "../../models/operations/index.js";
7
+ import { formatResult, ToolDefinition } from "../tools.js";
8
+
9
+ const args = {
10
+ request: operations.PasswordRequestBody$inboundSchema,
11
+ };
12
+
13
+ export const tool$userPassword: ToolDefinition<typeof args> = {
14
+ name: "user_password",
15
+ description: `Password reset
16
+
17
+ Resets the a user's password using a password_reset_id that was sent to them via email.
18
+ See /users/passwordresetrequest to initiate a password reset flow.`,
19
+ args,
20
+ tool: async (client, args, ctx) => {
21
+ const [result, apiCall] = await userPassword(
22
+ client,
23
+ args.request,
24
+ { fetchOptions: { signal: ctx.signal } },
25
+ ).$inspect();
26
+
27
+ if (!result.ok) {
28
+ return {
29
+ content: [{ type: "text", text: result.error.message }],
30
+ isError: true,
31
+ };
32
+ }
33
+
34
+ const value = result.value;
35
+
36
+ return formatResult(value, apiCall);
37
+ },
38
+ };
@@ -0,0 +1,37 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import { userPasswordResetRequest } from "../../funcs/userPasswordResetRequest.js";
6
+ import * as operations from "../../models/operations/index.js";
7
+ import { formatResult, ToolDefinition } from "../tools.js";
8
+
9
+ const args = {
10
+ request: operations.PasswordResetRequestRequestBody$inboundSchema,
11
+ };
12
+
13
+ export const tool$userPasswordResetRequest: ToolDefinition<typeof args> = {
14
+ name: "user_password-reset-request",
15
+ description: `Password reset request
16
+
17
+ It sends an email with a link for resetting a user's password.`,
18
+ args,
19
+ tool: async (client, args, ctx) => {
20
+ const [result, apiCall] = await userPasswordResetRequest(
21
+ client,
22
+ args.request,
23
+ { fetchOptions: { signal: ctx.signal } },
24
+ ).$inspect();
25
+
26
+ if (!result.ok) {
27
+ return {
28
+ content: [{ type: "text", text: result.error.message }],
29
+ isError: true,
30
+ };
31
+ }
32
+
33
+ const value = result.value;
34
+
35
+ return formatResult(value, apiCall);
36
+ },
37
+ };