@greensecurity/javascript-sdk 0.11.0 → 0.12.1

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 (83) hide show
  1. package/README.md +25 -28
  2. package/bin/mcp-server.js +77 -32
  3. package/bin/mcp-server.js.map +20 -20
  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 +4 -4
  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/primitives.d.ts +3 -0
  30. package/lib/primitives.d.ts.map +1 -1
  31. package/lib/primitives.js +7 -0
  32. package/lib/primitives.js.map +1 -1
  33. package/mcp-server/cli/start/command.d.ts.map +1 -1
  34. package/mcp-server/cli/start/command.js +44 -6
  35. package/mcp-server/cli/start/command.js.map +1 -1
  36. package/mcp-server/cli/start/impl.d.ts +4 -1
  37. package/mcp-server/cli/start/impl.d.ts.map +1 -1
  38. package/mcp-server/cli/start/impl.js +5 -0
  39. package/mcp-server/cli/start/impl.js.map +1 -1
  40. package/mcp-server/mcp-server.js +1 -1
  41. package/mcp-server/server.d.ts +2 -1
  42. package/mcp-server/server.d.ts.map +1 -1
  43. package/mcp-server/server.js +2 -1
  44. package/mcp-server/server.js.map +1 -1
  45. package/models/components/facility.d.ts +0 -4
  46. package/models/components/facility.d.ts.map +1 -1
  47. package/models/components/facility.js +0 -4
  48. package/models/components/facility.js.map +1 -1
  49. package/models/components/user.d.ts +6 -0
  50. package/models/components/user.d.ts.map +1 -1
  51. package/models/components/user.js +5 -0
  52. package/models/components/user.js.map +1 -1
  53. package/package.json +5 -1
  54. package/src/__tests__/assertions.ts +13 -0
  55. package/src/__tests__/files.ts +56 -0
  56. package/src/__tests__/organizations.test.ts +244 -0
  57. package/src/__tests__/testclient.ts +48 -0
  58. package/src/__tests__/user.test.ts +200 -0
  59. package/src/__tests__/vendors.test.ts +65 -0
  60. package/src/funcs/organizationsGetFacility.ts +1 -1
  61. package/src/funcs/organizationsListOrSearchFacilities.ts +1 -1
  62. package/src/funcs/userGetCurrentUser.ts +1 -1
  63. package/src/funcs/userGetUserById.ts +1 -1
  64. package/src/funcs/userLogsUserIntoTheSystem.ts +1 -1
  65. package/src/funcs/userMagiclink.ts +1 -1
  66. package/src/funcs/userPassword.ts +1 -1
  67. package/src/funcs/userPasswordResetRequest.ts +1 -1
  68. package/src/funcs/vendorsCreateVendorRegistration.ts +1 -1
  69. package/src/funcs/vendorsListVendorJobTitles.ts +1 -1
  70. package/src/lib/config.ts +7 -4
  71. package/src/lib/primitives.ts +14 -0
  72. package/src/mcp-server/cli/start/command.ts +46 -7
  73. package/src/mcp-server/cli/start/impl.ts +10 -1
  74. package/src/mcp-server/mcp-server.ts +1 -1
  75. package/src/mcp-server/server.ts +4 -2
  76. package/src/models/components/facility.ts +0 -8
  77. package/src/models/components/user.ts +15 -0
  78. package/src/vitest.config.js +5 -0
  79. package/vitest.config.d.ts +7 -0
  80. package/vitest.config.d.ts.map +1 -0
  81. package/vitest.config.js +8 -0
  82. package/vitest.config.js.map +1 -0
  83. package/vitest.config.ts +8 -0
@@ -134,3 +134,17 @@ export function compactMap<T>(
134
134
 
135
135
  return out;
136
136
  }
