@gr4vy/sdk 2.4.8 → 2.4.10

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 (56) hide show
  1. package/README.md +5 -0
  2. package/funcs/rolesList.d.ts +21 -0
  3. package/funcs/rolesList.d.ts.map +1 -0
  4. package/funcs/rolesList.js +158 -0
  5. package/funcs/rolesList.js.map +1 -0
  6. package/jsr.json +1 -1
  7. package/lib/config.d.ts +2 -2
  8. package/lib/config.js +2 -2
  9. package/lib/config.js.map +1 -1
  10. package/models/components/collectionrole.d.ts +26 -0
  11. package/models/components/collectionrole.d.ts.map +1 -0
  12. package/models/components/collectionrole.js +60 -0
  13. package/models/components/collectionrole.js.map +1 -0
  14. package/models/components/index.d.ts +2 -0
  15. package/models/components/index.d.ts.map +1 -1
  16. package/models/components/index.js +2 -0
  17. package/models/components/index.js.map +1 -1
  18. package/models/components/permissionset.d.ts +6 -0
  19. package/models/components/permissionset.d.ts.map +1 -1
  20. package/models/components/permissionset.js.map +1 -1
  21. package/models/components/role.d.ts +32 -0
  22. package/models/components/role.d.ts.map +1 -1
  23. package/models/components/role.js +12 -0
  24. package/models/components/role.js.map +1 -1
  25. package/models/components/roleassigneetype.d.ts +10 -0
  26. package/models/components/roleassigneetype.d.ts.map +1 -0
  27. package/models/components/roleassigneetype.js +47 -0
  28. package/models/components/roleassigneetype.js.map +1 -0
  29. package/models/operations/index.d.ts +1 -0
  30. package/models/operations/index.d.ts.map +1 -1
  31. package/models/operations/index.js +1 -0
  32. package/models/operations/index.js.map +1 -1
  33. package/models/operations/listroles.d.ts +29 -0
  34. package/models/operations/listroles.d.ts.map +1 -0
  35. package/models/operations/listroles.js +65 -0
  36. package/models/operations/listroles.js.map +1 -0
  37. package/package.json +1 -1
  38. package/sdk/roles.d.ts +15 -0
  39. package/sdk/roles.d.ts.map +1 -0
  40. package/sdk/roles.js +22 -0
  41. package/sdk/roles.js.map +1 -0
  42. package/sdk/sdk.d.ts +3 -0
  43. package/sdk/sdk.d.ts.map +1 -1
  44. package/sdk/sdk.js +4 -0
  45. package/sdk/sdk.js.map +1 -1
  46. package/src/funcs/rolesList.ts +310 -0
  47. package/src/lib/config.ts +2 -2
  48. package/src/models/components/collectionrole.ts +56 -0
  49. package/src/models/components/index.ts +2 -0
  50. package/src/models/components/permissionset.ts +6 -0
  51. package/src/models/components/role.ts +46 -0
  52. package/src/models/components/roleassigneetype.ts +20 -0
  53. package/src/models/operations/index.ts +1 -0
  54. package/src/models/operations/listroles.ts +72 -0
  55. package/src/sdk/roles.ts +29 -0
  56. package/src/sdk/sdk.ts +6 -0
@@ -0,0 +1,56 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import * as z from "zod/v3";
6
+ import { remap as remap$ } from "../../lib/primitives.js";
7
+ import { safeParse } from "../../lib/schemas.js";
8
+ import { Result as SafeParseResult } from "../../types/fp.js";
9
+ import { SDKValidationError } from "../errors/sdkvalidationerror.js";
10
+ import { Role, Role$inboundSchema } from "./role.js";
11
+
12
+ export type CollectionRole = {
13
+ /**
14
+ * A list of items returned for this request.
15
+ */
16
+ items: Array<Role>;
17
+ /**
18
+ * The number of items for this page.
19
+ */
20
+ limit: number;
21
+ /**
22
+ * The cursor pointing at the next page of items.
23
+ */
24
+ nextCursor?: string | null | undefined;
25
+ /**
26
+ * The cursor pointing at the previous page of items.
27
+ */
28
+ previousCursor?: string | null | undefined;
29
+ };
30
+
31
+ /** @internal */
32
+ export const CollectionRole$inboundSchema: z.ZodType<
33
+ CollectionRole,
34
+ z.ZodTypeDef,
35
+ unknown
36
+ > = z.object({
37
+ items: z.array(Role$inboundSchema),
38
+ limit: z.number().int().default(20),
39
+ next_cursor: z.nullable(z.string()).optional(),
40
+ previous_cursor: z.nullable(z.string()).optional(),
41
+ }).transform((v) => {
42
+ return remap$(v, {
43
+ "next_cursor": "nextCursor",
44
+ "previous_cursor": "previousCursor",
45
+ });
46
+ });
47
+
48
+ export function collectionRoleFromJSON(
49
+ jsonString: string,
50
+ ): SafeParseResult<CollectionRole, SDKValidationError> {
51
+ return safeParse(
52
+ jsonString,
53
+ (x) => CollectionRole$inboundSchema.parse(JSON.parse(x)),
54
+ `Failed to parse 'CollectionRole' from JSON`,
55
+ );
56
+ }
@@ -75,6 +75,7 @@ export * from "./clicktopaypaymentmethodcreate.js";
75
75
  export * from "./clicktopaysession.js";
