@useparagon/connect 0.0.16-canary.2

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 (46) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +44 -0
  3. package/dist/src/ConnectSDK.d.ts +245 -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 +36 -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 +45 -0
  11. package/dist/src/entities/integrationConfig.interface.d.ts +9 -0
  12. package/dist/src/entities/license.interface.d.ts +6 -0
  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/file-picker/integrations/googledrive.d.ts +24 -0
  20. package/dist/src/file-picker/integrations/index.d.ts +5 -0
  21. package/dist/src/file-picker/types/baseFilePicker.d.ts +32 -0
  22. package/dist/src/file-picker/types/externalFilePicker.d.ts +9 -0
  23. package/dist/src/file-picker/types/index.d.ts +1 -0
  24. package/dist/src/helpers/ConnectUserContext.d.ts +18 -0
  25. package/dist/src/helpers/index.d.ts +29 -0
  26. package/dist/src/helpers/oauth.d.ts +20 -0
  27. package/dist/src/index.d.ts +8 -0
  28. package/dist/src/index.js +2 -0
  29. package/dist/src/index.js.LICENSE.txt +14 -0
  30. package/dist/src/server.types.d.ts +14 -0
  31. package/dist/src/types/action.d.ts +266 -0
  32. package/dist/src/types/billing.d.ts +2 -0
  33. package/dist/src/types/connect.d.ts +213 -0
  34. package/dist/src/types/connectModal.d.ts +35 -0
  35. package/dist/src/types/environment.d.ts +16 -0
  36. package/dist/src/types/execution.d.ts +5 -0
  37. package/dist/src/types/index.d.ts +9 -0
  38. package/dist/src/types/resolvers.d.ts +297 -0
  39. package/dist/src/types/sdk.d.ts +302 -0
  40. package/dist/src/types/stripe.d.ts +23 -0
  41. package/dist/src/utils/connect.d.ts +13 -0
  42. package/dist/src/utils/crypto.d.ts +7 -0
  43. package/dist/src/utils/generic.d.ts +30 -0
  44. package/dist/src/utils/http.d.ts +57 -0
  45. package/dist/src/utils/throttle.d.ts +118 -0
  46. package/package.json +103 -0