137
+
138
+ export function allRequired<V extends Record<string, unknown>>(
139
+ v: V,
140
+ ):
141
+ | {
142
+ [K in keyof V]: NonNullable<V[K]>;
143
+ }
144
+ | undefined {
145
+ if (Object.values(v).every((x) => x == null)) {
146
+ return void 0;
147
+ }
148
+
149
+ return v as ReturnType<typeof allRequired<V>>;
150
+ }
@@ -15,12 +15,6 @@ export const startCommand = buildCommand({
15
15
  },
16
16
  parameters: {
17
17
  flags: {
18
- "log-level": {
19
- kind: "enum",
20
- brief: "The log level to use for the server",
21
- default: "info",
22
- values: consoleLoggerLevels,
23
- },
24
18
  transport: {
25
19
  kind: "enum",
26
20
  brief: "The transport to use for communicating with the server",
@@ -46,7 +40,22 @@ export const startCommand = buildCommand({
46
40
  },
47
41
  }
48
42
  : {}),
49
-
43
+ "api-token": {
44
+ kind: "parsed",
45
+ brief: "Sets the token auth field for the API",
46
+ optional: true,
47
+ parse: (value) => {
48
+ return z.string().parse(value);
49
+ },
50
+ },
51
+ "bearer-jwt": {
52
+ kind: "parsed",
53
+ brief: "Sets the bearerJwt auth field for the API",
54
+ optional: true,
55
+ parse: (value) => {
56
+ return z.string().parse(value);
57
+ },
58
+ },
50
59
  "server-url": {
51
60
  kind: "parsed",
52
61
  brief: "Overrides the default server URL used by the SDK",
@@ -59,6 +68,36 @@ export const startCommand = buildCommand({
59
68
  optional: true,
60
69
  parse: numberParser,
61
70
  },
71
+ "log-level": {
72
+ kind: "enum",
73
+ brief: "The log level to use for the server",
74
+ default: "info",
75
+ values: consoleLoggerLevels,
76
+ },
77
+ env: {
78
+ kind: "parsed",
79
+ brief: "Environment variables made available to the server",
80
+ optional: true,
81
+ variadic: true,
82
+ parse: (val: string) => {
83
+ const sepIdx = val.indexOf("=");
84
+ if (sepIdx === -1) {
85
+ throw new Error("Invalid environment variable format");
86
+ }
87
+
88
+ const key = val.slice(0, sepIdx);
89
+ const value = val.slice(sepIdx + 1);
90
+
91
+ return [
92
+ z.string().nonempty({
93
+ message: "Environment variable key must be a non-empty string",
94
+ }).parse(key),
95
+ z.string().nonempty({
96
+ message: "Environment variable value must be a non-empty string",
97
+ }).parse(value),
98
+ ] satisfies [string, string];
99
+ },
100
+ },
62
101
  },
63
102
  },
64
103
  docs: {
@@ -15,15 +15,22 @@ import { MCPScope } from "../../scopes.js";
15
15
  import { createMCPServer } from "../../server.js";
16
16
 
17
17
  interface StartCommandFlags {
18
- readonly "log-level": ConsoleLoggerLevel;
19
18
  readonly transport: "stdio" | "sse";
20
19
  readonly port: number;
21
20
  readonly scope?: MCPScope[];
21
+ readonly "api-token"?: string | undefined;
22
+ readonly "bearer-jwt"?: string | undefined;
22
23
  readonly "server-url"?: string;
23
24
  readonly "server-index"?: SDKOptions["serverIdx"];
25
+ readonly "log-level": ConsoleLoggerLevel;
26
+ readonly env?: [string, string][];
24
27
  }
25
28
 
26
29
  export async function main(this: LocalContext, flags: StartCommandFlags) {
30
+ flags.env?.forEach(([key, value]) => {
31
+ process.env[key] = value;
32
+ });
33
+
27
34
  switch (flags.transport) {
28
35
  case "stdio":
29
36
  await startStdio(flags);
@@ -42,6 +49,7 @@ async function startStdio(flags: StartCommandFlags) {
42
49
  const server = createMCPServer({
43
50
  logger,
44
51
  scopes: flags.scope,
52
+ security: { token: flags["api-token"], bearerJwt: flags["bearer-jwt"] },
45
53
  serverURL: flags["server-url"],
46
54
  serverIdx: flags["server-index"],
47
55
  });
@@ -61,6 +69,7 @@ async function startSSE(flags: StartCommandFlags) {
61
69
  const mcpServer = createMCPServer({
62
70
  logger,
63
71
  scopes: flags.scope,
72
+ security: { token: flags["api-token"], bearerJwt: flags["bearer-jwt"] },
64
73
  serverURL: flags["server-url"],
65
74
  serverIdx: flags["server-index"],
66
75
  });
@@ -19,7 +19,7 @@ const routes = buildRouteMap({
19
19
  export const app = buildApplication(routes, {
20
20
  name: "mcp",
21
21
  versionInfo: {
22
- currentVersion: "0.11.0",
22
+ currentVersion: "0.12.1",
23
23
  },
24
24
  });
25
25
 
@@ -23,14 +23,16 @@ export function createMCPServer(deps: {
23
23
  logger: ConsoleLogger;
24
24
  scopes?: MCPScope[] | undefined;
25
25
  serverURL?: string | undefined;
26
- serverIdx?: SDKOptions["serverIdx"];
26
+ security?: SDKOptions["security"] | undefined;
27
+ serverIdx?: SDKOptions["serverIdx"] | undefined;
27
28
  }) {
28
29
  const server = new McpServer({
29
30
  name: "GreenSecurity",
30
- version: "0.11.0",
31
+ version: "0.12.1",
31
32
  });
32
33
 
33
34
  const client = new GreenSecurityCore({
35
+ security: deps.security,
34
36
  serverURL: deps.serverURL,
35
37
  serverIdx: deps.serverIdx,
36
38
  });
@@ -97,8 +97,6 @@ export type Location = {
97
97
  website?: string | null | undefined;
98
98
  utcOffset?: number | null | undefined;
99
99
  timezone?: string | null | undefined;
100
- latitude?: number | null | undefined;
101
- longitude?: number | null | undefined;
102
100
  };
103
101
 
104
102
  export type ScrubsPolicy = {
@@ -584,8 +582,6 @@ export const Location$inboundSchema: z.ZodType<
584
582
  website: z.nullable(z.string()).optional(),
585
583
  utc_offset: z.nullable(z.number()).optional(),
586
584
  timezone: z.nullable(z.string()).optional(),
587
- latitude: z.nullable(z.number()).optional(),
588
- longitude: z.nullable(z.number()).optional(),
589
585
  }).transform((v) => {
590
586
  return remap$(v, {
591
587
  "street_address": "streetAddress",
@@ -605,8 +601,6 @@ export type Location$Outbound = {
605
601
  website?: string | null | undefined;
606
602
  utc_offset?: number | null | undefined;
607
603
  timezone?: string | null | undefined;
608
- latitude?: number | null | undefined;
609
- longitude?: number | null | undefined;
610
604
  };
611
605
 
612
606
  /** @internal */
@@ -625,8 +619,6 @@ export const Location$outboundSchema: z.ZodType<
625
619
  website: z.nullable(z.string()).optional(),
626
620
  utcOffset: z.nullable(z.number()).optional(),
627
621
  timezone: z.nullable(z.string()).optional(),
628
- latitude: z.nullable(z.number()).optional(),
629
- longitude: z.nullable(z.number()).optional(),
630
622
  }).transform((v) => {
631
623
  return remap$(v, {
632
624
  streetAddress: "street_address",
@@ -14,6 +14,12 @@ import {
14
14
  Contact$Outbound,
15
15
  Contact$outboundSchema,
16
16
  } from "./contact.js";
17
+ import {
18
+ ImageSet,
19
+ ImageSet$inboundSchema,
20
+ ImageSet$Outbound,
21
+ ImageSet$outboundSchema,
22
+ } from "./imageset.js";
17
23
 
18
24
  /**
19
25
  * The flavor of user will determine the most relevant user experience for this user as well as permissions
@@ -60,6 +66,10 @@ export type UserUser = {
60
66
  * The timezone of the user. This is used to display times in the user's local time. If not present, use the device's local timezone.
61
67
  */
62
68
  timezone?: string | null | undefined;
69
+ /**
70
+ * A set of images in different sizes
71
+ */
72
+ imageUrls?: ImageSet | undefined;
63
73
  };
64
74
 
65
75
  /**
@@ -140,11 +150,13 @@ export const UserUser$inboundSchema: z.ZodType<
140
150
  phone: z.nullable(z.string()).optional(),
141
151
  user_type: UserType$inboundSchema,
142
152
  timezone: z.nullable(z.string()).optional(),
153
+ image_urls: ImageSet$inboundSchema.optional(),
143
154
  }).transform((v) => {
144
155
  return remap$(v, {
145
156
  "first_name": "firstName",
146
157
  "last_name": "lastName",
147
158
  "user_type": "userType",
159
+ "image_urls": "imageUrls",
148
160
  });
149
161
  });
150
162
 
@@ -157,6 +169,7 @@ export type UserUser$Outbound = {
157
169
  phone?: string | null | undefined;
158
170
  user_type: string;
159
171
  timezone?: string | null | undefined;
172
+ image_urls?: ImageSet$Outbound | undefined;
160
173
  };
161
174
 
162
175
  /** @internal */
@@ -172,11 +185,13 @@ export const UserUser$outboundSchema: z.ZodType<
172
185
  phone: z.nullable(z.string()).optional(),
173
186
  userType: UserType$outboundSchema,
174
187
  timezone: z.nullable(z.string()).optional(),
188
+ imageUrls: ImageSet$outboundSchema.optional(),
175
189
  }).transform((v) => {
176
190
  return remap$(v, {
177
191
  firstName: "first_name",
178
192
  lastName: "last_name",
179
193
  userType: "user_type",
194
+ imageUrls: "image_urls",
180
195
  });
181
196
  });
182
197
 
@@ -0,0 +1,5 @@
1
+ export default {
2
+ test: {
3
+ timeout: 30000, // Set the global timeout to 10 seconds
4
+ },
5
+ }
@@ -0,0 +1,7 @@
1
+ declare namespace _default {
2
+ namespace test {
3
+ let timeout: number;
4
+ }
5
+ }
6
+ export default _default;
7
+ //# sourceMappingURL=vitest.config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vitest.config.d.ts","sourceRoot":"","sources":["src/vitest.config.js"],"names":[],"mappings":""}
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = {
4
+ test: {
5
+ timeout: 30000, // Set the global timeout to 10 seconds
6
+ },
7
+ };
8
+ //# sourceMappingURL=vitest.config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vitest.config.js","sourceRoot":"","sources":["src/vitest.config.js"],"names":[],"mappings":";;AAAA,kBAAe;IACb,IAAI,EAAE;QACJ,OAAO,EAAE,KAAK,EAAE,uCAAuC;KACxD;CACF,CAAA"}
@@ -0,0 +1,8 @@
1
+ /// <reference types="vitest" />
2
+ import { defineConfig } from 'vite'
3
+
4
+ export default defineConfig({
5
+ test: {
6
+ testTimeout: 30000,
7
+ },
8
+ })