@palmetto/users-sdk 0.0.8 → 0.0.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.
package/README.md CHANGED
@@ -1 +1,5 @@
1
1
  # Palmetto Users API SDK
2
+
3
+ ## Publishing Users SDK
4
+
5
+ Note: There is a Github Action that automatically publishes to NPM when a PR is merged into main with code that touches the Users SDK directory specifically. For the Github Action to succeed, be sure to manually bump the version at the top of the Users SDK package.json when pushing your changes. If you did not touch the Users SDK, you do not need to bump the version number. Changes to anything outside of the Users SDK directory will not trigger the Github Action.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@palmetto/users-sdk",
3
- "version": "0.0.8",
3
+ "version": "0.0.10",
4
4
  "main": "./dist/main.js",
5
5
  "files": [
6
6
  "dist/**/*",
@@ -26,7 +26,7 @@
26
26
  "@typescript-eslint/eslint-plugin": "7.15.0",
27
27
  "@typescript-eslint/parser": "7.15.0",
28
28
  "eslint": "8.56.0",
29
- "openapi-typescript": "^7.4.0",
29
+ "openapi-typescript": "7.4.0",
30
30
  "prettier": "2.8.3",
31
31
  "typescript": "5.5.4"
32
32
  },
@@ -36,4 +36,4 @@
36
36
  "publishConfig": {
37
37
  "access": "public"
38
38
  }
39
- }
39
+ }
package/dist/client2.d.ts DELETED
@@ -1,38 +0,0 @@
1
- export interface CreateClientOptions {
2
- apiUrl: string;
3
- authToken?: string;
4
- }
5
- export interface ApiOptions {
6
- authToken?: string;
7
- headers?: Record<string, string>;
8
- }
9
- export declare class UsersApiClient {
10
- private client;
11
- private headers;
12
- constructor(opts: CreateClientOptions);
13
- setAuthToken(authToken: string): void;
14
- me(opts?: ApiOptions): Promise<import("./result").ResultOk<{
15
- auth0Id: string;
16
- email: string;
17
- grants: {
18
- entity: string;
19
- operation: string;
20
- deny?: boolean;
21
- }[];
22
- id: string;
23
- firstName: string;
24
- lastName: string;
25
- phoneNumber: string;
26
- organizationId: unknown;
27
- meta: {
28
- createdAt: string;
29
- updatedAt?: string;
30
- };
31
- }> | import("./result").ResultErr<{
32
- code: "NOT_AUTHENTICATED";
33
- }> | import("./result").ResultErr<{
34
- code: "UNKNOWN_ERROR";
35
- }>>;
36
- protected generateHeaders(opts?: ApiOptions): Headers;
37
- protected mergeHeaders(overrides: Record<string, string>): Headers;
38
- }
package/dist/client2.js DELETED
@@ -1,54 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.UsersApiClient = void 0;
7
- const openapi_fetch_1 = __importDefault(require("openapi-fetch"));
8
- const result_1 = require("./result");
9
- class UsersApiClient {
10
- client;
11
- headers;
12
- constructor(opts) {
13
- this.client = (0, openapi_fetch_1.default)({ baseUrl: opts.apiUrl });
14
- this.headers = new Headers();
15
- if (opts.authToken) {
16
- this.setAuthToken(opts.authToken);
17
- }
18
- }
19
- setAuthToken(authToken) {
20
- this.headers.set("Authorization", `Bearer ${authToken}`);
21
- }
22
- async me(opts) {
23
- const { data, response } = await this.client.GET("/api/users/me", {
24
- headers: this.generateHeaders(opts),
25
- });
26
- if (data) {
27
- return (0, result_1.Ok)(data);
28
- }
29
- switch (response.status) {
30
- case 401:
31
- case 404:
32
- return (0, result_1.Err)("NOT_AUTHENTICATED");
33
- default:
34
- return (0, result_1.Err)("UNKNOWN_ERROR");
35
- }
36
- }
37
- generateHeaders(opts) {
38
- const headers = opts?.headers
39
- ? this.mergeHeaders(opts.headers)
40
- : new Headers(this.headers);
41
- if (opts?.authToken) {
42
- headers.set("Authorization", `Bearer ${opts.authToken}`);
43
- }
44
- return headers;
45
- }
46
- mergeHeaders(overrides) {
47
- const merged = new Headers(this.headers);
48
- for (const key in overrides) {
49
- merged.set(key, overrides[key]);
50
- }
51
- return merged;
52
- }
53
- }
54
- exports.UsersApiClient = UsersApiClient;