@@ -0,0 +1,57 @@
1
+ /**
2
+ * check if url is valid or not
3
+ * @param url
4
+ * @returns
5
+ */
6
+ export declare const isValidUrl: (url: string) => boolean;
7
+ /**
8
+ * it will add https protocol if protocol is not added in utl
9
+ * @param url
10
+ * @returns
11
+ */
12
+ export declare function sanitizeUrl(url: string): string;
13
+ export declare function getServiceUrl(service: string, domain: string, envPrefix?: string): string;
14
+ /**
15
+ * Validation error description.
16
+ * @see https://github.com/typestack/class-validator
17
+ *
18
+ * class-validator@0.13.0
19
+ *
20
+ * @publicApi
21
+ */
22
+ export interface ValidationError {
23
+ /**
24
+ * Constraints that failed validation with error messages.
25
+ */
26
+ constraints?: {
27
+ [type: string]: string;
28
+ };
29
+ /**
30
+ * Contains all nested validation errors of the property.
31
+ */
32
+ children?: ValidationError[];
33
+ }
34
+ export type MessageWithErrorBody = {
35
+ message: string;
36
+ response: Record<string, unknown>;
37
+ };
38
+ /**
39
+ * extract error message from response object
40
+ * @param response
41
+ * @returns
42
+ */
43
+ export declare function getErrorMessage(response: Response): Promise<string>;
44
+ export declare function getErrorMessage(response: Response, isProxyRequestFailure: true): Promise<MessageWithErrorBody>;
45
+ export declare function getErrorMessage(response: Response, isProxyRequestFailure: false): Promise<string>;
46
+ export declare class ProxyRequestError extends Error {
47
+ response: Record<string, unknown>;
48
+ constructor(message: string, response: any);
49
+ }
50
+ export declare const isIntegrationError: (error: unknown) => boolean;
51
+ /**
52
+ * Parses an error message and determines if it represents an integration error.
53
+ *
54
+ * @param {string | Error} err - The error message or Error object to parse.
55
+ * @returns {boolean} - True if the error represents an integration error, false otherwise.
56
+ */
57
+ export declare function errorMessageParser(err: string | Error): boolean;
@@ -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 ADDED
@@ -0,0 +1,103 @@
1
+ {
2
+ "name": "@useparagon/connect",
3
+ "version": "0.0.16-canary.2",
4
+ "description": "Embed integrations into your app with the Paragon SDK",
5
+ "main": "dist/src/index.js",
6
+ "types": "dist/src/index.d.ts",
7
+ "exports": "./dist/src/index.js",
8
+ "scripts": {
9
+ "build:prod": "yarn typecheck && yarn clean && webpack --config webpack.config.js",
10
+ "build:watch": "yarn build --watch",
11
+ "build": "yarn typecheck && yarn clean && webpack --config webpack.config.js",
12
+ "ci:compile": "whiskers",
13
+ "clean:server": "rimraf ./dist/src",
14
+ "clean": "rimraf coverage dist",
15
+ "format:check": "prettier --ignore-path=./prettierignore --config=prettier.config.js --check .",
16
+ "format": "prettier --ignore-path=./.prettierignore --write .",
17
+ "lint:cmd": "eslint --no-error-on-unmatched-pattern -c ./.eslintrc.js --cache --cache-strategy content --cache-location ./eslintcache/ --quiet",
18
+ "lint:fix": "yarn -s lint --fix",
19
+ "lint:staged": "yarn -s lint:cmd --fix",
20
+ "lint": "NODE_OPTIONS=--max-old-space-size=4096 yarn -s lint:cmd \"src{/**/,/}*.{js,jsx,ts,tsx}\"",
21
+ "prebuild": "yarn -s clean",
22
+ "release:publish:experimental": "yarn publish --new-version=$npm_package_version --tag=experimental",
23
+ "release:publish:stable": "yarn publish --new-version=$npm_package_version --tag=latest",
24
+ "release:version:bump": "ts-node ./scripts/version-bump.ts",
25
+ "test": "NODE_OPTIONS=--max-old-space-size=4096 jest",
26
+ "typecheck": "tsc -p tsconfig.json"
27
+ },
28
+ "dependencies": {
29
+ "hash.js": "^1.1.7",
30
+ "jwt-decode": "^3.1.2",
31
+ "react": "^17.0.2",
32
+ "tslib": "2.3.1"
33
+ },
34
+ "devDependencies": {
35
+ "@babel/core": "^7.12.3",
36
+ "@babel/preset-env": "^7.12.1",
37
+ "@babel/preset-react": "^7.12.5",
38
+ "@testing-library/jest-dom": "^5.14.1",
39
+ "@testing-library/react": "^12.1.0",
40
+ "@types/gapi": "^0.0.47",
41
+ "@types/google.picker": "^0.0.42",
42
+ "@types/jest": "^29.5.1",
43
+ "@types/node": "^18.13.0",
44
+ "@types/react": "^17.0.11",
45
+ "@types/react-dom": "^17.0.8",
46
+ "@typescript-eslint/eslint-plugin": "^5.21.0",
47
+ "@typescript-eslint/eslint-plugin-tslint": "^5.21.0",
48
+ "@typescript-eslint/parser": "^5.21.0",
49
+ "@useparagon/whiskers-cli": "^0.0.1-canary.15",
50
+ "babel-loader": "^8.2.1",
51
+ "concurrently": "^6.2.0",
52
+ "crypto-browserify": "^3.12.0",
53
+ "dotenv-webpack": "^7.0.3",
54
+ "eslint": "^8.14.0",
55
+ "eslint-config-prettier": "^8.5.0",
56
+ "eslint-plugin-import": "^2.26.0",
57
+ "eslint-plugin-jest": "^27.0.1",
58
+ "eslint-plugin-prettier": "^4.2.1",
59
+ "eslint-plugin-react": "^7.29.4",
60
+ "eslint-plugin-react-hooks": "^4.4.0",
61
+ "eslint-plugin-unicorn": "^41.0.0",
62
+ "glob": "^10.3.10",
63
+ "jest": "^27.0.6",
64
+ "jest-fetch-mock": "useparagon/jest-fetch-mock.git#3.0.4",
65
+ "jest-json": "^1.0.4",
66
+ "jest-json-reporter2": "^1.1.0",
67
+ "node-notifier": "^10.0.0",
68
+ "nyc": "^15.1.0",
69
+ "pkg": "^5.8.1",
70
+ "prettier": "^2.2.1",
71
+ "process": "^0.11.10",
72
+ "react-dom": "^17.0.2",
73
+ "rimraf": "^3.0.2",
74
+ "stream-browserify": "^3.0.0",
75
+ "stream-http": "^3.2.0",
76
+ "terser-webpack-plugin": "^5.3.7",
77
+ "ts-jest": "^27.0.5",
78
+ "ts-loader": "^6.2.1",
79
+ "ts-node": "^10.0.0",
80
+ "tsconfig-paths-webpack-plugin": "^3.2.0",
81
+ "tslint": "6.1.2",
82
+ "typescript": "^4.4.4",
83
+ "util": "^0.12.4",
84
+ "uuid": "^9.0.0",
85
+ "webpack": "^5.75.0",
86
+ "webpack-bundle-analyzer": "^4.3.0",
87
+ "webpack-cli": "^5.0.2"
88
+ },
89
+ "license": "MIT",
90
+ "pkg": {
91
+ "scripts": "./dist/**/*.js",
92
+ "assets": [
93
+ "./node_modules/**/*",
94
+ "./dist/src/**/*",
95
+ "./dist/**/*.json"
96
+ ]
97
+ },
98
+ "resolutions": {
99
+ "string-width": "^4.2.3",
100
+ "strip-ansi": "^6.0.1",
101
+ "wrap-ansi": "^6.2.0"
102
+ }
103
+ }