@useparagon/connect 1.0.0 → 1.0.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.
Files changed (42) hide show
  1. package/LICENSE +21 -674
  2. package/README.md +33 -8
  3. package/dist/src/ConnectSDK.d.ts +189 -0
  4. package/dist/src/SDKEventEmitter.d.ts +56 -0
  5. package/dist/src/constants.d.ts +1 -0
  6. package/dist/src/entities/base.entity.d.ts +5 -0
  7. package/dist/src/entities/connectCredential.interface.d.ts +42 -0
  8. package/dist/src/entities/credential.interface.d.ts +15 -0
  9. package/dist/src/entities/customIntegration.interface.d.ts +60 -0
  10. package/dist/src/entities/integration.interface.d.ts +33 -0
  11. package/dist/src/entities/integrationConfig.interface.d.ts +9 -0
  12. package/{src/entities/license.interface.ts → dist/src/entities/license.interface.d.ts} +2 -4
  13. package/dist/src/entities/persona.interface.d.ts +34 -0
  14. package/dist/src/entities/project.interface.d.ts +32 -0
  15. package/dist/src/entities/steps.d.ts +30 -0
  16. package/dist/src/entities/team.interface.d.ts +19 -0
  17. package/dist/src/entities/user.interface.d.ts +23 -0
  18. package/dist/src/entities/workflow.interface.d.ts +11 -0
  19. package/dist/src/helpers/ConnectUserContext.d.ts +18 -0
  20. package/dist/src/helpers/index.d.ts +15 -0
  21. package/dist/src/helpers/oauth.d.ts +30 -0
  22. package/dist/src/index.d.ts +8 -0
  23. package/dist/src/index.js +4376 -0
  24. package/dist/src/server.types.d.ts +13 -0
  25. package/dist/src/types/action.d.ts +252 -0
  26. package/dist/src/types/billing.d.ts +2 -0
  27. package/dist/src/types/connect.d.ts +200 -0
  28. package/dist/src/types/connectModal.d.ts +28 -0
  29. package/dist/src/types/environment.d.ts +16 -0
  30. package/dist/src/types/execution.d.ts +5 -0
  31. package/dist/src/types/index.d.ts +10 -0
  32. package/dist/src/types/oauth.d.ts +3 -0
  33. package/dist/src/types/resolvers.d.ts +297 -0
  34. package/dist/src/types/sdk.d.ts +223 -0
  35. package/dist/src/types/stripe.d.ts +23 -0
  36. package/dist/src/utils/connect.d.ts +13 -0
  37. package/dist/src/utils/crypto.d.ts +7 -0
  38. package/dist/src/utils/generic.d.ts +30 -0
  39. package/dist/src/utils/http.d.ts +13 -0
  40. package/dist/src/utils/throttle.d.ts +118 -0
  41. package/package.json +16 -42
  42. package/src/ConnectSDK.tsx +0 -1065
