@palmetto/users-sdk 1.2.1 → 1.3.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.
@@ -952,6 +952,7 @@ export interface components {
952
952
  lastName?: string;
953
953
  /** Format: email */
954
954
  email?: string;
955
+ roleIds?: string[];
955
956
  };
956
957
  /** SignUpToken */
957
958
  SignUpTokenDto: {
package/dist/client.d.ts CHANGED
@@ -480,6 +480,54 @@ export declare class UsersApiClient extends BaseSdkClient<paths> {
480
480
  };
481
481
  }, `${string}/${string}`>>>;
482
482
  private getToken;
483
+ getRoles(input: GetRolesInput, opts?: RequestOptions): Promise<ResultOk<{
484
+ data: import("./__generated__/schema").components["schemas"]["RoleDto"][];
485
+ } & {
486
+ data: unknown[];
487
+ paging: {
488
+ limit: number;
489
+ page: number;
490
+ pageStart: number;
491
+ pageEnd: number;
492
+ totalRecords: number;
493
+ totalPages: number;
494
+ };
495
+ }> | SdkError<ErrorResponse<{
496
+ 200: {
497
+ headers: {
498
+ [name: string]: unknown;
499
+ };
500
+ content: {
501
+ "application/json": {
502
+ data: import("./__generated__/schema").components["schemas"]["RoleDto"][];
503
+ } & import("./__generated__/schema").components["schemas"]["PaginatedListDto"];
504
+ };
505
+ };
506
+ 400: {
507
+ headers: {
508
+ [name: string]: unknown;
509
+ };
510
+ content: {
511
+ "application/json": import("./__generated__/schema").components["schemas"]["BadRequestErrorDto"];
512
+ };
513
+ };
514
+ 401: {
515
+ headers: {
516
+ [name: string]: unknown;
517
+ };
518
+ content: {
519
+ "application/json": import("./__generated__/schema").components["schemas"]["UnauthorizedErrorDto"];
520
+ };
521
+ };
522
+ 403: {
523
+ headers: {
524
+ [name: string]: unknown;
525
+ };
526
+ content: {
527
+ "application/json": import("./__generated__/schema").components["schemas"]["ForbiddenErrorDto"];
528
+ };
529
+ };
530
+ }, `${string}/${string}`>>>;
483
531
  }
484
532
  export interface MeInput {
485
533
  v2Response: true;
@@ -510,6 +558,8 @@ export type GetSignUpInput = ApiInput<paths["/api/sign-ups/{token}"]["get"]>;
510
558
  export type GetSignUpResponse = ApiResponse<paths["/api/sign-ups/{token}"]["get"]>;
511
559
  export type CreateSignUpUserInput = ApiInput<paths["/api/sign-ups/{token}/user"]["post"]>;
512
560
  export type CreateSignUpUserResponse = ApiResponse<paths["/api/sign-ups/{token}/user"]["post"]>;
561
+ export type GetRolesInput = ApiInput<paths["/api/roles"]["get"]>;
562
+ export type GetRolesResponse = ApiResponse<paths["/api/roles"]["get"]>;
513
563
  export interface GetAuthTokenInput {
514
564
  code: string;
515
565
  skipUserVerification: boolean;
package/dist/client.js CHANGED
@@ -210,5 +210,17 @@ class UsersApiClient extends base_sdk_client_1.BaseSdkClient {
210
210
  return this.handleErrorResponse(error, response);
211
211
  });
212
212
  }
213
+ getRoles(input, opts) {
214
+ return __awaiter(this, void 0, void 0, function* () {
215
+ const { data, error, response } = yield this.client.GET("/api/roles", {
216
+ params: { query: input },
217
+ headers: this.generateHeaders(opts),
218
+ });
219
+ if (data) {
220
+ return (0, result_1.Ok)(data);
221
+ }
222
+ return this.handleErrorResponse(error, response);
223
+ });
224
+ }
213
225
  }
214
226
  exports.UsersApiClient = UsersApiClient;
package/dist/main.d.ts CHANGED
@@ -1,4 +1,3 @@
1
1
  export * from "./client.js";