76
76
  export * from "./clicktopaysessionrequest.js";
77
77
  export * from "./collectionapikeypair.js";
78
+ export * from "./collectionrole.js";
78
79
  export * from "./createsession.js";
79
80
  export * from "./createsessionstatus.js";
80
81
  export * from "./cryptogram.js";
@@ -282,6 +283,7 @@ export * from "./requiredcheckoutfields.js";
282
283
  export * from "./riskifiedantifraudoptions.js";
283
284
  export * from "./riskifiedantifraudoptionslineitem.js";
284
285
  export * from "./role.js";
286
+ export * from "./roleassigneetype.js";
285
287
  export * from "./security.js";
286
288
  export * from "./sepabankpaymentmethodcreate.js";
287
289
  export * from "./settlement.js";
@@ -7,7 +7,13 @@ import { safeParse } from "../../lib/schemas.js";
7
7
  import { Result as SafeParseResult } from "../../types/fp.js";
8
8
  import { SDKValidationError } from "../errors/sdkvalidationerror.js";
9
9
 
10
+ /**
11
+ * The permissions granted by a role.
12
+ */
10
13
  export type PermissionSet = {
14
+ /**
15
+ * The scopes granted by this role.
16
+ */
11
17
  allow: Array<string>;
12
18
  };
13
19
 
@@ -3,17 +3,53 @@
3
3
  */
4
4
 
5
5
  import * as z from "zod/v3";
6
+ import { remap as remap$ } from "../../lib/primitives.js";
6
7
  import { safeParse } from "../../lib/schemas.js";
7
8
  import { Result as SafeParseResult } from "../../types/fp.js";
8
9
  import { SDKValidationError } from "../errors/sdkvalidationerror.js";
9
10
  import { PermissionSet, PermissionSet$inboundSchema } from "./permissionset.js";
11
+ import {
12
+ RoleAssigneeType,
13
+ RoleAssigneeType$inboundSchema,
14
+ } from "./roleassigneetype.js";
10
15
 
11
16
  export type Role = {
17
+ /**
18
+ * Always `role`.
19
+ */
12
20
  type: "role";
21
+ /**
22
+ * The unique ID for the role.
23
+ */
13
24
  id: string;
25
+ /**
26
+ * The human-readable name of the role.
27
+ */
14
28
  name: string;
29
+ /**
30
+ * The unique, human-readable identifier for the role.
31
+ */
32
+ slug: string;
33
+ /**
34
+ * A description of the access this role grants.
35
+ */
15
36
  description: string;
37
+ /**
38
+ * The permissions granted by a role.
39
+ */
16
40
  permissions: PermissionSet;
41
+ /**
42
+ * The types of resource this role can be assigned to.
43
+ */
44
+ assignableTo: Array<RoleAssigneeType>;
45
+ /**
46
+ * The slugs of the roles this role is an add-on of. Empty when this role is not an add-on.
47
+ */
48
+ appliesTo: Array<string>;
49
+ /**
50
+ * Whether this role can be assigned on its own, without being combined with another role.
51
+ */
52
+ isStandaloneAssignable: boolean;
17
53
  };
18
54
 
19
55
  /** @internal */
@@ -22,8 +58,18 @@ export const Role$inboundSchema: z.ZodType<Role, z.ZodTypeDef, unknown> = z
22
58
  type: z.literal("role").default("role"),
23
59
  id: z.string(),
24
60
  name: z.string(),
61
+ slug: z.string(),
25
62
  description: z.string(),
26
63
  permissions: PermissionSet$inboundSchema,
64
+ assignable_to: z.array(RoleAssigneeType$inboundSchema),
65
+ applies_to: z.array(z.string()),
66
+ is_standalone_assignable: z.boolean(),
67
+ }).transform((v) => {
68
+ return remap$(v, {
69
+ "assignable_to": "assignableTo",
70
+ "applies_to": "appliesTo",
71
+ "is_standalone_assignable": "isStandaloneAssignable",
72
+ });
27
73
  });
28
74
 