@@ -0,0 +1,118 @@
1
+ /**
2
+ * whether to debounce or throttle cached items
3
+ * defaults to `Debounce` behavior
4
+ */
5
+ export declare enum CacheMode {
6
+ Debounce = "debounce",
7
+ Throttle = "throttle"
8
+ }
9
+ /**
10
+ * configuration parameters for a CacheThrottle instance
11
+ */
12
+ export type CacheThrottleConfig<T = any> = Partial<{
13
+ /**
14
+ * when enabled, this clears pending `del` calls from the queue when `get`, `set`, or `getOrSet` is called
15
+ * this can be used to prevent queued delete calls from deleting recently retrieved stateful values, like db connections
16
+ */
17
+ clearPendingDeletes: boolean;
18
+ /**
19
+ * whether to operate in Throttle or Debounce mode
20
+ */
21
+ mode: CacheMode;
22
+ /**
23
+ * an optional callback for handling items when they get deregistered from the cache
24
+ */
25
+ onDeregister: (value: T) => Promise<void> | void;
26
+ /**
27
+ * an optional callback for serializing keys
28
+ * in the case that keys are particularly long, this can be used to shorten them
29
+ */
30
+ serializeKey: (key: string) => string;
31
+ /**
32
+ * how long items should remain in the cache
33
+ * the ttl is reset every time a key is accessed
34
+ */
35
+ ttl: number;
36
+ }>;
37
+ /**
38
+ * A helper class for caching items in memory and throttling / debouncing function calls
39
+ * methods for getters, setters, and executors are queued to prevent race conditions between calls.
40
+ * It provides helper methods for handling deregistering of items.
41
+ * Useful for caching database connections or rate-limiting outgoing Sentry calls.
42
+ */
43
+ export declare class CacheThrottle<T = any> {
44
+ #private;
45
+ constructor(config?: CacheThrottleConfig<T>);
46
+ /**
47
+ * attempts to retrieve a key from the cache
48
+ *
49
+ * @param {string} key
50
+ * @param {boolean} [asap] asap = as soon as possible. should this be queued or execute immediately
51
+ * @returns {(Promise<T | undefined>)}
52
+ * @memberof CacheThrottle
53
+ */
54
+ get(key: string, asap?: boolean): Promise<T | undefined>;
55
+ /**
56
+ * stores an item in the cache
57
+ *
58
+ * @param {string} key
59
+ * @param {T} value
60
+ * @param {number} [ttl=this.]
61
+ * @param {*} config
62
+ * @param {*} ttl
63
+ * @param {CacheMode} [mode]
64
+ * @param {boolean} [asap] asap = as soon as possible. should this be queued or execute immediately
65
+ * @returns {Promise<T>}
66
+ * @memberof CacheThrottle
67
+ */
68
+ set(key: string, value: T, ttl?: number, mode?: CacheMode, asap?: boolean): Promise<T>;
69
+ /**
70
+ * attempts to retrieve a value from the cache
71
+ * if it's not available, it sets the value using the provided generator method
72
+ */
73
+ getOrSet(key: string, generator: () => T | Promise<T>, ttl?: number, mode?: CacheMode, asap?: boolean): Promise<T>;
74
+ /**
75
+ * deletes an item from the cache
76
+ *
77
+ * @param {string} key
78
+ * @param {boolean} [isKeySerialized=false]
79
+ * @param {boolean} [asap] asap = as soon as possible. should this be queued or execute immediately
80
+ * @returns {(Promise<T | undefined>)}
81
+ * @memberof CacheThrottle
82
+ */
83
+ del(key: string, isKeySerialized?: boolean, asap?: boolean): Promise<T | undefined>;
84
+ /**
85
+ * returns the keys stored in the cache
86
+ */
87
+ keys(): string[];
88
+ /**
89
+ * executes a method. the `key` is used as a unique identifier for rate-limiting calls
90
+ */
91
+ do(key: string, method: () => T | Promise<T>, ttl?: number, mode?: CacheMode): Promise<T>;
92
+ /**
93
+ * removes all the items from the cache, clears timeouts, and calls deregister methods
94
+ */
95
+ close(): Promise<void>;
96
+ /**
97
+ * refreshes a set interval for clearing an item from the cache
98
+ * if an existing interval exists, it removes it
99
+ */
100
+ private refreshTimeout;
101
+ /**
102
+ * removes any pending delete calls on a key
103
+ * @param key
104
+ */
105
+ private clearPendingDeletesOnKey;
106
+ /**
107
+ * generates the key used for storing items in the cache
108
+ */
109
+ private serializeKey;
110
+ /**
111
+ * queues a method for processing
112
+ */
113
+ private enqueue;
114
+ /**
115
+ * calls the methods in the queue
116
+ */
117
+ private flush;
118
+ }
package/package.json CHANGED
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "name": "@useparagon/connect",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "paragon connect npm package",
5
- "main": "dist/src/index.js",
5
+ "main": "dist/src/index.ts",
6
+ "types": "dist/src/index.d.ts",
7
+ "exports": "./dist/src/index.js",
6
8
  "scripts": {
7
- "build:binary": "NODE_OPTIONS=--max-old-space-size=4096 pkg --public --output connect --targets node18 .",
8
9
  "build": "yarn typecheck && yarn clean && webpack --config webpack.config.js",
9
10
  "build:prod": "yarn typecheck && yarn clean && webpack --config webpack.config.js",
10
11
  "build:watch": "yarn build --watch",
11
- "clean": "rimraf coverage tmp dist",
12
- "clean:hard": "yarn -s clean && rimraf node_modules shared",
12
+ "clean": "rimraf coverage dist",
13
13
  "clean:server": "rimraf ./dist/src",
14
14
  "format:check": "prettier --ignore-path=./prettierignore --config=prettier.config.js --check .",
15
15
  "format": "prettier --ignore-path=./.prettierignore --write .",
@@ -18,68 +18,42 @@
18
18
  "lint:fix": "yarn -s lint --fix",
19
19
  "lint:staged": "yarn -s lint:cmd --fix",
20
20
  "prebuild": "yarn -s clean",
21
- "start:dev": "concurrently \"yarn build:watch\" \"lite-server -c ./bs-config.js\"",
22
- "start:prod": "node dist/src/index.js",
23
21
  "test": "NODE_OPTIONS=--max-old-space-size=4096 jest",
24
- "typecheck": "tsc -p tsconfig.json"
22
+ "typecheck": "tsc -p tsconfig.json",
23
+ "prepublishOnly":"yarn lint && yarn build"
25
24
  },