2
- export * from "./scopes.js";
3
2
  export { type RequestOptions, type SdkError } from "@palmetto/base-sdk-client";
4
3
  export { type ErrorResponse } from "openapi-typescript-helpers";
package/dist/main.js CHANGED
@@ -15,4 +15,3 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./client.js"), exports);
18
- __exportStar(require("./scopes.js"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@palmetto/users-sdk",
3
- "version": "1.2.1",
3
+ "version": "1.3.0",
4
4
  "main": "./dist/main.js",
5
5
  "files": [
6
6
  "dist/**/*",
@@ -15,8 +15,11 @@
15
15
  "tc": "tsc --noEmit",
16
16
  "start:dev": "tsc --watch",
17
17
  "build": "tsc",
18
+ "clean": "rm -rf ./dist/",
18
19
  "generate": "node ./scripts/generateApiSchema.mjs",
20
+ "refresh": "yarn generate && yarn build",
19
21
  "prepublishOnly": "yarn build",
22
+ "ci:build": "tsc",
20
23
  "ci:lint": "eslint . && prettier --check --loglevel warn ./src",
21
24
  "ci:tc": "yarn tc",
22
25
  "hook:lint": "eslint --cache --fix",
package/dist/scopes.d.ts DELETED
@@ -1,11 +0,0 @@
1
- export type GrantScope = "@deny" | "@self" | "@org" | "@admin";
2
- export declare function isGrantScope(value: unknown): value is GrantScope;
3
- export declare function valueOfScope(scope: GrantScope): number;
4
- export declare function compareScopes(a: GrantScope, b: GrantScope): -1 | 0 | 1;
5
- export declare function highestScope(scopes: GrantScope[]): GrantScope;
6
- export interface LowestScopeOptions {
7
- includeDeny: boolean;
8
- }
9
- export declare function lowestScope(scopes: GrantScope[], options?: LowestScopeOptions): GrantScope;
10
- export type ScopeOperator = "eq" | "neq" | "lt" | "lte" | "gt" | "gte";
11
- export declare function scopeMatch(left: GrantScope, op: ScopeOperator, right: GrantScope): boolean;
package/dist/scopes.js DELETED
@@ -1,50 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isGrantScope = isGrantScope;
4
- exports.valueOfScope = valueOfScope;
5
- exports.compareScopes = compareScopes;
6
- exports.highestScope = highestScope;
7
- exports.lowestScope = lowestScope;
8
- exports.scopeMatch = scopeMatch;
9
- const scopeOrder = ["@deny", "@self", "@org", "@admin"];
10
- function isGrantScope(value) {
11
- return typeof value === "string" && scopeOrder.includes(value);
12
- }
13
- function valueOfScope(scope) {
14
- return scopeOrder.indexOf(scope);
15
- }
16
- function compareScopes(a, b) {
17
- if (a === b) {
18
- return 0;
19
- }
20
- return valueOfScope(a) < valueOfScope(b) ? -1 : 1;
21
- }
22
- function highestScope(scopes) {
23
- var _a;
24
- return (_a = [...scopes].sort(compareScopes)[scopes.length - 1]) !== null && _a !== void 0 ? _a : "@deny";
25
- }
26
- function lowestScope(scopes, options) {
27
- var _a;
28
- const filtered = (options === null || options === void 0 ? void 0 : options.includeDeny)
29
- ? [...scopes]
30
- : [...scopes].filter((elem) => elem !== "@deny");
31
- return (_a = filtered.sort(compareScopes)[0]) !== null && _a !== void 0 ? _a : "@deny";
32
- }
33
- function scopeMatch(left, op, right) {
34
- const leftValue = valueOfScope(left);
35
- const rightValue = valueOfScope(right);
36
- switch (op) {
37
- case "eq":
38
- return leftValue === rightValue;
39
- case "neq":
40
- return leftValue !== rightValue;
41
- case "lt":
42
- return leftValue < rightValue;
43
- case "lte":
44
- return leftValue <= rightValue;
45
- case "gt":
46
- return leftValue > rightValue;
47
- case "gte":
48
- return leftValue >= rightValue;
49
- }
50
- }