@greensecurity/javascript-sdk 0.11.0 → 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 (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
package/README.md CHANGED
@@ -34,6 +34,17 @@ Some useful links:
34
34
  <!-- $toc-max-depth=2 -->
35
35
  * [greensecurity](#greensecurity)
36
36
  * [SDK Installation](#sdk-installation)
37
+ * [Requirements](#requirements)
38
+ * [SDK Example Usage](#sdk-example-usage)
39
+ * [Authentication](#authentication)
40
+ * [Available Resources and Operations](#available-resources-and-operations)
41
+ * [Standalone functions](#standalone-functions)
42
+ * [React hooks with TanStack Query](#react-hooks-with-tanstack-query)
43
+ * [Retries](#retries)
44
+ * [Error Handling](#error-handling)
45
+ * [Server Selection](#server-selection)
46
+ * [Custom HTTP Client](#custom-http-client)
47
+ * [Debugging](#debugging)
37
48
  * [Development](#development)
38
49
  * [Maturity](#maturity)
39
50
  * [Contributions](#contributions)
@@ -99,11 +110,13 @@ Add the following server definition to your `claude_desktop_config.json` file:
99
110
  "mcpServers": {
100
111
  "GreenSecurity": {
101
112
  "command": "npx",
102
- "args": ["-y", "--package", "@greensecurity/javascript-sdk", "--", "mcp", "start"],
103
- "env": {
104
- "GREEN_SECURITY_TOKEN": "...",
105
- "GREEN_SECURITY_BEARER_JWT": "..."
106
- }
113
+ "args": [
114
+ "-y", "--package", "@greensecurity/javascript-sdk",
115
+ "--",
116
+ "mcp", "start",
117
+ "--api-token", "...",
118
+ "--bearer-jwt", "..."
119
+ ]
107
120
  }
108
121
  }
109
122
  }
@@ -114,30 +127,14 @@ Add the following server definition to your `claude_desktop_config.json` file:
114
127
  <details>
115
128
  <summary>Cursor installation steps</summary>
116
129
 
117
- 1. Create a shell script called `mcp-green_security.sh` with the following content:
118
-
119
- ```sh
120
- #!/bin/sh
121
-
122
- export GREEN_SECURITY_TOKEN="..."
123
- export GREEN_SECURITY_BEARER_JWT="..."
124
-
125
- exec npx -y --package @greensecurity/javascript-sdk -- mcp start "$@"
126
- ```
127
-
128
- 2. Then make it executable with the following command:
130
+ Go to `Cursor Settings > Features > MCP Servers > Add new MCP server` and use the following settings:
129
131
 
130
- ```sh
131
- chmod +x mcp-green_security.sh
132
- ```
133
-
134
- 3. In Cursor, `Cursor Settings > Features > MCP Servers > Add new MCP server` and use the following settings:
135
-
136
- | Field | Value |
137
- | ------- | ----- |
138
- | Name | GreenSecurity |
139
- | Type | `command` |
140
- | Command | `/path/to/mcp-green_security.sh` |
132
+ - Name: GreenSecurity
133
+ - Type: `command`
134
+ - Command:
135
+ ```sh
136
+ npx -y --package @greensecurity/javascript-sdk -- mcp start --api-token ... --bearer-jwt ...
137
+ ```
141
138
 
142
139
  </details>
143
140
 
package/bin/mcp-server.js CHANGED
@@ -34172,9 +34172,9 @@ var init_config = __esm(() => {
34172
34172
  SDK_METADATA = {
34173
34173
  language: "typescript",
34174
34174
  openapiDocVersion: "0.0.3",
34175
- sdkVersion: "0.11.0",
34176
- genVersion: "2.518.1",
34177
- userAgent: "speakeasy-sdk/typescript 0.11.0 2.518.1 0.0.3 @greensecurity/javascript-sdk"
34175
+ sdkVersion: "0.12.0",
34176
+ genVersion: "2.529.2",
34177
+ userAgent: "speakeasy-sdk/typescript 0.12.0 2.529.2 0.0.3 @greensecurity/javascript-sdk"
34178
34178
  };
34179
34179
  });
34180
34180
 
@@ -35937,9 +35937,7 @@ var init_facility = __esm(() => {
35937
35937
  fax: nullableType(stringType()).optional(),
35938
35938
  website: nullableType(stringType()).optional(),
35939
35939
  utc_offset: nullableType(numberType()).optional(),
35940
- timezone: nullableType(stringType()).optional(),
35941
- latitude: nullableType(numberType()).optional(),
35942
- longitude: nullableType(numberType()).optional()
35940
+ timezone: nullableType(stringType()).optional()
35943
35941
  }).transform((v2) => {
35944
35942
  return remap(v2, {
35945
35943
  street_address: "streetAddress",
@@ -35956,9 +35954,7 @@ var init_facility = __esm(() => {
35956
35954
  fax: nullableType(stringType()).optional(),
35957
35955
  website: nullableType(stringType()).optional(),
35958
35956
  utcOffset: nullableType(numberType()).optional(),
35959
- timezone: nullableType(stringType()).optional(),
35960
- latitude: nullableType(numberType()).optional(),
35961
- longitude: nullableType(numberType()).optional()
35957
+ timezone: nullableType(stringType()).optional()
35962
35958
  }).transform((v2) => {
35963
35959
  return remap(v2, {
35964
35960
  streetAddress: "street_address",
@@ -36531,6 +36527,7 @@ var init_user = __esm(() => {
36531
36527
  init_lib();
36532
36528
  init_primitives();
36533
36529
  init_contact();
36530
+ init_imageset();
36534
36531
  UserType = {
36535
36532
  Api: "API",
36536
36533
  Admin: "Admin",
@@ -36559,12 +36556,14 @@ var init_user = __esm(() => {
36559
36556
  email: stringType(),
36560
36557
  phone: nullableType(stringType()).optional(),
36561
36558
  user_type: UserType$inboundSchema,
36562
- timezone: nullableType(stringType()).optional()
36559
+ timezone: nullableType(stringType()).optional(),
36560
+ image_urls: ImageSet$inboundSchema.optional()
36563
36561
  }).transform((v2) => {
36564
36562
  return remap(v2, {
36565
36563
  first_name: "firstName",
36566
36564
  last_name: "lastName",
36567
- user_type: "userType"
36565
+ user_type: "userType",
36566
+ image_urls: "imageUrls"
36568
36567
  });
36569
36568
  });
36570
36569
  UserUser$outboundSchema = objectType({
@@ -36574,12 +36573,14 @@ var init_user = __esm(() => {
36574
36573
  email: stringType(),
36575
36574
  phone: nullableType(stringType()).optional(),
36576
36575
  userType: UserType$outboundSchema,
36577
- timezone: nullableType(stringType()).optional()
36576
+ timezone: nullableType(stringType()).optional(),
36577
+ imageUrls: ImageSet$outboundSchema.optional()
36578
36578
  }).transform((v2) => {
36579
36579
  return remap(v2, {
36580
36580
  firstName: "first_name",
36581
36581
  lastName: "last_name",
36582
- userType: "user_type"
36582
+ userType: "user_type",
36583
+ imageUrls: "image_urls"
36583
36584
  });
36584
36585
  });
36585
36586
  ((UserUser$) => {
@@ -37186,7 +37187,7 @@ async function $do(client, request, options) {
37186
37187
  path,
37187
37188
  headers,
37188
37189
  body,
37189
- timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1
37190
+ timeoutMs: options?.timeoutMs || client._options.timeoutMs || 30000
37190
37191
  }, options);
37191
37192
  if (!requestRes.ok) {
37192
37193
  return [requestRes, { status: "invalid" }];
@@ -37298,7 +37299,7 @@ async function $do2(client, request, options) {
37298
37299
  headers,
37299
37300
  query,
37300
37301
  body,
37301
- timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1
37302
+ timeoutMs: options?.timeoutMs || client._options.timeoutMs || 30000
37302
37303
  }, options);
37303
37304
  if (!requestRes.ok) {
37304
37305
  return [requestRes, { status: "invalid" }];
@@ -37399,7 +37400,7 @@ async function $do3(client, options) {
37399
37400
  baseURL: options?.serverURL,
37400
37401
  path,
37401
37402
  headers,
37402
- timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1
37403
+ timeoutMs: options?.timeoutMs || client._options.timeoutMs || 30000
37403
37404
  }, options);
37404
37405
  if (!requestRes.ok) {
37405
37406
  return [requestRes, { status: "invalid" }];
@@ -37497,7 +37498,7 @@ async function $do4(client, request, options) {
37497
37498
  path,
37498
37499
  headers,
37499
37500
  body,
37500
- timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1
37501
+ timeoutMs: options?.timeoutMs || client._options.timeoutMs || 30000
37501
37502
  }, options);
37502
37503
  if (!requestRes.ok) {
37503
37504
  return [requestRes, { status: "invalid" }];
@@ -37595,7 +37596,7 @@ async function $do5(client, request, options) {
37595
37596
  path,
37596
37597
  headers,
37597
37598
  body,
37598
- timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1
37599
+ timeoutMs: options?.timeoutMs || client._options.timeoutMs || 30000
37599
37600
  }, options);
37600
37601
  if (!requestRes.ok) {
37601
37602
  return [requestRes, { status: "invalid" }];
@@ -37724,7 +37725,7 @@ async function $do6(client, request, options) {
37724
37725
  path,
37725
37726
  headers,
37726
37727
  body,
37727
- timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1
37728
+ timeoutMs: options?.timeoutMs || client._options.timeoutMs || 30000
37728
37729
  }, options);
37729
37730
  if (!requestRes.ok) {
37730
37731
  return [requestRes, { status: "invalid" }];
@@ -37824,7 +37825,7 @@ async function $do7(client, request, options) {
37824
37825
  path,
37825
37826
  headers,
37826
37827
  body,
37827
- timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1
37828
+ timeoutMs: options?.timeoutMs || client._options.timeoutMs || 30000
37828
37829
  }, options);
37829
37830
  if (!requestRes.ok) {
37830
37831
  return [requestRes, { status: "invalid" }];
@@ -37925,7 +37926,7 @@ async function $do8(client, request, options) {
37925
37926
  path,
37926
37927
  headers,
37927
37928
  body,
37928
- timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1
37929
+ timeoutMs: options?.timeoutMs || client._options.timeoutMs || 30000
37929
37930
  }, options);
37930
37931
  if (!requestRes.ok) {
37931
37932
  return [requestRes, { status: "invalid" }];
@@ -38022,7 +38023,7 @@ async function $do9(client, request, options) {
38022
38023
  path,
38023
38024
  headers,
38024
38025
  body,
38025
- timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1
38026
+ timeoutMs: options?.timeoutMs || client._options.timeoutMs || 30000
38026
38027
  }, options);
38027
38028
  if (!requestRes.ok) {
38028
38029
  return [requestRes, { status: "invalid" }];
@@ -38125,7 +38126,7 @@ async function $do10(client, request, options) {
38125
38126
  headers,
38126
38127
  query,
38127
38128
  body,
38128
- timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1
38129
+ timeoutMs: options?.timeoutMs || client._options.timeoutMs || 30000
38129
38130
  }, options);
38130
38131
  if (!requestRes.ok) {
38131
38132
  return [requestRes, { status: "invalid" }];
@@ -38194,9 +38195,10 @@ List valid job titles for Vendors. This can be used during sign up or in a filte
38194
38195
  function createMCPServer(deps) {
38195
38196
  const server = new McpServer({
38196
38197
  name: "GreenSecurity",
38197
- version: "0.11.0"
38198
+ version: "0.12.0"
38198
38199
  });
38199
38200
  const client = new GreenSecurityCore({
38201
+ security: deps.security,
38200
38202
  serverURL: deps.serverURL,
38201
38203
  serverIdx: deps.serverIdx
38202
38204
  });
@@ -38237,6 +38239,9 @@ __export(exports_impl, {
38237
38239
  main: () => main
38238
38240
  });
38239
38241
  async function main(flags) {
38242
+ flags.env?.forEach(([key, value]) => {
38243
+ process.env[key] = value;
38244
+ });
38240
38245
  switch (flags.transport) {
38241
38246
  case "stdio":
38242
38247
  await startStdio(flags);
@@ -38254,6 +38259,7 @@ async function startStdio(flags) {
38254
38259
  const server = createMCPServer({
38255
38260
  logger,
38256
38261
  scopes: flags.scope,
38262
+ security: { token: flags["api-token"], bearerJwt: flags["bearer-jwt"] },
38257
38263
  serverURL: flags["server-url"],
38258
38264
  serverIdx: flags["server-index"]
38259
38265
  });
@@ -38271,6 +38277,7 @@ async function startSSE(flags) {
38271
38277
  const mcpServer = createMCPServer({
38272
38278
  logger,
38273
38279
  scopes: flags.scope,
38280
+ security: { token: flags["api-token"], bearerJwt: flags["bearer-jwt"] },
38274
38281
  serverURL: flags["server-url"],
38275
38282
  serverIdx: flags["server-index"]
38276
38283
  });
@@ -39314,12 +39321,6 @@ var startCommand = tn({
39314
39321
  },
39315
39322
  parameters: {
39316
39323
  flags: {
39317
- "log-level": {
39318
- kind: "enum",
39319
- brief: "The log level to use for the server",
39320
- default: "info",
39321
- values: consoleLoggerLevels
39322
- },
39323
39324
  transport: {
39324
39325
  kind: "enum",
39325
39326
  brief: "The transport to use for communicating with the server",
@@ -39341,6 +39342,22 @@ var startCommand = tn({
39341
39342
  optional: true
39342
39343
  }
39343
39344
  } : {},
39345
+ "api-token": {
39346
+ kind: "parsed",
39347
+ brief: "Sets the token auth field for the API",
39348
+ optional: true,
39349
+ parse: (value) => {
39350
+ return stringType().parse(value);
39351
+ }
39352
+ },
39353
+ "bearer-jwt": {
39354
+ kind: "parsed",
39355
+ brief: "Sets the bearerJwt auth field for the API",
39356
+ optional: true,
39357
+ parse: (value) => {
39358
+ return stringType().parse(value);
39359
+ }
39360
+ },
39344
39361
  "server-url": {
39345
39362
  kind: "parsed",
39346
39363
  brief: "Overrides the default server URL used by the SDK",
@@ -39352,6 +39369,34 @@ var startCommand = tn({
39352
39369
  brief: "Selects a predefined server used by the SDK",
39353
39370
  optional: true,
39354
39371
  parse: oe
39372
+ },
39373
+ "log-level": {
39374
+ kind: "enum",
39375
+ brief: "The log level to use for the server",
39376
+ default: "info",
39377
+ values: consoleLoggerLevels
39378
+ },
39379
+ env: {
39380
+ kind: "parsed",
39381
+ brief: "Environment variables made available to the server",
39382
+ optional: true,
39383
+ variadic: true,
39384
+ parse: (val) => {
39385
+ const sepIdx = val.indexOf("=");
39386
+ if (sepIdx === -1) {
39387
+ throw new Error("Invalid environment variable format");
39388
+ }
39389
+ const key = val.slice(0, sepIdx);
39390
+ const value = val.slice(sepIdx + 1);
39391
+ return [
39392
+ stringType().nonempty({
39393
+ message: "Environment variable key must be a non-empty string"
39394
+ }).parse(key),
39395
+ stringType().nonempty({
39396
+ message: "Environment variable value must be a non-empty string"
39397
+ }).parse(value)
39398
+ ];
39399
+ }
39355
39400
  }
39356
39401
  }
39357
39402
  },
@@ -39372,7 +39417,7 @@ var routes = rn({
39372
39417
  var app = Ve(routes, {
39373
39418
  name: "mcp",
39374
39419
  versionInfo: {
39375
- currentVersion: "0.11.0"
39420
+ currentVersion: "0.12.0"
39376
39421
  }
39377
39422
  });
39378
39423
  _t(app, process3.argv.slice(2), buildContext(process3));
@@ -39380,5 +39425,5 @@ export {
39380
39425
  app
39381
39426
  };
39382
39427
 
39383
- //# debugId=EB6CEAED5EEB6A7064756E2164756E21
39428
+ //# debugId=A704FF916C71600F64756E2164756E21
39384
39429
  //# sourceMappingURL=mcp-server.js.map