@greensecurity/javascript-sdk 0.9.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.
- package/.devcontainer/README.md +35 -0
- package/.devcontainer/devcontainer.json +45 -0
- package/FUNCTIONS.md +109 -0
- package/REACT_QUERY.md +318 -0
- package/README.md +561 -0
- package/RUNTIMES.md +48 -0
- package/core.d.ts +10 -0
- package/core.d.ts.map +1 -0
- package/core.js +17 -0
- package/core.js.map +1 -0
- package/docs/sdks/greensecurity/README.md +14 -0
- package/docs/sdks/organizations/README.md +252 -0
- package/docs/sdks/user/README.md +348 -0
- package/docs/sdks/vendors/README.md +219 -0
- package/funcs/organizationsGetFacility.d.ts +17 -0
- package/funcs/organizationsGetFacility.d.ts.map +1 -0
- package/funcs/organizationsGetFacility.js +117 -0
- package/funcs/organizationsGetFacility.js.map +1 -0
- package/funcs/organizationsListOrSearchFacilities.d.ts +28 -0
- package/funcs/organizationsListOrSearchFacilities.d.ts.map +1 -0
- package/funcs/organizationsListOrSearchFacilities.js +131 -0
- package/funcs/organizationsListOrSearchFacilities.js.map +1 -0
- package/funcs/userGetCurrentUser.d.ts +16 -0
- package/funcs/userGetCurrentUser.d.ts.map +1 -0
- package/funcs/userGetCurrentUser.js +101 -0
- package/funcs/userGetCurrentUser.js.map +1 -0
- package/funcs/userGetUserById.d.ts +17 -0
- package/funcs/userGetUserById.d.ts.map +1 -0
- package/funcs/userGetUserById.js +117 -0
- package/funcs/userGetUserById.js.map +1 -0
- package/funcs/userLogsUserIntoTheSystem.d.ts +46 -0
- package/funcs/userLogsUserIntoTheSystem.d.ts.map +1 -0
- package/funcs/userLogsUserIntoTheSystem.js +137 -0
- package/funcs/userLogsUserIntoTheSystem.js.map +1 -0
- package/funcs/vendorsCreateVendorRegistration.d.ts +16 -0
- package/funcs/vendorsCreateVendorRegistration.d.ts.map +1 -0
- package/funcs/vendorsCreateVendorRegistration.js +107 -0
- package/funcs/vendorsCreateVendorRegistration.js.map +1 -0
- package/funcs/vendorsListVendorJobTitles.d.ts +16 -0
- package/funcs/vendorsListVendorJobTitles.d.ts.map +1 -0
- package/funcs/vendorsListVendorJobTitles.js +114 -0
- package/funcs/vendorsListVendorJobTitles.js.map +1 -0
- package/hooks/hooks.d.ts +24 -0
- package/hooks/hooks.d.ts.map +1 -0
- package/hooks/hooks.js +86 -0
- package/hooks/hooks.js.map +1 -0
- package/hooks/index.d.ts +3 -0
- package/hooks/index.d.ts.map +1 -0
- package/hooks/index.js +22 -0
- package/hooks/index.js.map +1 -0
- package/hooks/registration.d.ts +3 -0
- package/hooks/registration.d.ts.map +1 -0
- package/hooks/registration.js +15 -0
- package/hooks/registration.js.map +1 -0
- package/hooks/types.d.ts +78 -0
- package/hooks/types.d.ts.map +1 -0
- package/hooks/types.js +6 -0
- package/hooks/types.js.map +1 -0
- package/index.d.ts +4 -0
- package/index.d.ts.map +1 -0
- package/index.js +46 -0
- package/index.js.map +1 -0
- package/jsr.json +27 -0
- package/lib/base64.d.ts +10 -0
- package/lib/base64.d.ts.map +1 -0
- package/lib/base64.js +71 -0
- package/lib/base64.js.map +1 -0
- package/lib/config.d.ts +38 -0
- package/lib/config.d.ts.map +1 -0
- package/lib/config.js +46 -0
- package/lib/config.js.map +1 -0
- package/lib/dlv.d.ts +14 -0
- package/lib/dlv.d.ts.map +1 -0
- package/lib/dlv.js +49 -0
- package/lib/dlv.js.map +1 -0
- package/lib/encodings.d.ts +52 -0
- package/lib/encodings.d.ts.map +1 -0
- package/lib/encodings.js +368 -0
- package/lib/encodings.js.map +1 -0
- package/lib/env.d.ts +16 -0
- package/lib/env.d.ts.map +1 -0
- package/lib/env.js +66 -0
- package/lib/env.js.map +1 -0
- package/lib/files.d.ts +8 -0
- package/lib/files.d.ts.map +1 -0
- package/lib/files.js +36 -0
- package/lib/files.js.map +1 -0
- package/lib/http.d.ts +67 -0
- package/lib/http.d.ts.map +1 -0
- package/lib/http.js +217 -0
- package/lib/http.js.map +1 -0
- package/lib/is-plain-object.d.ts +2 -0
- package/lib/is-plain-object.d.ts.map +1 -0
- package/lib/is-plain-object.js +41 -0
- package/lib/is-plain-object.js.map +1 -0
- package/lib/logger.d.ts +6 -0
- package/lib/logger.d.ts.map +1 -0
- package/lib/logger.js +6 -0
- package/lib/logger.js.map +1 -0
- package/lib/matchers.d.ts +64 -0
- package/lib/matchers.d.ts.map +1 -0
- package/lib/matchers.js +204 -0
- package/lib/matchers.js.map +1 -0
- package/lib/primitives.d.ts +23 -0
- package/lib/primitives.d.ts.map +1 -0
- package/lib/primitives.js +104 -0
- package/lib/primitives.js.map +1 -0
- package/lib/retries.d.ts +38 -0
- package/lib/retries.d.ts.map +1 -0
- package/lib/retries.js +153 -0
- package/lib/retries.js.map +1 -0
- package/lib/schemas.d.ts +19 -0
- package/lib/schemas.d.ts.map +1 -0
- package/lib/schemas.js +62 -0
- package/lib/schemas.js.map +1 -0
- package/lib/sdks.d.ts +60 -0
- package/lib/sdks.d.ts.map +1 -0
- package/lib/sdks.js +280 -0
- package/lib/sdks.js.map +1 -0
- package/lib/security.d.ts +82 -0
- package/lib/security.d.ts.map +1 -0
- package/lib/security.js +145 -0
- package/lib/security.js.map +1 -0
- package/lib/url.d.ts +5 -0
- package/lib/url.d.ts.map +1 -0
- package/lib/url.js +25 -0
- package/lib/url.js.map +1 -0
- package/models/components/contact.d.ts +135 -0
- package/models/components/contact.d.ts.map +1 -0
- package/models/components/contact.js +172 -0
- package/models/components/contact.js.map +1 -0
- package/models/components/departmentsummary.d.ts +34 -0
- package/models/components/departmentsummary.d.ts.map +1 -0
- package/models/components/departmentsummary.js +71 -0
- package/models/components/departmentsummary.js.map +1 -0
- package/models/components/desc.d.ts +25 -0
- package/models/components/desc.d.ts.map +1 -0
- package/models/components/desc.js +66 -0
- package/models/components/desc.js.map +1 -0
- package/models/components/expand.d.ts +79 -0
- package/models/components/expand.d.ts.map +1 -0
- package/models/components/expand.js +79 -0
- package/models/components/expand.js.map +1 -0
- package/models/components/facility.d.ts +544 -0
- package/models/components/facility.d.ts.map +1 -0
- package/models/components/facility.js +797 -0
- package/models/components/facility.js.map +1 -0
- package/models/components/facilitysummary.d.ts +34 -0
- package/models/components/facilitysummary.d.ts.map +1 -0
- package/models/components/facilitysummary.js +71 -0
- package/models/components/facilitysummary.js.map +1 -0
- package/models/components/imageset.d.ts +38 -0
- package/models/components/imageset.d.ts.map +1 -0
- package/models/components/imageset.js +75 -0
- package/models/components/imageset.js.map +1 -0
- package/models/components/index.d.ts +20 -0
- package/models/components/index.d.ts.map +1 -0
- package/models/components/index.js +39 -0
- package/models/components/index.js.map +1 -0
- package/models/components/loginemailandpassword.d.ts +45 -0
- package/models/components/loginemailandpassword.d.ts.map +1 -0
- package/models/components/loginemailandpassword.js +82 -0
- package/models/components/loginemailandpassword.js.map +1 -0
- package/models/components/loginrequirementsfromemail.d.ts +40 -0
- package/models/components/loginrequirementsfromemail.d.ts.map +1 -0
- package/models/components/loginrequirementsfromemail.js +80 -0
- package/models/components/loginrequirementsfromemail.js.map +1 -0
- package/models/components/mfarequiredresponse.d.ts +98 -0
- package/models/components/mfarequiredresponse.d.ts.map +1 -0
- package/models/components/mfarequiredresponse.js +126 -0
- package/models/components/mfarequiredresponse.js.map +1 -0
- package/models/components/pager.d.ts +69 -0
- package/models/components/pager.d.ts.map +1 -0
- package/models/components/pager.js +97 -0
- package/models/components/pager.js.map +1 -0
- package/models/components/passwordrequiredresponse.d.ts +62 -0
- package/models/components/passwordrequiredresponse.d.ts.map +1 -0
- package/models/components/passwordrequiredresponse.js +92 -0
- package/models/components/passwordrequiredresponse.js.map +1 -0
- package/models/components/samlloginrequiredresponse.d.ts +73 -0
- package/models/components/samlloginrequiredresponse.d.ts.map +1 -0
- package/models/components/samlloginrequiredresponse.js +106 -0
- package/models/components/samlloginrequiredresponse.js.map +1 -0
- package/models/components/security.d.ts +31 -0
- package/models/components/security.d.ts.map +1 -0
- package/models/components/security.js +80 -0
- package/models/components/security.js.map +1 -0
- package/models/components/status.d.ts +37 -0
- package/models/components/status.d.ts.map +1 -0
- package/models/components/status.js +65 -0
- package/models/components/status.js.map +1 -0
- package/models/components/systemsummary.d.ts +34 -0
- package/models/components/systemsummary.d.ts.map +1 -0
- package/models/components/systemsummary.js +71 -0
- package/models/components/systemsummary.js.map +1 -0
- package/models/components/user.d.ts +265 -0
- package/models/components/user.d.ts.map +1 -0
- package/models/components/user.js +284 -0
- package/models/components/user.js.map +1 -0
- package/models/components/vendorjobtitle.d.ts +41 -0
- package/models/components/vendorjobtitle.d.ts.map +1 -0
- package/models/components/vendorjobtitle.js +71 -0
- package/models/components/vendorjobtitle.js.map +1 -0
- package/models/components/vendortype.d.ts +69 -0
- package/models/components/vendortype.d.ts.map +1 -0
- package/models/components/vendortype.js +135 -0
- package/models/components/vendortype.js.map +1 -0
- package/models/errors/apierror.d.ts +8 -0
- package/models/errors/apierror.d.ts.map +1 -0
- package/models/errors/apierror.js +21 -0
- package/models/errors/apierror.js.map +1 -0
- package/models/errors/apierrorresponse.d.ts +51 -0
- package/models/errors/apierrorresponse.d.ts.map +1 -0
- package/models/errors/apierrorresponse.js +91 -0
- package/models/errors/apierrorresponse.js.map +1 -0
- package/models/errors/httpclienterrors.d.ts +44 -0
- package/models/errors/httpclienterrors.d.ts.map +1 -0
- package/models/errors/httpclienterrors.js +78 -0
- package/models/errors/httpclienterrors.js.map +1 -0
- package/models/errors/index.d.ts +5 -0
- package/models/errors/index.d.ts.map +1 -0
- package/models/errors/index.js +24 -0
- package/models/errors/index.js.map +1 -0
- package/models/errors/sdkvalidationerror.d.ts +20 -0
- package/models/errors/sdkvalidationerror.d.ts.map +1 -0
- package/models/errors/sdkvalidationerror.js +115 -0
- package/models/errors/sdkvalidationerror.js.map +1 -0
- package/models/operations/createvendorregistration.d.ts +115 -0
- package/models/operations/createvendorregistration.d.ts.map +1 -0
- package/models/operations/createvendorregistration.js +143 -0
- package/models/operations/createvendorregistration.js.map +1 -0
- package/models/operations/getfacility.d.ts +32 -0
- package/models/operations/getfacility.d.ts.map +1 -0
- package/models/operations/getfacility.js +69 -0
- package/models/operations/getfacility.js.map +1 -0
- package/models/operations/getuserbyid.d.ts +32 -0
- package/models/operations/getuserbyid.d.ts.map +1 -0
- package/models/operations/getuserbyid.js +69 -0
- package/models/operations/getuserbyid.js.map +1 -0
- package/models/operations/index.d.ts +7 -0
- package/models/operations/index.d.ts.map +1 -0
- package/models/operations/index.js +26 -0
- package/models/operations/index.js.map +1 -0
- package/models/operations/listorsearchfacilities.d.ts +110 -0
- package/models/operations/listorsearchfacilities.d.ts.map +1 -0
- package/models/operations/listorsearchfacilities.js +130 -0
- package/models/operations/listorsearchfacilities.js.map +1 -0
- package/models/operations/listvendorjobtitles.d.ts +86 -0
- package/models/operations/listvendorjobtitles.d.ts.map +1 -0
- package/models/operations/listvendorjobtitles.js +118 -0
- package/models/operations/listvendorjobtitles.js.map +1 -0
- package/models/operations/logsuserintothesystem.d.ts +98 -0
- package/models/operations/logsuserintothesystem.d.ts.map +1 -0
- package/models/operations/logsuserintothesystem.js +164 -0
- package/models/operations/logsuserintothesystem.js.map +1 -0
- package/package.json +41 -0
- package/react-query/_context.d.ts +8 -0
- package/react-query/_context.d.ts.map +1 -0
- package/react-query/_context.js +21 -0
- package/react-query/_context.js.map +1 -0
- package/react-query/_types.d.ts +14 -0
- package/react-query/_types.d.ts.map +1 -0
- package/react-query/_types.js +6 -0
- package/react-query/_types.js.map +1 -0
- package/react-query/index.d.ts +10 -0
- package/react-query/index.d.ts.map +1 -0
- package/react-query/index.js +32 -0
- package/react-query/index.js.map +1 -0
- package/react-query/organizationsGetFacility.d.ts +31 -0
- package/react-query/organizationsGetFacility.d.ts.map +1 -0
- package/react-query/organizationsGetFacility.js +87 -0
- package/react-query/organizationsGetFacility.js.map +1 -0
- package/react-query/organizationsListOrSearchFacilities.d.ts +91 -0
- package/react-query/organizationsListOrSearchFacilities.d.ts.map +1 -0
- package/react-query/organizationsListOrSearchFacilities.js +132 -0
- package/react-query/organizationsListOrSearchFacilities.js.map +1 -0
- package/react-query/userGetCurrentUser.d.ts +29 -0
- package/react-query/userGetCurrentUser.d.ts.map +1 -0
- package/react-query/userGetCurrentUser.js +75 -0
- package/react-query/userGetCurrentUser.js.map +1 -0
- package/react-query/userGetUserById.d.ts +31 -0
- package/react-query/userGetUserById.d.ts.map +1 -0
- package/react-query/userGetUserById.js +87 -0
- package/react-query/userGetUserById.js.map +1 -0
- package/react-query/userLogsUserIntoTheSystem.d.ts +53 -0
- package/react-query/userLogsUserIntoTheSystem.d.ts.map +1 -0
- package/react-query/userLogsUserIntoTheSystem.js +77 -0
- package/react-query/userLogsUserIntoTheSystem.js.map +1 -0
- package/react-query/vendorsCreateVendorRegistration.d.ts +23 -0
- package/react-query/vendorsCreateVendorRegistration.d.ts.map +1 -0
- package/react-query/vendorsCreateVendorRegistration.js +51 -0
- package/react-query/vendorsCreateVendorRegistration.js.map +1 -0
- package/react-query/vendorsListVendorJobTitles.d.ts +53 -0
- package/react-query/vendorsListVendorJobTitles.d.ts.map +1 -0
- package/react-query/vendorsListVendorJobTitles.js +102 -0
- package/react-query/vendorsListVendorJobTitles.js.map +1 -0
- package/sdk/index.d.ts +2 -0
- package/sdk/index.d.ts.map +1 -0
- package/sdk/index.js +21 -0
- package/sdk/index.js.map +1 -0
- package/sdk/organizations.d.ts +33 -0
- package/sdk/organizations.d.ts.map +1 -0
- package/sdk/organizations.js +45 -0
- package/sdk/organizations.js.map +1 -0
- package/sdk/sdk.d.ts +13 -0
- package/sdk/sdk.d.ts.map +1 -0
- package/sdk/sdk.js +23 -0
- package/sdk/sdk.js.map +1 -0
- package/sdk/user.d.ts +57 -0
- package/sdk/user.d.ts.map +1 -0
- package/sdk/user.js +72 -0
- package/sdk/user.js.map +1 -0
- package/sdk/vendors.d.ts +19 -0
- package/sdk/vendors.d.ts.map +1 -0
- package/sdk/vendors.js +32 -0
- package/sdk/vendors.js.map +1 -0
- package/src/core.ts +13 -0
- package/src/funcs/organizationsGetFacility.ts +144 -0
- package/src/funcs/organizationsListOrSearchFacilities.ts +152 -0
- package/src/funcs/userGetCurrentUser.ts +118 -0
- package/src/funcs/userGetUserById.ts +141 -0
- package/src/funcs/userLogsUserIntoTheSystem.ts +161 -0
- package/src/funcs/vendorsCreateVendorRegistration.ts +132 -0
- package/src/funcs/vendorsListVendorJobTitles.ts +141 -0
- package/src/hooks/hooks.ts +132 -0
- package/src/hooks/index.ts +6 -0
- package/src/hooks/registration.ts +14 -0
- package/src/hooks/types.ts +110 -0
- package/src/index.ts +7 -0
- package/src/lib/base64.ts +37 -0
- package/src/lib/config.ts +76 -0
- package/src/lib/dlv.ts +53 -0
- package/src/lib/encodings.ts +483 -0
- package/src/lib/env.ts +43 -0
- package/src/lib/files.ts +40 -0
- package/src/lib/http.ts +323 -0
- package/src/lib/is-plain-object.ts +43 -0
- package/src/lib/logger.ts +9 -0
- package/src/lib/matchers.ts +322 -0
- package/src/lib/primitives.ts +136 -0
- package/src/lib/retries.ts +218 -0
- package/src/lib/schemas.ts +91 -0
- package/src/lib/sdks.ts +400 -0
- package/src/lib/security.ts +260 -0
- package/src/lib/url.ts +33 -0
- package/src/models/components/contact.ts +268 -0
- package/src/models/components/departmentsummary.ts +73 -0
- package/src/models/components/desc.ts +48 -0
- package/src/models/components/expand.ts +52 -0
- package/src/models/components/facility.ts +1334 -0
- package/src/models/components/facilitysummary.ts +71 -0
- package/src/models/components/imageset.ts +77 -0
- package/src/models/components/index.ts +23 -0
- package/src/models/components/loginemailandpassword.ts +95 -0
- package/src/models/components/loginrequirementsfromemail.ts +88 -0
- package/src/models/components/mfarequiredresponse.ts +160 -0
- package/src/models/components/pager.ts +126 -0
- package/src/models/components/passwordrequiredresponse.ts +105 -0
- package/src/models/components/samlloginrequiredresponse.ts +136 -0
- package/src/models/components/security.ts +75 -0
- package/src/models/components/status.ts +38 -0
- package/src/models/components/systemsummary.ts +69 -0
- package/src/models/components/user.ts +451 -0
- package/src/models/components/vendorjobtitle.ts +76 -0
- package/src/models/components/vendortype.ts +170 -0
- package/src/models/errors/apierror.ts +27 -0
- package/src/models/errors/apierrorresponse.ts +95 -0
- package/src/models/errors/httpclienterrors.ts +62 -0
- package/src/models/errors/index.ts +8 -0
- package/src/models/errors/sdkvalidationerror.ts +97 -0
- package/src/models/operations/createvendorregistration.ts +237 -0
- package/src/models/operations/getfacility.ts +69 -0
- package/src/models/operations/getuserbyid.ts +69 -0
- package/src/models/operations/index.ts +10 -0
- package/src/models/operations/listorsearchfacilities.ts +219 -0
- package/src/models/operations/listvendorjobtitles.ts +179 -0
- package/src/models/operations/logsuserintothesystem.ts +270 -0
- package/src/react-query/_types.ts +91 -0
- package/src/react-query/index.ts +14 -0
- package/src/react-query/organizationsGetFacility.ts +154 -0
- package/src/react-query/organizationsListOrSearchFacilities.ts +241 -0
- package/src/react-query/userGetCurrentUser.ts +124 -0
- package/src/react-query/userGetUserById.ts +152 -0
- package/src/react-query/userLogsUserIntoTheSystem.ts +119 -0
- package/src/react-query/vendorsCreateVendorRegistration.ts +93 -0
- package/src/react-query/vendorsListVendorJobTitles.ts +194 -0
- package/src/sdk/index.ts +5 -0
- package/src/sdk/organizations.ts +59 -0
- package/src/sdk/sdk.ts +25 -0
- package/src/sdk/user.ts +92 -0
- package/src/sdk/vendors.ts +45 -0
- package/src/types/blobs.ts +31 -0
- package/src/types/constdatetime.ts +15 -0
- package/src/types/enums.ts +16 -0
- package/src/types/fp.ts +50 -0
- package/src/types/index.ts +11 -0
- package/src/types/operations.ts +105 -0
- package/src/types/rfcdate.ts +54 -0
- package/src/types/streams.ts +21 -0
- package/tsconfig.json +41 -0
- package/types/blobs.d.ts +4 -0
- package/types/blobs.d.ts.map +1 -0
- package/types/blobs.js +62 -0
- package/types/blobs.js.map +1 -0
- package/types/constdatetime.d.ts +3 -0
- package/types/constdatetime.d.ts.map +1 -0
- package/types/constdatetime.js +46 -0
- package/types/constdatetime.js.map +1 -0
- package/types/enums.d.ts +12 -0
- package/types/enums.d.ts.map +1 -0
- package/types/enums.js +10 -0
- package/types/enums.js.map +1 -0
- package/types/fp.d.ts +31 -0
- package/types/fp.d.ts.map +1 -0
- package/types/fp.js +37 -0
- package/types/fp.js.map +1 -0
- package/types/index.d.ts +8 -0
- package/types/index.d.ts.map +1 -0
- package/types/index.js +16 -0
- package/types/index.js.map +1 -0
- package/types/operations.d.ts +27 -0
- package/types/operations.d.ts.map +1 -0
- package/types/operations.js +83 -0
- package/types/operations.js.map +1 -0
- package/types/rfcdate.d.ts +21 -0
- package/types/rfcdate.d.ts.map +1 -0
- package/types/rfcdate.js +46 -0
- package/types/rfcdate.js.map +1 -0
- package/types/streams.d.ts +2 -0
- package/types/streams.d.ts.map +1 -0
- package/types/streams.js +18 -0
- package/types/streams.js.map +1 -0
package/README.md
ADDED
|
@@ -0,0 +1,561 @@
|
|
|
1
|
+
# greensecurity
|
|
2
|
+
|
|
3
|
+
Developer-friendly & type-safe Typescript SDK specifically catered to leverage *greensecurity* API.
|
|
4
|
+
|
|
5
|
+
<div align="left">
|
|
6
|
+
<a href="https://www.speakeasy.com/?utm_source=greensecurity&utm_campaign=typescript"><img src="https://custom-icon-badges.demolab.com/badge/-Built%20By%20Speakeasy-212015?style=for-the-badge&logoColor=FBE331&logo=speakeasy&labelColor=545454" /></a>
|
|
7
|
+
<a href="https://opensource.org/licenses/MIT">
|
|
8
|
+
<img src="https://img.shields.io/badge/License-MIT-blue.svg" style="width: 100px; height: 28px;" />
|
|
9
|
+
</a>
|
|
10
|
+
</div>
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
<br /><br />
|
|
14
|
+
> [!IMPORTANT]
|
|
15
|
+
> This SDK is not yet ready for production use. To complete setup please follow the steps outlined in
|
|
16
|
+
> your [workspace](https://app.speakeasy.com/org/green-security-llc/repconnex). Delete this section before > publishing to
|
|
17
|
+
> a package manager.
|
|
18
|
+
|
|
19
|
+
<!-- Start Summary [summary] -->
|
|
20
|
+
## Summary
|
|
21
|
+
|
|
22
|
+
API Reference: The Green Security API is organized around [REST](http://en.wikipedia.org/wiki/Representational_State_Transfer).
|
|
23
|
+
Our API has predictable resource-oriented URLs, accepts [JSON-encoded](http://www.json.org/) request bodies,
|
|
24
|
+
returns JSON-encoded responses, and uses standard HTTP response codes, authentication, and verbs.
|
|
25
|
+
|
|
26
|
+
The API is updated frequently, so be sure to check back often for the latest information.
|
|
27
|
+
|
|
28
|
+
Some useful links:
|
|
29
|
+
- [OpenAPI Reference](https://www.speakeasy.com/openapi)
|
|
30
|
+
<!-- End Summary [summary] -->
|
|
31
|
+
|
|
32
|
+
<!-- Start Table of Contents [toc] -->
|
|
33
|
+
## Table of Contents
|
|
34
|
+
<!-- $toc-max-depth=2 -->
|
|
35
|
+
* [greensecurity](#greensecurity)
|
|
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)
|
|
48
|
+
* [Development](#development)
|
|
49
|
+
* [Maturity](#maturity)
|
|
50
|
+
* [Contributions](#contributions)
|
|
51
|
+
|
|
52
|
+
<!-- End Table of Contents [toc] -->
|
|
53
|
+
|
|
54
|
+
<!-- Start SDK Installation [installation] -->
|
|
55
|
+
## SDK Installation
|
|
56
|
+
|
|
57
|
+
The SDK can be installed with either [npm](https://www.npmjs.com/), [pnpm](https://pnpm.io/), [bun](https://bun.sh/) or [yarn](https://classic.yarnpkg.com/en/) package managers.
|
|
58
|
+
|
|
59
|
+
### NPM
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
npm add @greensecurity/javascript-sdk
|
|
63
|
+
# Install optional peer dependencies if you plan to use React hooks
|
|
64
|
+
npm add @tanstack/react-query react react-dom
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### PNPM
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
pnpm add @greensecurity/javascript-sdk
|
|
71
|
+
# Install optional peer dependencies if you plan to use React hooks
|
|
72
|
+
pnpm add @tanstack/react-query react react-dom
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### Bun
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
bun add @greensecurity/javascript-sdk
|
|
79
|
+
# Install optional peer dependencies if you plan to use React hooks
|
|
80
|
+
bun add @tanstack/react-query react react-dom
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### Yarn
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
yarn add @greensecurity/javascript-sdk zod
|
|
87
|
+
# Install optional peer dependencies if you plan to use React hooks
|
|
88
|
+
yarn add @tanstack/react-query react react-dom
|
|
89
|
+
|
|
90
|
+
# Note that Yarn does not install peer dependencies automatically. You will need
|
|
91
|
+
# to install zod as shown above.
|
|
92
|
+
```
|
|
93
|
+
<!-- End SDK Installation [installation] -->
|
|
94
|
+
|
|
95
|
+
<!-- Start Requirements [requirements] -->
|
|
96
|
+
## Requirements
|
|
97
|
+
|
|
98
|
+
For supported JavaScript runtimes, please consult [RUNTIMES.md](RUNTIMES.md).
|
|
99
|
+
<!-- End Requirements [requirements] -->
|
|
100
|
+
|
|
101
|
+
<!-- Start SDK Example Usage [usage] -->
|
|
102
|
+
## SDK Example Usage
|
|
103
|
+
|
|
104
|
+
### Example
|
|
105
|
+
|
|
106
|
+
```typescript
|
|
107
|
+
import { GreenSecurity } from "@greensecurity/javascript-sdk";
|
|
108
|
+
|
|
109
|
+
const greenSecurity = new GreenSecurity();
|
|
110
|
+
|
|
111
|
+
async function run() {
|
|
112
|
+
const result = await greenSecurity.vendors.createVendorRegistration({
|
|
113
|
+
email: "user@example.com",
|
|
114
|
+
password: "Abcdef123!",
|
|
115
|
+
timezone: "America/Chicago",
|
|
116
|
+
affiliateId: 123,
|
|
117
|
+
vendorGroupId: 123,
|
|
118
|
+
managingCompanyId: 123,
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
// Handle the result
|
|
122
|
+
console.log(result);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
run();
|
|
126
|
+
|
|
127
|
+
```
|
|
128
|
+
<!-- End SDK Example Usage [usage] -->
|
|
129
|
+
|
|
130
|
+
<!-- Start Authentication [security] -->
|
|
131
|
+
## Authentication
|
|
132
|
+
|
|
133
|
+
### Per-Client Security Schemes
|
|
134
|
+
|
|
135
|
+
This SDK supports the following security schemes globally:
|
|
136
|
+
|
|
137
|
+
| Name | Type | Scheme | Environment Variable |
|
|
138
|
+
| ----------- | ------ | ----------- | --------------------------- |
|
|
139
|
+
| `token` | apiKey | API key | `GREEN_SECURITY_TOKEN` |
|
|
140
|
+
| `bearerJwt` | http | HTTP Bearer | `GREEN_SECURITY_BEARER_JWT` |
|
|
141
|
+
|
|
142
|
+
You can set the security parameters through the `security` optional parameter when initializing the SDK client instance. The selected scheme will be used by default to authenticate with the API for all operations that support it. For example:
|
|
143
|
+
```typescript
|
|
144
|
+
import { GreenSecurity } from "@greensecurity/javascript-sdk";
|
|
145
|
+
|
|
146
|
+
const greenSecurity = new GreenSecurity({
|
|
147
|
+
security: {
|
|
148
|
+
token: process.env["GREEN_SECURITY_TOKEN"] ?? "",
|
|
149
|
+
},
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
async function run() {
|
|
153
|
+
const result = await greenSecurity.vendors.createVendorRegistration({
|
|
154
|
+
email: "user@example.com",
|
|
155
|
+
password: "Abcdef123!",
|
|
156
|
+
timezone: "America/Chicago",
|
|
157
|
+
affiliateId: 123,
|
|
158
|
+
vendorGroupId: 123,
|
|
159
|
+
managingCompanyId: 123,
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
// Handle the result
|
|
163
|
+
console.log(result);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
run();
|
|
167
|
+
|
|
168
|
+
```
|
|
169
|
+
<!-- End Authentication [security] -->
|
|
170
|
+
|
|
171
|
+
<!-- Start Available Resources and Operations [operations] -->
|
|
172
|
+
## Available Resources and Operations
|
|
173
|
+
|
|
174
|
+
<details open>
|
|
175
|
+
<summary>Available methods</summary>
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
### [organizations](docs/sdks/organizations/README.md)
|
|
179
|
+
|
|
180
|
+
* [listOrSearchFacilities](docs/sdks/organizations/README.md#listorsearchfacilities) - List or search facilities
|
|
181
|
+
* [getFacility](docs/sdks/organizations/README.md#getfacility) - Get facility
|
|
182
|
+
|
|
183
|
+
### [user](docs/sdks/user/README.md)
|
|
184
|
+
|
|
185
|
+
* [getCurrentUser](docs/sdks/user/README.md#getcurrentuser) - Get current user
|
|
186
|
+
* [getUserById](docs/sdks/user/README.md#getuserbyid) - Get user by id
|
|
187
|
+
* [logsUserIntoTheSystem](docs/sdks/user/README.md#logsuserintothesystem) - Logs user into the system
|
|
188
|
+
|
|
189
|
+
### [vendors](docs/sdks/vendors/README.md)
|
|
190
|
+
|
|
191
|
+
* [createVendorRegistration](docs/sdks/vendors/README.md#createvendorregistration) - Create vendor registration
|
|
192
|
+
* [listVendorJobTitles](docs/sdks/vendors/README.md#listvendorjobtitles) - List vendor job titles
|
|
193
|
+
|
|
194
|
+
</details>
|
|
195
|
+
<!-- End Available Resources and Operations [operations] -->
|
|
196
|
+
|
|
197
|
+
<!-- Start Standalone functions [standalone-funcs] -->
|
|
198
|
+
## Standalone functions
|
|
199
|
+
|
|
200
|
+
All the methods listed above are available as standalone functions. These
|
|
201
|
+
functions are ideal for use in applications running in the browser, serverless
|
|
202
|
+
runtimes or other environments where application bundle size is a primary
|
|
203
|
+
concern. When using a bundler to build your application, all unused
|
|
204
|
+
functionality will be either excluded from the final bundle or tree-shaken away.
|
|
205
|
+
|
|
206
|
+
To read more about standalone functions, check [FUNCTIONS.md](./FUNCTIONS.md).
|
|
207
|
+
|
|
208
|
+
<details>
|
|
209
|
+
|
|
210
|
+
<summary>Available standalone functions</summary>
|
|
211
|
+
|
|
212
|
+
- [`organizationsGetFacility`](docs/sdks/organizations/README.md#getfacility) - Get facility
|
|
213
|
+
- [`organizationsListOrSearchFacilities`](docs/sdks/organizations/README.md#listorsearchfacilities) - List or search facilities
|
|
214
|
+
- [`userGetCurrentUser`](docs/sdks/user/README.md#getcurrentuser) - Get current user
|
|
215
|
+
- [`userGetUserById`](docs/sdks/user/README.md#getuserbyid) - Get user by id
|
|
216
|
+
- [`userLogsUserIntoTheSystem`](docs/sdks/user/README.md#logsuserintothesystem) - Logs user into the system
|
|
217
|
+
- [`vendorsCreateVendorRegistration`](docs/sdks/vendors/README.md#createvendorregistration) - Create vendor registration
|
|
218
|
+
- [`vendorsListVendorJobTitles`](docs/sdks/vendors/README.md#listvendorjobtitles) - List vendor job titles
|
|
219
|
+
|
|
220
|
+
</details>
|
|
221
|
+
<!-- End Standalone functions [standalone-funcs] -->
|
|
222
|
+
|
|
223
|
+
<!-- Start React hooks with TanStack Query [react-query] -->
|
|
224
|
+
## React hooks with TanStack Query
|
|
225
|
+
|
|
226
|
+
React hooks built on [TanStack Query][tanstack-query] are included in this SDK.
|
|
227
|
+
These hooks and the utility functions provided alongside them can be used to
|
|
228
|
+
build rich applications that pull data from the API using one of the most
|
|
229
|
+
popular asynchronous state management library.
|
|
230
|
+
|
|
231
|
+
[tanstack-query]: https://tanstack.com/query/v5/docs/framework/react/overview
|
|
232
|
+
|
|
233
|
+
To learn about this feature and how to get started, check
|
|
234
|
+
[REACT_QUERY.md](./REACT_QUERY.md).
|
|
235
|
+
|
|
236
|
+
> [!WARNING]
|
|
237
|
+
>
|
|
238
|
+
> This feature is currently in **preview** and is subject to breaking changes
|
|
239
|
+
> within the current major version of the SDK as we gather user feedback on it.
|
|
240
|
+
|
|
241
|
+
<details>
|
|
242
|
+
|
|
243
|
+
<summary>Available React hooks</summary>
|
|
244
|
+
|
|
245
|
+
- [`useOrganizationsGetFacility`](docs/sdks/organizations/README.md#getfacility) - Get facility
|
|
246
|
+
- [`useOrganizationsListOrSearchFacilities`](docs/sdks/organizations/README.md#listorsearchfacilities) - List or search facilities
|
|
247
|
+
- [`useUserGetCurrentUser`](docs/sdks/user/README.md#getcurrentuser) - Get current user
|
|
248
|
+
- [`useUserGetUserById`](docs/sdks/user/README.md#getuserbyid) - Get user by id
|
|
249
|
+
- [`useUserLogsUserIntoTheSystemMutation`](docs/sdks/user/README.md#logsuserintothesystem) - Logs user into the system
|
|
250
|
+
- [`useVendorsCreateVendorRegistrationMutation`](docs/sdks/vendors/README.md#createvendorregistration) - Create vendor registration
|
|
251
|
+
- [`useVendorsListVendorJobTitles`](docs/sdks/vendors/README.md#listvendorjobtitles) - List vendor job titles
|
|
252
|
+
|
|
253
|
+
</details>
|
|
254
|
+
<!-- End React hooks with TanStack Query [react-query] -->
|
|
255
|
+
|
|
256
|
+
<!-- Start Retries [retries] -->
|
|
257
|
+
## Retries
|
|
258
|
+
|
|
259
|
+
Some of the endpoints in this SDK support retries. If you use the SDK without any configuration, it will fall back to the default retry strategy provided by the API. However, the default retry strategy can be overridden on a per-operation basis, or across the entire SDK.
|
|
260
|
+
|
|
261
|
+
To change the default retry strategy for a single API call, simply provide a retryConfig object to the call:
|
|
262
|
+
```typescript
|
|
263
|
+
import { GreenSecurity } from "@greensecurity/javascript-sdk";
|
|
264
|
+
|
|
265
|
+
const greenSecurity = new GreenSecurity();
|
|
266
|
+
|
|
267
|
+
async function run() {
|
|
268
|
+
const result = await greenSecurity.vendors.createVendorRegistration({
|
|
269
|
+
email: "user@example.com",
|
|
270
|
+
password: "Abcdef123!",
|
|
271
|
+
timezone: "America/Chicago",
|
|
272
|
+
affiliateId: 123,
|
|
273
|
+
vendorGroupId: 123,
|
|
274
|
+
managingCompanyId: 123,
|
|
275
|
+
}, {
|
|
276
|
+
retries: {
|
|
277
|
+
strategy: "backoff",
|
|
278
|
+
backoff: {
|
|
279
|
+
initialInterval: 1,
|
|
280
|
+
maxInterval: 50,
|
|
281
|
+
exponent: 1.1,
|
|
282
|
+
maxElapsedTime: 100,
|
|
283
|
+
},
|
|
284
|
+
retryConnectionErrors: false,
|
|
285
|
+
},
|
|
286
|
+
});
|
|
287
|
+
|
|
288
|
+
// Handle the result
|
|
289
|
+
console.log(result);
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
run();
|
|
293
|
+
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
If you'd like to override the default retry strategy for all operations that support retries, you can provide a retryConfig at SDK initialization:
|
|
297
|
+
```typescript
|
|
298
|
+
import { GreenSecurity } from "@greensecurity/javascript-sdk";
|
|
299
|
+
|
|
300
|
+
const greenSecurity = new GreenSecurity({
|
|
301
|
+
retryConfig: {
|
|
302
|
+
strategy: "backoff",
|
|
303
|
+
backoff: {
|
|
304
|
+
initialInterval: 1,
|
|
305
|
+
maxInterval: 50,
|
|
306
|
+
exponent: 1.1,
|
|
307
|
+
maxElapsedTime: 100,
|
|
308
|
+
},
|
|
309
|
+
retryConnectionErrors: false,
|
|
310
|
+
},
|
|
311
|
+
});
|
|
312
|
+
|
|
313
|
+
async function run() {
|
|
314
|
+
const result = await greenSecurity.vendors.createVendorRegistration({
|
|
315
|
+
email: "user@example.com",
|
|
316
|
+
password: "Abcdef123!",
|
|
317
|
+
timezone: "America/Chicago",
|
|
318
|
+
affiliateId: 123,
|
|
319
|
+
vendorGroupId: 123,
|
|
320
|
+
managingCompanyId: 123,
|
|
321
|
+
});
|
|
322
|
+
|
|
323
|
+
// Handle the result
|
|
324
|
+
console.log(result);
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
run();
|
|
328
|
+
|
|
329
|
+
```
|
|
330
|
+
<!-- End Retries [retries] -->
|
|
331
|
+
|
|
332
|
+
<!-- Start Error Handling [errors] -->
|
|
333
|
+
## Error Handling
|
|
334
|
+
|
|
335
|
+
Some methods specify known errors which can be thrown. All the known errors are enumerated in the `models/errors/errors.ts` module. The known errors for a method are documented under the *Errors* tables in SDK docs. For example, the `createVendorRegistration` method may throw the following errors:
|
|
336
|
+
|
|
337
|
+
| Error Type | Status Code | Content Type |
|
|
338
|
+
| ----------------------- | ------------------ | ---------------- |
|
|
339
|
+
| errors.ApiErrorResponse | 400, 401, 403, 409 | application/json |
|
|
340
|
+
| errors.APIError | 4XX, 5XX | \*/\* |
|
|
341
|
+
|
|
342
|
+
If the method throws an error and it is not captured by the known errors, it will default to throwing a `APIError`.
|
|
343
|
+
|
|
344
|
+
```typescript
|
|
345
|
+
import { GreenSecurity } from "@greensecurity/javascript-sdk";
|
|
346
|
+
import {
|
|
347
|
+
ApiErrorResponse,
|
|
348
|
+
SDKValidationError,
|
|
349
|
+
} from "@greensecurity/javascript-sdk/models/errors";
|
|
350
|
+
|
|
351
|
+
const greenSecurity = new GreenSecurity();
|
|
352
|
+
|
|
353
|
+
async function run() {
|
|
354
|
+
let result;
|
|
355
|
+
try {
|
|
356
|
+
result = await greenSecurity.vendors.createVendorRegistration({
|
|
357
|
+
email: "user@example.com",
|
|
358
|
+
password: "Abcdef123!",
|
|
359
|
+
timezone: "America/Chicago",
|
|
360
|
+
affiliateId: 123,
|
|
361
|
+
vendorGroupId: 123,
|
|
362
|
+
managingCompanyId: 123,
|
|
363
|
+
});
|
|
364
|
+
|
|
365
|
+
// Handle the result
|
|
366
|
+
console.log(result);
|
|
367
|
+
} catch (err) {
|
|
368
|
+
switch (true) {
|
|
369
|
+
// The server response does not match the expected SDK schema
|
|
370
|
+
case (err instanceof SDKValidationError): {
|
|
371
|
+
// Pretty-print will provide a human-readable multi-line error message
|
|
372
|
+
console.error(err.pretty());
|
|
373
|
+
// Raw value may also be inspected
|
|
374
|
+
console.error(err.rawValue);
|
|
375
|
+
return;
|
|
376
|
+
}
|
|
377
|
+
case (err instanceof ApiErrorResponse): {
|
|
378
|
+
// Handle err.data$: ApiErrorResponseData
|
|
379
|
+
console.error(err);
|
|
380
|
+
return;
|
|
381
|
+
}
|
|
382
|
+
default: {
|
|
383
|
+
// Other errors such as network errors, see HTTPClientErrors for more details
|
|
384
|
+
throw err;
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
run();
|
|
391
|
+
|
|
392
|
+
```
|
|
393
|
+
|
|
394
|
+
Validation errors can also occur when either method arguments or data returned from the server do not match the expected format. The `SDKValidationError` that is thrown as a result will capture the raw value that failed validation in an attribute called `rawValue`. Additionally, a `pretty()` method is available on this error that can be used to log a nicely formatted multi-line string since validation errors can list many issues and the plain error string may be difficult read when debugging.
|
|
395
|
+
|
|
396
|
+
In some rare cases, the SDK can fail to get a response from the server or even make the request due to unexpected circumstances such as network conditions. These types of errors are captured in the `models/errors/httpclienterrors.ts` module:
|
|
397
|
+
|
|
398
|
+
| HTTP Client Error | Description |
|
|
399
|
+
| ---------------------------------------------------- | ---------------------------------------------------- |
|
|
400
|
+
| RequestAbortedError | HTTP request was aborted by the client |
|
|
401
|
+
| RequestTimeoutError | HTTP request timed out due to an AbortSignal signal |
|
|
402
|
+
| ConnectionError | HTTP client was unable to make a request to a server |
|
|
403
|
+
| InvalidRequestError | Any input used to create a request is invalid |
|
|
404
|
+
| UnexpectedClientError | Unrecognised or unexpected error |
|
|
405
|
+
<!-- End Error Handling [errors] -->
|
|
406
|
+
|
|
407
|
+
<!-- Start Server Selection [server] -->
|
|
408
|
+
## Server Selection
|
|
409
|
+
|
|
410
|
+
### Select Server by Index
|
|
411
|
+
|
|
412
|
+
You can override the default server globally by passing a server index to the `serverIdx: number` optional parameter when initializing the SDK client instance. The selected server will then be used as the default on the operations that use it. This table lists the indexes associated with the available servers:
|
|
413
|
+
|
|
414
|
+
| # | Server |
|
|
415
|
+
| --- | ------------------------------------------ |
|
|
416
|
+
| 0 | `https://www.greensecurityllc.com/api` |
|
|
417
|
+
| 1 | `https://staging.greensecurityllc.com/api` |
|
|
418
|
+
| 2 | `https://localhost:3000/api` |
|
|
419
|
+
|
|
420
|
+
#### Example
|
|
421
|
+
|
|
422
|
+
```typescript
|
|
423
|
+
import { GreenSecurity } from "@greensecurity/javascript-sdk";
|
|
424
|
+
|
|
425
|
+
const greenSecurity = new GreenSecurity({
|
|
426
|
+
serverIdx: 2,
|
|
427
|
+
});
|
|
428
|
+
|
|
429
|
+
async function run() {
|
|
430
|
+
const result = await greenSecurity.vendors.createVendorRegistration({
|
|
431
|
+
email: "user@example.com",
|
|
432
|
+
password: "Abcdef123!",
|
|
433
|
+
timezone: "America/Chicago",
|
|
434
|
+
affiliateId: 123,
|
|
435
|
+
vendorGroupId: 123,
|
|
436
|
+
managingCompanyId: 123,
|
|
437
|
+
});
|
|
438
|
+
|
|
439
|
+
// Handle the result
|
|
440
|
+
console.log(result);
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
run();
|
|
444
|
+
|
|
445
|
+
```
|
|
446
|
+
|
|
447
|
+
### Override Server URL Per-Client
|
|
448
|
+
|
|
449
|
+
The default server can also be overridden globally by passing a URL to the `serverURL: string` optional parameter when initializing the SDK client instance. For example:
|
|
450
|
+
```typescript
|
|
451
|
+
import { GreenSecurity } from "@greensecurity/javascript-sdk";
|
|
452
|
+
|
|
453
|
+
const greenSecurity = new GreenSecurity({
|
|
454
|
+
serverURL: "https://www.greensecurityllc.com/api",
|
|
455
|
+
});
|
|
456
|
+
|
|
457
|
+
async function run() {
|
|
458
|
+
const result = await greenSecurity.vendors.createVendorRegistration({
|
|
459
|
+
email: "user@example.com",
|
|
460
|
+
password: "Abcdef123!",
|
|
461
|
+
timezone: "America/Chicago",
|
|
462
|
+
affiliateId: 123,
|
|
463
|
+
vendorGroupId: 123,
|
|
464
|
+
managingCompanyId: 123,
|
|
465
|
+
});
|
|
466
|
+
|
|
467
|
+
// Handle the result
|
|
468
|
+
console.log(result);
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
run();
|
|
472
|
+
|
|
473
|
+
```
|
|
474
|
+
<!-- End Server Selection [server] -->
|
|
475
|
+
|
|
476
|
+
<!-- Start Custom HTTP Client [http-client] -->
|
|
477
|
+
## Custom HTTP Client
|
|
478
|
+
|
|
479
|
+
The TypeScript SDK makes API calls using an `HTTPClient` that wraps the native
|
|
480
|
+
[Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API). This
|
|
481
|
+
client is a thin wrapper around `fetch` and provides the ability to attach hooks
|
|
482
|
+
around the request lifecycle that can be used to modify the request or handle
|
|
483
|
+
errors and response.
|
|
484
|
+
|
|
485
|
+
The `HTTPClient` constructor takes an optional `fetcher` argument that can be
|
|
486
|
+
used to integrate a third-party HTTP client or when writing tests to mock out
|
|
487
|
+
the HTTP client and feed in fixtures.
|
|
488
|
+
|
|
489
|
+
The following example shows how to use the `"beforeRequest"` hook to to add a
|
|
490
|
+
custom header and a timeout to requests and how to use the `"requestError"` hook
|
|
491
|
+
to log errors:
|
|
492
|
+
|
|
493
|
+
```typescript
|
|
494
|
+
import { GreenSecurity } from "@greensecurity/javascript-sdk";
|
|
495
|
+
import { HTTPClient } from "@greensecurity/javascript-sdk/lib/http";
|
|
496
|
+
|
|
497
|
+
const httpClient = new HTTPClient({
|
|
498
|
+
// fetcher takes a function that has the same signature as native `fetch`.
|
|
499
|
+
fetcher: (request) => {
|
|
500
|
+
return fetch(request);
|
|
501
|
+
}
|
|
502
|
+
});
|
|
503
|
+
|
|
504
|
+
httpClient.addHook("beforeRequest", (request) => {
|
|
505
|
+
const nextRequest = new Request(request, {
|
|
506
|
+
signal: request.signal || AbortSignal.timeout(5000)
|
|
507
|
+
});
|
|
508
|
+
|
|
509
|
+
nextRequest.headers.set("x-custom-header", "custom value");
|
|
510
|
+
|
|
511
|
+
return nextRequest;
|
|
512
|
+
});
|
|
513
|
+
|
|
514
|
+
httpClient.addHook("requestError", (error, request) => {
|
|
515
|
+
console.group("Request Error");
|
|
516
|
+
console.log("Reason:", `${error}`);
|
|
517
|
+
console.log("Endpoint:", `${request.method} ${request.url}`);
|
|
518
|
+
console.groupEnd();
|
|
519
|
+
});
|
|
520
|
+
|
|
521
|
+
const sdk = new GreenSecurity({ httpClient });
|
|
522
|
+
```
|
|
523
|
+
<!-- End Custom HTTP Client [http-client] -->
|
|
524
|
+
|
|
525
|
+
<!-- Start Debugging [debug] -->
|
|
526
|
+
## Debugging
|
|
527
|
+
|
|
528
|
+
You can setup your SDK to emit debug logs for SDK requests and responses.
|
|
529
|
+
|
|
530
|
+
You can pass a logger that matches `console`'s interface as an SDK option.
|
|
531
|
+
|
|
532
|
+
> [!WARNING]
|
|
533
|
+
> Beware that debug logging will reveal secrets, like API tokens in headers, in log messages printed to a console or files. It's recommended to use this feature only during local development and not in production.
|
|
534
|
+
|
|
535
|
+
```typescript
|
|
536
|
+
import { GreenSecurity } from "@greensecurity/javascript-sdk";
|
|
537
|
+
|
|
538
|
+
const sdk = new GreenSecurity({ debugLogger: console });
|
|
539
|
+
```
|
|
540
|
+
|
|
541
|
+
You can also enable a default debug logger by setting an environment variable `GREEN_SECURITY_DEBUG` to true.
|
|
542
|
+
<!-- End Debugging [debug] -->
|
|
543
|
+
|
|
544
|
+
<!-- Placeholder for Future Speakeasy SDK Sections -->
|
|
545
|
+
|
|
546
|
+
# Development
|
|
547
|
+
|
|
548
|
+
## Maturity
|
|
549
|
+
|
|
550
|
+
This SDK is in beta, and there may be breaking changes between versions without a major version update. Therefore, we
|
|
551
|
+
recommend pinning usage
|
|
552
|
+
to a specific package version. This way, you can install the same version each time without breaking changes unless you
|
|
553
|
+
are intentionally
|
|
554
|
+
looking for the latest version.
|
|
555
|
+
|
|
556
|
+
## Contributions
|
|
557
|
+
|
|
558
|
+
While we value open-source contributions to this SDK, this library is generated programmatically. Any manual changes
|
|
559
|
+
added to internal files will be overwritten on the next generation.
|
|
560
|
+
We look forward to hearing your feedback. Feel free to open a PR or an issue with a proof of concept and we'll do our
|
|
561
|
+
best to include it in a future release.
|
package/RUNTIMES.md
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# Supported JavaScript runtimes
|
|
2
|
+
|
|
3
|
+
This SDK is intended to be used in JavaScript runtimes that support ECMAScript 2020 or newer. The SDK uses the following features:
|
|
4
|
+
|
|
5
|
+
* [Web Fetch API][web-fetch]
|
|
6
|
+
* [Web Streams API][web-streams] and in particular `ReadableStream`
|
|
7
|
+
* [Async iterables][async-iter] using `Symbol.asyncIterator`
|
|
8
|
+
|
|
9
|
+
[web-fetch]: https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API
|
|
10
|
+
[web-streams]: https://developer.mozilla.org/en-US/docs/Web/API/Streams_API
|
|
11
|
+
[async-iter]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#the_async_iterator_and_async_iterable_protocols
|
|
12
|
+
|
|
13
|
+
Runtime environments that are explicitly supported are:
|
|
14
|
+
|
|
15
|
+
- Evergreen browsers which include: Chrome, Safari, Edge, Firefox
|
|
16
|
+
- Node.js active and maintenance LTS releases
|
|
17
|
+
- Currently, this is v18 and v20
|
|
18
|
+
- Bun v1 and above
|
|
19
|
+
- Deno v1.39
|
|
20
|
+
- Note that Deno does not currently have native support for streaming file uploads backed by the filesystem ([issue link][deno-file-streaming])
|
|
21
|
+
|
|
22
|
+
[deno-file-streaming]: https://github.com/denoland/deno/issues/11018
|
|
23
|
+
|
|
24
|
+
## Recommended TypeScript compiler options
|
|
25
|
+
|
|
26
|
+
The following `tsconfig.json` options are recommended for projects using this
|
|
27
|
+
SDK in order to get static type support for features like async iterables,
|
|
28
|
+
streams and `fetch`-related APIs ([`for await...of`][for-await-of],
|
|
29
|
+
[`AbortSignal`][abort-signal], [`Request`][request], [`Response`][response] and
|
|
30
|
+
so on):
|
|
31
|
+
|
|
32
|
+
[for-await-of]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for-await...of
|
|
33
|
+
[abort-signal]: https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal
|
|
34
|
+
[request]: https://developer.mozilla.org/en-US/docs/Web/API/Request
|
|
35
|
+
[response]: https://developer.mozilla.org/en-US/docs/Web/API/Response
|
|
36
|
+
|
|
37
|
+
```jsonc
|
|
38
|
+
{
|
|
39
|
+
"compilerOptions": {
|
|
40
|
+
"target": "es2020", // or higher
|
|
41
|
+
"lib": ["es2020", "dom", "dom.iterable"],
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
While `target` can be set to older ECMAScript versions, it may result in extra,
|
|
47
|
+
unnecessary compatibility code being generated if you are not targeting old
|
|
48
|
+
runtimes.
|
package/core.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ClientSDK } from "./lib/sdks.js";
|
|
2
|
+
/**
|
|
3
|
+
* A minimal client to use when calling standalone SDK functions. Typically, an
|
|
4
|
+
* instance of this class would be instantiated once at the start of an
|
|
5
|
+
* application and passed around through some dependency injection mechanism to
|
|
6
|
+
* parts of an application that need to make SDK calls.
|
|
7
|
+
*/
|
|
8
|
+
export declare class GreenSecurityCore extends ClientSDK {
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=core.d.ts.map
|
package/core.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["src/core.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAE1C;;;;;GAKG;AACH,qBAAa,iBAAkB,SAAQ,SAAS;CAAG"}
|
package/core.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.GreenSecurityCore = void 0;
|
|
7
|
+
const sdks_js_1 = require("./lib/sdks.js");
|
|
8
|
+
/**
|
|
9
|
+
* A minimal client to use when calling standalone SDK functions. Typically, an
|
|
10
|
+
* instance of this class would be instantiated once at the start of an
|
|
11
|
+
* application and passed around through some dependency injection mechanism to
|
|
12
|
+
* parts of an application that need to make SDK calls.
|
|
13
|
+
*/
|
|
14
|
+
class GreenSecurityCore extends sdks_js_1.ClientSDK {
|
|
15
|
+
}
|
|
16
|
+
exports.GreenSecurityCore = GreenSecurityCore;
|
|
17
|
+
//# sourceMappingURL=core.js.map
|
package/core.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core.js","sourceRoot":"","sources":["src/core.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,2CAA0C;AAE1C;;;;;GAKG;AACH,MAAa,iBAAkB,SAAQ,mBAAS;CAAG;AAAnD,8CAAmD"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# GreenSecurity SDK
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
API Reference: The Green Security API is organized around [REST](http://en.wikipedia.org/wiki/Representational_State_Transfer).
|
|
6
|
+
Our API has predictable resource-oriented URLs, accepts [JSON-encoded](http://www.json.org/) request bodies,
|
|
7
|
+
returns JSON-encoded responses, and uses standard HTTP response codes, authentication, and verbs.
|
|
8
|
+
|
|
9
|
+
The API is updated frequently, so be sure to check back often for the latest information.
|
|
10
|
+
|
|
11
|
+
Some useful links:
|
|
12
|
+
- [OpenAPI Reference](https://www.speakeasy.com/openapi)
|
|
13
|
+
|
|
14
|
+
### Available Operations
|