29
75
  export function roleFromJSON(
@@ -0,0 +1,20 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import * as z from "zod/v3";
6
+ import * as openEnums from "../../types/enums.js";
7
+ import { OpenEnum } from "../../types/enums.js";
8
+
9
+ export const RoleAssigneeType = {
10
+ User: "user",
11
+ ApiKeyPair: "api-key-pair",
12
+ } as const;
13
+ export type RoleAssigneeType = OpenEnum<typeof RoleAssigneeType>;
14
+
15
+ /** @internal */
16
+ export const RoleAssigneeType$inboundSchema: z.ZodType<
17
+ RoleAssigneeType,
18
+ z.ZodTypeDef,
19
+ unknown
20
+ > = openEnums.inboundSchema(RoleAssigneeType);
@@ -91,6 +91,7 @@ export * from "./listpaymentservices.js";
91
91
  export * from "./listpayouts.js";
92
92
  export * from "./listreportexecutions.js";
93
93
  export * from "./listreports.js";
94
+ export * from "./listroles.js";
94
95
  export * from "./listthreedsconfigurations.js";
95
96
  export * from "./listtransactionactions.js";
96
97
  export * from "./listtransactioncaptures.js";
@@ -0,0 +1,72 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import * as z from "zod/v3";
6
+ import { remap as remap$ } from "../../lib/primitives.js";
7
+ import { safeParse } from "../../lib/schemas.js";
8
+ import { Result as SafeParseResult } from "../../types/fp.js";
9
+ import * as components from "../components/index.js";
10
+ import { SDKValidationError } from "../errors/sdkvalidationerror.js";
11
+
12
+ export type ListRolesRequest = {
13
+ /**
14
+ * A pointer to the page of results to return.
15
+ */
16
+ cursor?: string | null | undefined;
17
+ /**
18
+ * The maximum number of items that are returned.
19
+ */
20
+ limit?: number | undefined;
21
+ };
22
+
23
+ export type ListRolesResponse = {
24
+ result: components.CollectionRole;
25
+ };
26
+
27
+ /** @internal */
28
+ export type ListRolesRequest$Outbound = {
29
+ cursor?: string | null | undefined;
30
+ limit: number;
31
+ };
32
+
33
+ /** @internal */
34
+ export const ListRolesRequest$outboundSchema: z.ZodType<
35
+ ListRolesRequest$Outbound,
36
+ z.ZodTypeDef,
37
+ ListRolesRequest
38
+ > = z.object({
39
+ cursor: z.nullable(z.string()).optional(),
40
+ limit: z.number().int().default(20),
41
+ });
42
+
43
+ export function listRolesRequestToJSON(
44
+ listRolesRequest: ListRolesRequest,
45
+ ): string {
46
+ return JSON.stringify(
47
+ ListRolesRequest$outboundSchema.parse(listRolesRequest),
48
+ );
49
+ }
50
+
51
+ /** @internal */
52
+ export const ListRolesResponse$inboundSchema: z.ZodType<
53
+ ListRolesResponse,
54
+ z.ZodTypeDef,
55
+ unknown
56
+ > = z.object({
57
+ Result: components.CollectionRole$inboundSchema,
58
+ }).transform((v) => {
59
+ return remap$(v, {
60
+ "Result": "result",
61
+ });
62
+ });
63
+
64
+ export function listRolesResponseFromJSON(
65
+ jsonString: string,
66
+ ): SafeParseResult<ListRolesResponse, SDKValidationError> {
67
+ return safeParse(
68
+ jsonString,
69
+ (x) => ListRolesResponse$inboundSchema.parse(JSON.parse(x)),
70
+ `Failed to parse 'ListRolesResponse' from JSON`,
71
+ );
72
+ }
@@ -0,0 +1,29 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import { rolesList } from "../funcs/rolesList.js";
6
+ import { ClientSDK, RequestOptions } from "../lib/sdks.js";
7
+ import * as operations from "../models/operations/index.js";
8
+ import { PageIterator, unwrapResultIterator } from "../types/operations.js";
9
+
10
+ export class Roles extends ClientSDK {
11
+ /**
12
+ * List all roles
13
+ *
14
+ * @remarks
15
+ * List all roles available in the instance.
16
+ */
17
+ async list(
18
+ cursor?: string | null | undefined,
19
+ limit?: number | undefined,
20
+ options?: RequestOptions,
21
+ ): Promise<PageIterator<operations.ListRolesResponse, { cursor: string }>> {
22
+ return unwrapResultIterator(rolesList(
23
+ this,
24
+ cursor,
25
+ limit,
26
+ options,
27
+ ));
28
+ }
29
+ }
package/src/sdk/sdk.ts CHANGED
@@ -21,6 +21,7 @@ import { Payouts } from "./payouts.js";
21
21
  import { Refunds } from "./refunds.js";
22
22
  import { ReportExecutions } from "./reportexecutions.js";
23
23
  import { Reports } from "./reports.js";
24
+ import { Roles } from "./roles.js";
24
25
  import { ThreeDsScenarios } from "./threedsscenarios.js";
25
26
  import { Transactions } from "./transactions.js";
26
27
 
@@ -109,6 +110,11 @@ export class Gr4vy extends ClientSDK {
109
110
  return (this._checkoutSessions ??= new CheckoutSessions(this._options));
110
111
  }
111
112
 
113
+ private _roles?: Roles;
114
+ get roles(): Roles {
115
+ return (this._roles ??= new Roles(this._options));
116
+ }
117
+
112
118
  private _merchantAccounts?: MerchantAccounts;
113
119
  get merchantAccounts(): MerchantAccounts {
114
120
  return (this._merchantAccounts ??= new MerchantAccounts(this._options));