26
25
  "dependencies": {
27
- "browserify-zlib": "0.2.0",
28
- "crypto-browserify": "^3.12.0",
29
- "cryptr": "^6.0.1",
30
- "https-browserify": "1.0.0",
26
+ "hash.js": "^1.1.7",
31
27
  "jwt-decode": "^3.1.2",
32
- "process": "^0.11.10",
33
28
  "react": "^17.0.2",
34
- "react-dom": "^17.0.2",
35
- "reactjs-popup": "^1.5.0",
36
- "rxjs": "^7.3.0",
37
- "snarkdown": "^2.0.0",
38
- "source-map-support": "^0.5.19",
39
- "sourcemapped-stacktrace": "^1.1.11",
40
- "stacktrace-parser": "^0.1.8",
41
- "stream-http": "^3.2.0",
42
- "styled-components": "^5.2.1",
43
- "timers-browserify": "^2.0.12",
44
29
  "tslib": "2.3.1"
45
30
  },
46
31
  "devDependencies": {
47
32
  "@babel/core": "^7.12.3",
48
33
  "@babel/preset-env": "^7.12.1",
49
34
  "@babel/preset-react": "^7.12.5",
50
- "@darraghor/eslint-plugin-nestjs-typed": "^3.9.1",
51
- "@testing-library/jest-dom": "^5.14.1",
52
- "@testing-library/react": "^12.1.0",
53
- "@testing-library/user-event": "^14.4.3",
54
- "@types/cls-hooked": "^4.3.3",
55
- "@types/jest": "^29.5.0",
35
+ "@types/jest": "^29.5.1",
56
36
  "@types/node": "^18.13.0",
57
- "@types/object-hash": "^2.2.1",
58
37
  "@types/react": "^17.0.11",
59
- "@types/react-dom": "^17.0.8",
60
- "@types/styled-components": "^5.1.9",
61
- "@types/webpack-env": "^1.15.3",
62
38
  "@typescript-eslint/eslint-plugin": "^5.21.0",
63
39
  "@typescript-eslint/eslint-plugin-tslint": "^5.21.0",
64
40
  "@typescript-eslint/parser": "^5.21.0",
65
41
  "babel-loader": "^8.2.1",
66
- "buffer": "^6.0.3",
67
42
  "concurrently": "^6.2.0",
43
+ "crypto-browserify": "^3.12.0",
68
44
  "dotenv-webpack": "^7.0.3",
69
45
  "eslint": "^8.14.0",
70
46
  "eslint-config-prettier": "^8.5.0",
71
47
  "eslint-plugin-import": "^2.26.0",
72
48
  "eslint-plugin-jest": "^27.0.1",
73
- "eslint-plugin-local-rules": "^1.1.0",
49
+ "eslint-plugin-prettier": "^4.2.1",
74
50
  "eslint-plugin-react": "^7.29.4",
75
51
  "eslint-plugin-react-hooks": "^4.4.0",
76
52
  "eslint-plugin-unicorn": "^41.0.0",
77
- "filemanager-webpack-plugin": "^3.0.0-alpha.7",
78
53
  "jest": "^27.0.6",
79
54
  "jest-fetch-mock": "useparagon/jest-fetch-mock.git#3.0.4",
80
55
  "jest-json": "^1.0.4",
81
56
  "jest-json-reporter2": "^1.1.0",
82
- "jsonwebtoken": "^8.5.1",
83
57
  "node-notifier": "^10.0.0",
84
58
  "nyc": "^15.1.0",
85
59
  "pkg": "^5.8.1",
@@ -87,21 +61,21 @@
87
61
  "process": "^0.11.10",
88
62
  "rimraf": "^3.0.2",
89
63
  "stream-browserify": "^3.0.0",
90
- "stripe": "^8.67.0",
64
+ "stream-http": "^3.2.0",
65
+ "terser-webpack-plugin": "^5.3.7",
91
66
  "ts-jest": "^27.0.5",
92
67
  "ts-loader": "^6.2.1",
93
68
  "ts-node": "^10.0.0",
94
- "tsconfig-paths": "^3.9.0",
95
69
  "tsconfig-paths-webpack-plugin": "^3.2.0",
96
70
  "tslint": "6.1.2",
97
71
  "typescript": "^4.4.4",
98
72
  "util": "^0.12.4",
99
- "vm-browserify": "^1.1.2",
73
+ "uuid": "^9.0.0",
100
74
  "webpack": "^5.75.0",
101
75
  "webpack-bundle-analyzer": "^4.3.0",
102
- "webpack-cli": "^4.2.0"
76
+ "webpack-cli": "^5.0.2"
103
77
  },
104
- "license": "UNLICENSED",
78
+ "license": "MIT",
105
79
  "pkg": {
106
80
  "scripts": "./dist/**/*.js",
107
81
  "assets": [