@fireberry/sdk 0.0.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.
- package/.eslintrc.json +36 -0
- package/.prettierrc.json +7 -0
- package/.vscode/settings.json +35 -0
- package/README.md +37 -0
- package/dist/base.fireberrySDK.d.ts +7 -0
- package/dist/base.fireberrySDK.js +10 -0
- package/dist/base.fireberrySDK.js.map +1 -0
- package/dist/context/context.d.ts +13 -0
- package/dist/context/context.js +22 -0
- package/dist/context/context.js.map +1 -0
- package/dist/context/context.record.test.d.ts +1 -0
- package/dist/context/context.record.test.js +45 -0
- package/dist/context/context.record.test.js.map +1 -0
- package/dist/context/index.d.ts +5 -0
- package/dist/context/index.js +18 -0
- package/dist/context/index.js.map +1 -0
- package/dist/context/record.d.ts +9 -0
- package/dist/context/record.js +33 -0
- package/dist/context/record.js.map +1 -0
- package/dist/context/user.d.ts +5 -0
- package/dist/context/user.js +27 -0
- package/dist/context/user.js.map +1 -0
- package/dist/fireberry.sdk.d.ts +4 -0
- package/dist/fireberry.sdk.js +13 -0
- package/dist/fireberry.sdk.js.map +1 -0
- package/dist/fireberryAPI/fireberryV2Api.d.ts +17 -0
- package/dist/fireberryAPI/fireberryV2Api.js +54 -0
- package/dist/fireberryAPI/fireberryV2Api.js.map +1 -0
- package/dist/fireberryAPI/fireberryV2Api.test.d.ts +1 -0
- package/dist/fireberryAPI/fireberryV2Api.test.js +56 -0
- package/dist/fireberryAPI/fireberryV2Api.test.js.map +1 -0
- package/dist/fireberryAPI/index.d.ts +2 -0
- package/dist/fireberryAPI/index.js +21 -0
- package/dist/fireberryAPI/index.js.map +1 -0
- package/dist/fireberryAPI/types.d.ts +10 -0
- package/dist/fireberryAPI/types.js +3 -0
- package/dist/fireberryAPI/types.js.map +1 -0
- package/dist/fireberrySDK.client.d.ts +5 -0
- package/dist/fireberrySDK.client.js +13 -0
- package/dist/fireberrySDK.client.js.map +1 -0
- package/dist/fireberrySDK.server.d.ts +6 -0
- package/dist/fireberrySDK.server.js +12 -0
- package/dist/fireberrySDK.server.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +25 -0
- package/dist/index.js.map +1 -0
- package/dist/jest.config.d.ts +6 -0
- package/dist/jest.config.js +11 -0
- package/dist/src/context/context.d.ts +13 -0
- package/dist/src/context/context.js +21 -0
- package/dist/src/context/context.record.test.d.ts +1 -0
- package/dist/src/context/context.record.test.js +36 -0
- package/dist/src/context/index.d.ts +5 -0
- package/dist/src/context/index.js +17 -0
- package/dist/src/context/record.d.ts +9 -0
- package/dist/src/context/record.js +32 -0
- package/dist/src/context/user.d.ts +8 -0
- package/dist/src/context/user.js +31 -0
- package/dist/src/fireberry.sdk.d.ts +9 -0
- package/dist/src/fireberry.sdk.js +14 -0
- package/dist/src/fireberryAPI/fireberryV2Api.d.ts +14 -0
- package/dist/src/fireberryAPI/fireberryV2Api.js +41 -0
- package/dist/src/fireberryAPI/index.d.ts +2 -0
- package/dist/src/fireberryAPI/index.js +20 -0
- package/dist/src/fireberryAPI/types.d.ts +10 -0
- package/dist/src/fireberryAPI/types.js +2 -0
- package/dist/src/index.d.ts +9 -0
- package/dist/src/index.js +6 -0
- package/dist/src/utils/axios.util.d.ts +6 -0
- package/dist/src/utils/axios.util.js +24 -0
- package/dist/src/utils/index.d.ts +2 -0
- package/dist/src/utils/index.js +18 -0
- package/dist/src/utils/queryParam.util.d.ts +1 -0
- package/dist/src/utils/queryParam.util.js +10 -0
- package/dist/utils/axios.util.d.ts +6 -0
- package/dist/utils/axios.util.js +24 -0
- package/dist/utils/axios.util.js.map +1 -0
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.js +19 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/queryParam.util.d.ts +1 -0
- package/dist/utils/queryParam.util.js +12 -0
- package/dist/utils/queryParam.util.js.map +1 -0
- package/jest.config.ts +10 -0
- package/node_modules/asynckit/LICENSE +21 -0
- package/node_modules/asynckit/README.md +233 -0
- package/node_modules/asynckit/bench.js +76 -0
- package/node_modules/asynckit/index.js +6 -0
- package/node_modules/asynckit/lib/abort.js +29 -0
- package/node_modules/asynckit/lib/async.js +34 -0
- package/node_modules/asynckit/lib/defer.js +26 -0
- package/node_modules/asynckit/lib/iterate.js +75 -0
- package/node_modules/asynckit/lib/readable_asynckit.js +91 -0
- package/node_modules/asynckit/lib/readable_parallel.js +25 -0
- package/node_modules/asynckit/lib/readable_serial.js +25 -0
- package/node_modules/asynckit/lib/readable_serial_ordered.js +29 -0
- package/node_modules/asynckit/lib/state.js +37 -0
- package/node_modules/asynckit/lib/streamify.js +141 -0
- package/node_modules/asynckit/lib/terminator.js +29 -0
- package/node_modules/asynckit/package.json +63 -0
- package/node_modules/asynckit/parallel.js +43 -0
- package/node_modules/asynckit/serial.js +17 -0
- package/node_modules/asynckit/serialOrdered.js +75 -0
- package/node_modules/asynckit/stream.js +21 -0
- package/node_modules/axios/CHANGELOG.md +874 -0
- package/node_modules/axios/LICENSE +7 -0
- package/node_modules/axios/MIGRATION_GUIDE.md +3 -0
- package/node_modules/axios/README.md +1650 -0
- package/node_modules/axios/SECURITY.md +6 -0
- package/node_modules/axios/dist/axios.js +3448 -0
- package/node_modules/axios/dist/axios.js.map +1 -0
- package/node_modules/axios/dist/axios.min.js +2 -0
- package/node_modules/axios/dist/axios.min.js.map +1 -0
- package/node_modules/axios/dist/browser/axios.cjs +3258 -0
- package/node_modules/axios/dist/browser/axios.cjs.map +1 -0
- package/node_modules/axios/dist/esm/axios.js +3281 -0
- package/node_modules/axios/dist/esm/axios.js.map +1 -0
- package/node_modules/axios/dist/esm/axios.min.js +2 -0
- package/node_modules/axios/dist/esm/axios.min.js.map +1 -0
- package/node_modules/axios/dist/node/axios.cjs +4354 -0
- package/node_modules/axios/dist/node/axios.cjs.map +1 -0
- package/node_modules/axios/index.d.cts +542 -0
- package/node_modules/axios/index.d.ts +559 -0
- package/node_modules/axios/index.js +43 -0
- package/node_modules/axios/lib/adapters/README.md +37 -0
- package/node_modules/axios/lib/adapters/adapters.js +77 -0
- package/node_modules/axios/lib/adapters/http.js +685 -0
- package/node_modules/axios/lib/adapters/xhr.js +260 -0
- package/node_modules/axios/lib/axios.js +89 -0
- package/node_modules/axios/lib/cancel/CancelToken.js +121 -0
- package/node_modules/axios/lib/cancel/CanceledError.js +25 -0
- package/node_modules/axios/lib/cancel/isCancel.js +5 -0
- package/node_modules/axios/lib/core/Axios.js +225 -0
- package/node_modules/axios/lib/core/AxiosError.js +100 -0
- package/node_modules/axios/lib/core/AxiosHeaders.js +298 -0
- package/node_modules/axios/lib/core/InterceptorManager.js +71 -0
- package/node_modules/axios/lib/core/README.md +8 -0
- package/node_modules/axios/lib/core/buildFullPath.js +21 -0
- package/node_modules/axios/lib/core/dispatchRequest.js +81 -0
- package/node_modules/axios/lib/core/mergeConfig.js +106 -0
- package/node_modules/axios/lib/core/settle.js +27 -0
- package/node_modules/axios/lib/core/transformData.js +28 -0
- package/node_modules/axios/lib/defaults/index.js +156 -0
- package/node_modules/axios/lib/defaults/transitional.js +7 -0
- package/node_modules/axios/lib/env/README.md +3 -0
- package/node_modules/axios/lib/env/classes/FormData.js +2 -0
- package/node_modules/axios/lib/env/data.js +1 -0
- package/node_modules/axios/lib/helpers/AxiosTransformStream.js +191 -0
- package/node_modules/axios/lib/helpers/AxiosURLSearchParams.js +58 -0
- package/node_modules/axios/lib/helpers/HttpStatusCode.js +71 -0
- package/node_modules/axios/lib/helpers/README.md +7 -0
- package/node_modules/axios/lib/helpers/ZlibHeaderTransformStream.js +28 -0
- package/node_modules/axios/lib/helpers/bind.js +7 -0
- package/node_modules/axios/lib/helpers/buildURL.js +63 -0
- package/node_modules/axios/lib/helpers/callbackify.js +16 -0
- package/node_modules/axios/lib/helpers/combineURLs.js +15 -0
- package/node_modules/axios/lib/helpers/cookies.js +42 -0
- package/node_modules/axios/lib/helpers/deprecatedMethod.js +26 -0
- package/node_modules/axios/lib/helpers/formDataToJSON.js +95 -0
- package/node_modules/axios/lib/helpers/formDataToStream.js +111 -0
- package/node_modules/axios/lib/helpers/fromDataURI.js +53 -0
- package/node_modules/axios/lib/helpers/isAbsoluteURL.js +15 -0
- package/node_modules/axios/lib/helpers/isAxiosError.js +14 -0
- package/node_modules/axios/lib/helpers/isURLSameOrigin.js +67 -0
- package/node_modules/axios/lib/helpers/null.js +2 -0
- package/node_modules/axios/lib/helpers/parseHeaders.js +55 -0
- package/node_modules/axios/lib/helpers/parseProtocol.js +6 -0
- package/node_modules/axios/lib/helpers/readBlob.js +15 -0
- package/node_modules/axios/lib/helpers/speedometer.js +55 -0
- package/node_modules/axios/lib/helpers/spread.js +28 -0
- package/node_modules/axios/lib/helpers/throttle.js +33 -0
- package/node_modules/axios/lib/helpers/toFormData.js +219 -0
- package/node_modules/axios/lib/helpers/toURLEncodedForm.js +18 -0
- package/node_modules/axios/lib/helpers/validator.js +91 -0
- package/node_modules/axios/lib/platform/browser/classes/Blob.js +3 -0
- package/node_modules/axios/lib/platform/browser/classes/FormData.js +3 -0
- package/node_modules/axios/lib/platform/browser/classes/URLSearchParams.js +4 -0
- package/node_modules/axios/lib/platform/browser/index.js +13 -0
- package/node_modules/axios/lib/platform/common/utils.js +47 -0
- package/node_modules/axios/lib/platform/index.js +7 -0
- package/node_modules/axios/lib/platform/node/classes/FormData.js +3 -0
- package/node_modules/axios/lib/platform/node/classes/URLSearchParams.js +4 -0
- package/node_modules/axios/lib/platform/node/index.js +12 -0
- package/node_modules/axios/lib/utils.js +723 -0
- package/node_modules/axios/package.json +218 -0
- package/node_modules/combined-stream/License +19 -0
- package/node_modules/combined-stream/Readme.md +138 -0
- package/node_modules/combined-stream/lib/combined_stream.js +208 -0
- package/node_modules/combined-stream/package.json +25 -0
- package/node_modules/delayed-stream/.npmignore +1 -0
- package/node_modules/delayed-stream/License +19 -0
- package/node_modules/delayed-stream/Makefile +7 -0
- package/node_modules/delayed-stream/Readme.md +141 -0
- package/node_modules/delayed-stream/lib/delayed_stream.js +107 -0
- package/node_modules/delayed-stream/package.json +27 -0
- package/node_modules/dotenv/CHANGELOG.md +475 -0
- package/node_modules/dotenv/LICENSE +23 -0
- package/node_modules/dotenv/README-es.md +448 -0
- package/node_modules/dotenv/README.md +728 -0
- package/node_modules/dotenv/config.d.ts +1 -0
- package/node_modules/dotenv/config.js +9 -0
- package/node_modules/dotenv/lib/cli-options.js +11 -0
- package/node_modules/dotenv/lib/env-options.js +24 -0
- package/node_modules/dotenv/lib/main.d.ts +153 -0
- package/node_modules/dotenv/lib/main.js +361 -0
- package/node_modules/dotenv/package.json +65 -0
- package/node_modules/follow-redirects/LICENSE +18 -0
- package/node_modules/follow-redirects/README.md +155 -0
- package/node_modules/follow-redirects/debug.js +15 -0
- package/node_modules/follow-redirects/http.js +1 -0
- package/node_modules/follow-redirects/https.js +1 -0
- package/node_modules/follow-redirects/index.js +672 -0
- package/node_modules/follow-redirects/package.json +58 -0
- package/node_modules/form-data/License +19 -0
- package/node_modules/form-data/README.md.bak +358 -0
- package/node_modules/form-data/Readme.md +358 -0
- package/node_modules/form-data/index.d.ts +62 -0
- package/node_modules/form-data/lib/browser.js +2 -0
- package/node_modules/form-data/lib/form_data.js +501 -0
- package/node_modules/form-data/lib/populate.js +10 -0
- package/node_modules/form-data/package.json +68 -0
- package/node_modules/mime-db/HISTORY.md +507 -0
- package/node_modules/mime-db/LICENSE +23 -0
- package/node_modules/mime-db/README.md +100 -0
- package/node_modules/mime-db/db.json +8519 -0
- package/node_modules/mime-db/index.js +12 -0
- package/node_modules/mime-db/package.json +60 -0
- package/node_modules/mime-types/HISTORY.md +397 -0
- package/node_modules/mime-types/LICENSE +23 -0
- package/node_modules/mime-types/README.md +113 -0
- package/node_modules/mime-types/index.js +188 -0
- package/node_modules/mime-types/package.json +44 -0
- package/node_modules/proxy-from-env/.eslintrc +29 -0
- package/node_modules/proxy-from-env/.travis.yml +10 -0
- package/node_modules/proxy-from-env/LICENSE +20 -0
- package/node_modules/proxy-from-env/README.md +131 -0
- package/node_modules/proxy-from-env/index.js +108 -0
- package/node_modules/proxy-from-env/package.json +34 -0
- package/node_modules/proxy-from-env/test.js +483 -0
- package/package.json +48 -0
- package/src/base.fireberrySDK.ts +7 -0
- package/src/context/context.record.test.ts +47 -0
- package/src/context/context.ts +28 -0
- package/src/context/index.ts +6 -0
- package/src/context/record.ts +22 -0
- package/src/context/user.ts +15 -0
- package/src/fireberry.sdk.ts +14 -0
- package/src/fireberryAPI/fireberryV2Api.test.ts +57 -0
- package/src/fireberryAPI/fireberryV2Api.ts +61 -0
- package/src/fireberryAPI/index.ts +2 -0
- package/src/fireberryAPI/types.ts +10 -0
- package/src/fireberrySDK.client.ts +10 -0
- package/src/fireberrySDK.server.ts +8 -0
- package/src/index.ts +9 -0
- package/src/utils/axios.util.ts +20 -0
- package/src/utils/index.ts +2 -0
- package/src/utils/queryParam.util.ts +8 -0
- package/tsconfig.json +123 -0
package/.eslintrc.json
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"env": {
|
|
3
|
+
"browser": true,
|
|
4
|
+
"es2021": true
|
|
5
|
+
},
|
|
6
|
+
"extends": [
|
|
7
|
+
"eslint:recommended",
|
|
8
|
+
"plugin:@typescript-eslint/recommended"
|
|
9
|
+
],
|
|
10
|
+
"parser": "@typescript-eslint/parser",
|
|
11
|
+
"parserOptions": {
|
|
12
|
+
"ecmaVersion": "latest",
|
|
13
|
+
"sourceType": "module"
|
|
14
|
+
},
|
|
15
|
+
"plugins": [
|
|
16
|
+
"@typescript-eslint"
|
|
17
|
+
],
|
|
18
|
+
"rules": {
|
|
19
|
+
"indent": [
|
|
20
|
+
"error",
|
|
21
|
+
"space"
|
|
22
|
+
],
|
|
23
|
+
"linebreak-style": [
|
|
24
|
+
"error",
|
|
25
|
+
"unix"
|
|
26
|
+
],
|
|
27
|
+
"quotes": [
|
|
28
|
+
"error",
|
|
29
|
+
"single"
|
|
30
|
+
],
|
|
31
|
+
"semi": [
|
|
32
|
+
"error",
|
|
33
|
+
"always"
|
|
34
|
+
]
|
|
35
|
+
}
|
|
36
|
+
}
|
package/.prettierrc.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"[javascript]": {
|
|
3
|
+
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
|
4
|
+
},
|
|
5
|
+
"editor.formatOnSave": true,
|
|
6
|
+
"files.autoSave": "onFocusChange",
|
|
7
|
+
"files.trimTrailingWhitespace": true,
|
|
8
|
+
"[html]": {
|
|
9
|
+
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
|
10
|
+
},
|
|
11
|
+
"[json]": {
|
|
12
|
+
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
|
13
|
+
},
|
|
14
|
+
"[typescript]": {
|
|
15
|
+
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
|
16
|
+
},
|
|
17
|
+
"[jsonc]": {
|
|
18
|
+
"editor.defaultFormatter": "vscode.json-language-features"
|
|
19
|
+
},
|
|
20
|
+
"editor.codeActionsOnSave": {
|
|
21
|
+
"source.organizeImports": "always"
|
|
22
|
+
},
|
|
23
|
+
"files.associations": {
|
|
24
|
+
".env": "ini"
|
|
25
|
+
},
|
|
26
|
+
"editor.wordWrap": "on",
|
|
27
|
+
"javascript.format.insertSpaceBeforeFunctionParenthesis": true,
|
|
28
|
+
"typescript.format.insertSpaceBeforeFunctionParenthesis": true,
|
|
29
|
+
"javascript.format.insertSpaceAfterFunctionKeywordForAnonymousFunctions": false,
|
|
30
|
+
"typescript.format.insertSpaceAfterFunctionKeywordForAnonymousFunctions": false,
|
|
31
|
+
"typescript.preferences.importModuleSpecifier": "relative",
|
|
32
|
+
"cSpell.words": [
|
|
33
|
+
"Fireberry"
|
|
34
|
+
]
|
|
35
|
+
}
|
package/README.md
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# Fireberry SDK
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
Welcome to the Fireberry SDK! This software development kit (SDK) is designed to help developers who are looking to integrate Fireberry into their application. This guide will provide you with the necessary information to get started.
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- Get current record: Using FireberryApi module you can fetch the current record.
|
|
10
|
+
- [Feature 2]: Description of the second feature.
|
|
11
|
+
- [Feature 3]: Description of the third feature.
|
|
12
|
+
- ...
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
To integrate Fireberry SDK into your project, follow these simple steps:
|
|
17
|
+
|
|
18
|
+
1. URL params: The SDK uses `recordType` and `recordId` url params, make sure you don't overrides them.
|
|
19
|
+
2. tokenId variable: On dev mode only, pass the tokenId as a config to the FireberrySDK instance.
|
|
20
|
+
_Pay attention: In production, the SDK will use the cookie as an authentication, and not the token_
|
|
21
|
+
3. node env variable: Add to your `.env` file a `NODE_ENV` param:
|
|
22
|
+
`NODE_ENV=development`
|
|
23
|
+
|
|
24
|
+
### How to use
|
|
25
|
+
|
|
26
|
+
```
|
|
27
|
+
const [record, setRecord] = useState(null);
|
|
28
|
+
|
|
29
|
+
useEffect(() => {
|
|
30
|
+
const fbSDK = new FireberrySDK({
|
|
31
|
+
tokenId: "YOUR DEVELOPMENT ONLY TOKEN",
|
|
32
|
+
});
|
|
33
|
+
fbSDK.context.record.all().then((record) => {
|
|
34
|
+
setRecord(record);
|
|
35
|
+
});
|
|
36
|
+
}, []);
|
|
37
|
+
```
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FireberrySDK = void 0;
|
|
4
|
+
class FireberrySDK {
|
|
5
|
+
constructor(api) {
|
|
6
|
+
this.api = api;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
exports.FireberrySDK = FireberrySDK;
|
|
10
|
+
//# sourceMappingURL=base.fireberrySDK.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base.fireberrySDK.js","sourceRoot":"","sources":["../src/base.fireberrySDK.ts"],"names":[],"mappings":";;;AAGA,MAAsB,YAAY;IAEhC,YAAmB,GAAmB;QAAnB,QAAG,GAAH,GAAG,CAAgB;IAAG,CAAC;CAC3C;AAHD,oCAGC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { FireberryV2Api } from '../fireberryAPI';
|
|
2
|
+
import { RecordContext } from './record';
|
|
3
|
+
import { UserContext } from './user';
|
|
4
|
+
export declare class Context {
|
|
5
|
+
recordId?: string;
|
|
6
|
+
recordType?: number;
|
|
7
|
+
user: UserContext;
|
|
8
|
+
record: RecordContext;
|
|
9
|
+
constructor(fireberryApi: FireberryV2Api, recordDetails?: {
|
|
10
|
+
recordId: string;
|
|
11
|
+
recordType: number;
|
|
12
|
+
});
|
|
13
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Context = void 0;
|
|
4
|
+
const utils_1 = require("../utils");
|
|
5
|
+
const record_1 = require("./record");
|
|
6
|
+
const user_1 = require("./user");
|
|
7
|
+
class Context {
|
|
8
|
+
constructor(fireberryApi, recordDetails) {
|
|
9
|
+
const recordId = (0, utils_1.getParam)('recordId');
|
|
10
|
+
const recordTypeParam = (0, utils_1.getParam)('recordType');
|
|
11
|
+
const recordType = recordTypeParam ? parseInt(recordTypeParam) : undefined;
|
|
12
|
+
this.recordId = recordId;
|
|
13
|
+
this.recordType = recordType;
|
|
14
|
+
this.user = new user_1.UserContext();
|
|
15
|
+
this.record = new record_1.RecordContext(fireberryApi, {
|
|
16
|
+
recordId: recordId || (recordDetails === null || recordDetails === void 0 ? void 0 : recordDetails.recordId),
|
|
17
|
+
recordType: recordType || (recordDetails === null || recordDetails === void 0 ? void 0 : recordDetails.recordType),
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.Context = Context;
|
|
22
|
+
//# sourceMappingURL=context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/context/context.ts"],"names":[],"mappings":";;;AACA,oCAAoC;AACpC,qCAAyC;AACzC,iCAAqC;AAErC,MAAa,OAAO;IAMlB,YACE,YAA4B,EAC5B,aAAwD;QAExD,MAAM,QAAQ,GAAG,IAAA,gBAAQ,EAAC,UAAU,CAAC,CAAC;QACtC,MAAM,eAAe,GAAG,IAAA,gBAAQ,EAAC,YAAY,CAAC,CAAC;QAC/C,MAAM,UAAU,GAAG,eAAe,CAAC,CAAC,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QAE3E,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,IAAI,GAAG,IAAI,kBAAW,EAAkB,CAAC;QAC9C,IAAI,CAAC,MAAM,GAAG,IAAI,sBAAa,CAAC,YAAY,EAAE;YAC5C,QAAQ,EAAE,QAAQ,KAAI,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAE,QAAQ,CAAA;YAC7C,UAAU,EAAE,UAAU,KAAI,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAE,UAAU,CAAA;SACpD,CAAC,CAAC;IACL,CAAC;CACF;AAtBD,0BAsBC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const jsdom_1 = require("jsdom");
|
|
16
|
+
const __1 = __importDefault(require("../"));
|
|
17
|
+
describe('SDK context', () => {
|
|
18
|
+
it('context is undefined when not in browser', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
19
|
+
const fireberry = (0, __1.default)();
|
|
20
|
+
expect(fireberry.context).toBeUndefined;
|
|
21
|
+
}));
|
|
22
|
+
it('retrieved a record', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
23
|
+
var _a, _b;
|
|
24
|
+
const dom = new jsdom_1.JSDOM('<!DOCTYPE html><html><head></head><body></body></html>', {
|
|
25
|
+
url: 'http://localhost?recordId=123&recordType=1&tokenId=123',
|
|
26
|
+
});
|
|
27
|
+
global.window = dom.window;
|
|
28
|
+
global.window.parent = dom.window;
|
|
29
|
+
global.document = dom.window.document;
|
|
30
|
+
global.window.location = dom.window.location;
|
|
31
|
+
const customFieldName = 'pcfSystemField123';
|
|
32
|
+
const extendCustomObject = { [customFieldName]: 'test' };
|
|
33
|
+
const fireberry = (0, __1.default)();
|
|
34
|
+
const record = Object.assign({ createdBy: 'test', createdByName: 'test', createdOn: new Date(), modifiedBy: 'test', modifiedByName: 'test', modifiedOn: new Date(), ownerId: 'test', ownerName: 'test' }, extendCustomObject);
|
|
35
|
+
const mockAddListener = jest.spyOn(fireberry.api, 'get');
|
|
36
|
+
mockAddListener.mockImplementation((_recordType, _recordId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
37
|
+
return record;
|
|
38
|
+
}));
|
|
39
|
+
const specificFieldValue = yield ((_a = fireberry.context) === null || _a === void 0 ? void 0 : _a.record.get(customFieldName));
|
|
40
|
+
expect(specificFieldValue).toBe(extendCustomObject[customFieldName]);
|
|
41
|
+
const recordResult = yield ((_b = fireberry.context) === null || _b === void 0 ? void 0 : _b.record.all());
|
|
42
|
+
expect(recordResult).toBe(record);
|
|
43
|
+
}));
|
|
44
|
+
});
|
|
45
|
+
//# sourceMappingURL=context.record.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.record.test.js","sourceRoot":"","sources":["../../src/context/context.record.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,iCAA8B;AAC9B,4CAA+B;AAE/B,QAAQ,CAAC,aAAa,EAAE,GAAG,EAAE;IAC3B,EAAE,CAAC,0CAA0C,EAAE,GAAS,EAAE;QACxD,MAAM,SAAS,GAAG,IAAA,WAAY,GAAE,CAAC;QAEjC,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,aAAa,CAAC;IAC1C,CAAC,CAAA,CAAC,CAAC;IAEH,EAAE,CAAC,oBAAoB,EAAE,GAAS,EAAE;;QAClC,MAAM,GAAG,GAAG,IAAI,aAAK,CAAC,wDAAwD,EAAE;YAC9E,GAAG,EAAE,wDAAwD;SAC9D,CAAC,CAAC;QACH,MAAM,CAAC,MAAM,GAAG,GAAG,CAAC,MAAa,CAAC;QAClC,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,GAAG,CAAC,MAAa,CAAC;QACzC,MAAM,CAAC,QAAQ,GAAG,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC;QACtC,MAAM,CAAC,MAAM,CAAC,QAAQ,GAAG,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC;QAE7C,MAAM,eAAe,GAAG,mBAAmB,CAAC;QAC5C,MAAM,kBAAkB,GAAG,EAAE,CAAC,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;QACzD,MAAM,SAAS,GAAG,IAAA,WAAY,GAAE,CAAC;QAEjC,MAAM,MAAM,mBACV,SAAS,EAAE,MAAM,EACjB,aAAa,EAAE,MAAM,EACrB,SAAS,EAAE,IAAI,IAAI,EAAE,EACrB,UAAU,EAAE,MAAM,EAClB,cAAc,EAAE,MAAM,EACtB,UAAU,EAAE,IAAI,IAAI,EAAE,EACtB,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,IACd,kBAAkB,CACtB,CAAC;QAEF,MAAM,eAAe,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QACzD,eAAe,CAAC,kBAAkB,CAAC,CAAO,WAAmB,EAAE,SAAiB,EAAE,EAAE;YAClF,OAAO,MAAM,CAAC;QAChB,CAAC,CAAA,CAAC,CAAC;QAEH,MAAM,kBAAkB,GAAG,MAAM,CAAA,MAAA,SAAS,CAAC,OAAO,0CAAE,MAAM,CAAC,GAAG,CAAC,eAAe,CAAC,CAAA,CAAC;QAChF,MAAM,CAAC,kBAAkB,CAAC,CAAC,IAAI,CAAC,kBAAkB,CAAC,eAAe,CAAC,CAAC,CAAC;QAErE,MAAM,YAAY,GAAG,MAAM,CAAA,MAAA,SAAS,CAAC,OAAO,0CAAE,MAAM,CAAC,GAAG,EAAE,CAAA,CAAC;QAC3D,MAAM,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACpC,CAAC,CAAA,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./context"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/context/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4CAA0B"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { CurrentRecordDetails } from '.';
|
|
2
|
+
import { BusinessObject, FireberryV2Api } from '../fireberryAPI';
|
|
3
|
+
export declare class RecordContext {
|
|
4
|
+
private fireberryApi;
|
|
5
|
+
private currentRecord;
|
|
6
|
+
constructor(fireberryApi: FireberryV2Api, currentRecord: CurrentRecordDetails);
|
|
7
|
+
get(fieldName: string): Promise<any>;
|
|
8
|
+
all(): Promise<BusinessObject & any>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.RecordContext = void 0;
|
|
13
|
+
class RecordContext {
|
|
14
|
+
constructor(fireberryApi, currentRecord) {
|
|
15
|
+
this.fireberryApi = fireberryApi;
|
|
16
|
+
this.currentRecord = currentRecord;
|
|
17
|
+
}
|
|
18
|
+
get(fieldName) {
|
|
19
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
20
|
+
return (yield this.all())[fieldName];
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
all() {
|
|
24
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
25
|
+
if (!this.currentRecord.recordId || !this.currentRecord.recordType) {
|
|
26
|
+
throw new Error('Record context is not set. Please set the recordId and recordType before calling this method.');
|
|
27
|
+
}
|
|
28
|
+
return yield this.fireberryApi.get(this.currentRecord.recordType, this.currentRecord.recordId);
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
exports.RecordContext = RecordContext;
|
|
33
|
+
//# sourceMappingURL=record.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"record.js","sourceRoot":"","sources":["../../src/context/record.ts"],"names":[],"mappings":";;;;;;;;;;;;AAGA,MAAa,aAAa;IACxB,YACU,YAA4B,EAC5B,aAAmC;QADnC,iBAAY,GAAZ,YAAY,CAAgB;QAC5B,kBAAa,GAAb,aAAa,CAAsB;IAC1C,CAAC;IAEE,GAAG,CAAC,SAAiB;;YACzB,OAAO,CAAC,MAAM,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC;QACvC,CAAC;KAAA;IAEK,GAAG;;YACP,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,QAAQ,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,UAAU,EAAE,CAAC;gBACnE,MAAM,IAAI,KAAK,CACb,+FAA+F,CAChG,CAAC;YACJ,CAAC;YACD,OAAO,MAAM,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,aAAa,CAAC,UAAU,EAAE,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;QACjG,CAAC;KAAA;CACF;AAlBD,sCAkBC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.UserContext = void 0;
|
|
13
|
+
class UserContext {
|
|
14
|
+
constructor() { }
|
|
15
|
+
get(_fieldName) {
|
|
16
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
17
|
+
throw new Error('Not implemented');
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
all() {
|
|
21
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
22
|
+
throw new Error('Not implemented');
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
exports.UserContext = UserContext;
|
|
27
|
+
//# sourceMappingURL=user.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"user.js","sourceRoot":"","sources":["../../src/context/user.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,MAAa,WAAW;IAEtB,gBAAuD,CAAC;IAGlD,GAAG,CAAC,UAAkB;;YAC1B,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;QACrC,CAAC;KAAA;IAEK,GAAG;;YACP,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;QACrC,CAAC;KAAA;CACF;AAZD,kCAYC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const fireberryAPI_1 = require("./fireberryAPI");
|
|
4
|
+
const fireberrySDK_client_1 = require("./fireberrySDK.client");
|
|
5
|
+
const fireberrySDK_server_1 = require("./fireberrySDK.server");
|
|
6
|
+
const utils_1 = require("./utils");
|
|
7
|
+
exports.default = () => {
|
|
8
|
+
const isBrowser = typeof window !== 'undefined' && typeof window.document !== 'undefined';
|
|
9
|
+
const tokenId = (0, utils_1.getParam)('tokenId');
|
|
10
|
+
const api = new fireberryAPI_1.FireberryV2Api({ tokenId });
|
|
11
|
+
return isBrowser ? new fireberrySDK_client_1.FireberryClientSDK(api) : new fireberrySDK_server_1.FireberryServerSDK(api);
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=fireberry.sdk.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fireberry.sdk.js","sourceRoot":"","sources":["../src/fireberry.sdk.ts"],"names":[],"mappings":";;AAAA,iDAAgD;AAChD,+DAA2D;AAC3D,+DAA2D;AAC3D,mCAAmC;AAEnC,kBAAe,GAAG,EAAE;IAClB,MAAM,SAAS,GAAG,OAAO,MAAM,KAAK,WAAW,IAAI,OAAO,MAAM,CAAC,QAAQ,KAAK,WAAW,CAAC;IAE1F,MAAM,OAAO,GAAG,IAAA,gBAAQ,EAAC,SAAS,CAAC,CAAC;IAEpC,MAAM,GAAG,GAAG,IAAI,6BAAc,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC;IAE5C,OAAO,SAAS,CAAC,CAAC,CAAC,IAAI,wCAAkB,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,wCAAkB,CAAC,GAAG,CAAC,CAAC;AAC/E,CAAC,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Config } from '..';
|
|
2
|
+
import { AxiosFireberryAPI } from '../utils';
|
|
3
|
+
import { BusinessObject } from './types';
|
|
4
|
+
export declare class FireberryV2Api extends AxiosFireberryAPI {
|
|
5
|
+
constructor(config: Config);
|
|
6
|
+
create<TReq, TRes extends TReq & BusinessObject>(recordType: number, data: TReq): Promise<{
|
|
7
|
+
_id: string;
|
|
8
|
+
} & TRes>;
|
|
9
|
+
update<TReq, TRes extends TReq & BusinessObject>(recordType: number, id: string, data: Record<string, any>): Promise<TRes & {
|
|
10
|
+
_id: string;
|
|
11
|
+
}>;
|
|
12
|
+
delete(recordType: number, id: string): Promise<{
|
|
13
|
+
success: boolean;
|
|
14
|
+
}>;
|
|
15
|
+
get<T extends BusinessObject>(recordType: number, recordId: string): Promise<T>;
|
|
16
|
+
query(fields: string[], recordType: number, query: string, shouldShowRealValues?: boolean): Promise<import("axios").AxiosResponse<any, any>>;
|
|
17
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.FireberryV2Api = void 0;
|
|
13
|
+
const utils_1 = require("../utils");
|
|
14
|
+
class FireberryV2Api extends utils_1.AxiosFireberryAPI {
|
|
15
|
+
constructor(config) {
|
|
16
|
+
super(config);
|
|
17
|
+
}
|
|
18
|
+
create(recordType, data) {
|
|
19
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
20
|
+
const newRecord = yield this.api.post(`api/v2/record/${recordType}`, data);
|
|
21
|
+
const { _id, record } = newRecord.data;
|
|
22
|
+
return Object.assign({ _id }, record);
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
update(recordType, id, data) {
|
|
26
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
27
|
+
const updatedRecord = yield this.api.put(`api/v2/record/${recordType}/${id}`, data);
|
|
28
|
+
return Object.assign(Object.assign({}, updatedRecord.data.record), { _id: id });
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
delete(recordType, id) {
|
|
32
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
33
|
+
return (yield this.api.delete(`api/record/${recordType}/${id}`)).data;
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
get(recordType, recordId) {
|
|
37
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
38
|
+
return (yield this.api.get(`/api/v2/record/${recordType}/${recordId}/getrecord`)).data;
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
query(fields_1, recordType_1, query_1) {
|
|
42
|
+
return __awaiter(this, arguments, void 0, function* (fields, recordType, query, shouldShowRealValues = false) {
|
|
43
|
+
const payload = {
|
|
44
|
+
recordType: recordType,
|
|
45
|
+
fields,
|
|
46
|
+
query,
|
|
47
|
+
show_real_value: shouldShowRealValues ? 1 : 0,
|
|
48
|
+
};
|
|
49
|
+
return yield this.api.post('/api/query', payload);
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
exports.FireberryV2Api = FireberryV2Api;
|
|
54
|
+
//# sourceMappingURL=fireberryV2Api.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fireberryV2Api.js","sourceRoot":"","sources":["../../src/fireberryAPI/fireberryV2Api.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,oCAA6C;AAG7C,MAAa,cAAe,SAAQ,yBAAiB;IACnD,YAAY,MAAc;QACxB,KAAK,CAAC,MAAM,CAAC,CAAC;IAChB,CAAC;IASK,MAAM,CAA2C,UAAkB,EAAE,IAAU;;YACnF,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,IAAI,CACnC,iBAAiB,UAAU,EAAE,EAC7B,IAAI,CACL,CAAC;YACF,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC,IAAI,CAAC;YACvC,uBAAS,GAAG,IAAK,MAAM,EAAG;QAC5B,CAAC;KAAA;IAEK,MAAM,CACV,UAAkB,EAClB,EAAU,EACV,IAAyB;;YAEzB,MAAM,aAAa,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,GAAG,CACtC,iBAAiB,UAAU,IAAI,EAAE,EAAE,EACnC,IAAI,CACL,CAAC;YACF,uCAAY,aAAa,CAAC,IAAI,CAAC,MAAM,KAAE,GAAG,EAAE,EAAE,IAAG;QACnD,CAAC;KAAA;IAEK,MAAM,CAAC,UAAkB,EAAE,EAAU;;YACzC,OAAO,CAAC,MAAM,IAAI,CAAC,GAAG,CAAC,MAAM,CAAuB,cAAc,UAAU,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;QAC9F,CAAC;KAAA;IAQK,GAAG,CAA2B,UAAkB,EAAE,QAAgB;;YACtE,OAAO,CAAC,MAAM,IAAI,CAAC,GAAG,CAAC,GAAG,CAAI,kBAAkB,UAAU,IAAI,QAAQ,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC;QAC5F,CAAC;KAAA;IAEK,KAAK;6DAAC,MAAgB,EAAE,UAAkB,EAAE,KAAa,EAAE,oBAAoB,GAAG,KAAK;YAC3F,MAAM,OAAO,GAAG;gBACd,UAAU,EAAE,UAAU;gBACtB,MAAM;gBACN,KAAK;gBACL,eAAe,EAAE,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;aAC9C,CAAC;YACF,OAAO,MAAM,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;QACpD,CAAC;KAAA;CACF;AAxDD,wCAwDC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const dotenv_1 = require("dotenv");
|
|
16
|
+
const jsdom_1 = require("jsdom");
|
|
17
|
+
const __1 = __importDefault(require("../"));
|
|
18
|
+
describe('api', () => {
|
|
19
|
+
beforeAll(() => {
|
|
20
|
+
(0, dotenv_1.configDotenv)({ path: '.env.test' });
|
|
21
|
+
const dom = new jsdom_1.JSDOM('<!DOCTYPE html><html><head></head><body></body></html>', {
|
|
22
|
+
url: `http://localhost?recordId=123&recordType=1&tokenId=${process.env.TEST_TOKEN_ID}`,
|
|
23
|
+
});
|
|
24
|
+
global.window = dom.window;
|
|
25
|
+
global.window.parent = dom.window;
|
|
26
|
+
global.document = dom.window.document;
|
|
27
|
+
global.window.location = dom.window.location;
|
|
28
|
+
});
|
|
29
|
+
it('should create a new record, get it, update it and delete it', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
30
|
+
const recordType = 1;
|
|
31
|
+
const fireberry = (0, __1.default)();
|
|
32
|
+
const newRecordData = {
|
|
33
|
+
accountname: `sdk Test ${new Date().toISOString()}`,
|
|
34
|
+
accountnumber: '123456',
|
|
35
|
+
};
|
|
36
|
+
const newRecordCreated = yield fireberry.api.create(recordType, newRecordData);
|
|
37
|
+
const id = newRecordCreated._id;
|
|
38
|
+
const fieldWithDefaultValue = newRecordCreated.pcfsystemfield106;
|
|
39
|
+
expect(newRecordCreated).toMatchObject(newRecordData);
|
|
40
|
+
expect(fieldWithDefaultValue).toBe('Default Test Value');
|
|
41
|
+
const newRecordRetrieved = yield fireberry.api.get(recordType, id);
|
|
42
|
+
expect(newRecordRetrieved).toMatchObject(newRecordData);
|
|
43
|
+
const updatePayload = {
|
|
44
|
+
telephone1: '050000000',
|
|
45
|
+
emailaddress1: 'example@email.com',
|
|
46
|
+
parentaccountid: 'B6B99205-112D-48F5-A6FA-4E8F649A1F14',
|
|
47
|
+
};
|
|
48
|
+
const updatedRecord = yield fireberry.api.update(recordType, id, updatePayload);
|
|
49
|
+
expect(updatedRecord).toMatchObject(Object.assign(Object.assign({}, newRecordData), updatePayload));
|
|
50
|
+
expect(updatedRecord._id).toBe(id);
|
|
51
|
+
yield fireberry.api.delete(recordType, id);
|
|
52
|
+
const deletedRecordRetrieved = yield fireberry.api.get(recordType, id);
|
|
53
|
+
expect(deletedRecordRetrieved).toBeNull();
|
|
54
|
+
}));
|
|
55
|
+
});
|
|
56
|
+
//# sourceMappingURL=fireberryV2Api.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fireberryV2Api.test.js","sourceRoot":"","sources":["../../src/fireberryAPI/fireberryV2Api.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,mCAAsC;AACtC,iCAA8B;AAC9B,4CAA+B;AAG/B,QAAQ,CAAC,KAAK,EAAE,GAAG,EAAE;IACnB,SAAS,CAAC,GAAG,EAAE;QACb,IAAA,qBAAY,EAAC,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC,CAAC;QACpC,MAAM,GAAG,GAAG,IAAI,aAAK,CAAC,wDAAwD,EAAE;YAC9E,GAAG,EAAE,sDAAsD,OAAO,CAAC,GAAG,CAAC,aAAa,EAAE;SACvF,CAAC,CAAC;QACH,MAAM,CAAC,MAAM,GAAG,GAAG,CAAC,MAAa,CAAC;QAClC,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,GAAG,CAAC,MAAa,CAAC;QACzC,MAAM,CAAC,QAAQ,GAAG,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC;QACtC,MAAM,CAAC,MAAM,CAAC,QAAQ,GAAG,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC;IAC/C,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,6DAA6D,EAAE,GAAS,EAAE;QAC3E,MAAM,UAAU,GAAG,CAAC,CAAC;QACrB,MAAM,SAAS,GAAG,IAAA,WAAY,GAAE,CAAC;QAEjC,MAAM,aAAa,GAAG;YACpB,WAAW,EAAE,YAAY,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,EAAE;YACnD,aAAa,EAAE,QAAQ;SACxB,CAAC;QAEF,MAAM,gBAAgB,GAAG,MAAM,SAAS,CAAC,GAAG,CAAC,MAAM,CAGjD,UAAU,EAAE,aAAa,CAAC,CAAC;QAE7B,MAAM,EAAE,GAAG,gBAAgB,CAAC,GAAG,CAAC;QAChC,MAAM,qBAAqB,GAAG,gBAAgB,CAAC,iBAAiB,CAAC;QAEjE,MAAM,CAAC,gBAAgB,CAAC,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC;QACtD,MAAM,CAAC,qBAAqB,CAAC,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;QAEzD,MAAM,kBAAkB,GAAG,MAAM,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;QACnE,MAAM,CAAC,kBAAkB,CAAC,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC;QAExD,MAAM,aAAa,GAAG;YACpB,UAAU,EAAE,WAAW;YACvB,aAAa,EAAE,mBAAmB;YAClC,eAAe,EAAE,sCAAsC;SACxD,CAAC;QAEF,MAAM,aAAa,GAAG,MAAM,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,UAAU,EAAE,EAAE,EAAE,aAAa,CAAC,CAAC;QAEhF,MAAM,CAAC,aAAa,CAAC,CAAC,aAAa,iCAAM,aAAa,GAAK,aAAa,EAAG,CAAC;QAC5E,MAAM,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAEnC,MAAM,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;QAE3C,MAAM,sBAAsB,GAAG,MAAM,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;QACvE,MAAM,CAAC,sBAAsB,CAAC,CAAC,QAAQ,EAAE,CAAC;IAC5C,CAAC,CAAA,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.FireberryV2Api = void 0;
|
|
18
|
+
var fireberryV2Api_1 = require("./fireberryV2Api");
|
|
19
|
+
Object.defineProperty(exports, "FireberryV2Api", { enumerable: true, get: function () { return fireberryV2Api_1.FireberryV2Api; } });
|
|
20
|
+
__exportStar(require("./types"), exports);
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/fireberryAPI/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,mDAAkD;AAAzC,gHAAA,cAAc,OAAA;AACvB,0CAAwB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/fireberryAPI/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FireberryClientSDK = void 0;
|
|
4
|
+
const base_fireberrySDK_1 = require("./base.fireberrySDK");
|
|
5
|
+
const context_1 = require("./context");
|
|
6
|
+
class FireberryClientSDK extends base_fireberrySDK_1.FireberrySDK {
|
|
7
|
+
constructor(api) {
|
|
8
|
+
super(api);
|
|
9
|
+
this.context = new context_1.Context(this.api);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
exports.FireberryClientSDK = FireberryClientSDK;
|
|
13
|
+
//# sourceMappingURL=fireberrySDK.client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fireberrySDK.client.js","sourceRoot":"","sources":["../src/fireberrySDK.client.ts"],"names":[],"mappings":";;;AAAA,2DAAmD;AACnD,uCAAoC;AAGpC,MAAa,kBAAmB,SAAQ,gCAAY;IAClD,YAAY,GAAmB;QAC7B,KAAK,CAAC,GAAG,CAAC,CAAC;QACX,IAAI,CAAC,OAAO,GAAG,IAAI,iBAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACvC,CAAC;CACF;AALD,gDAKC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FireberryServerSDK = void 0;
|
|
4
|
+
const base_fireberrySDK_1 = require("./base.fireberrySDK");
|
|
5
|
+
class FireberryServerSDK extends base_fireberrySDK_1.FireberrySDK {
|
|
6
|
+
constructor(api) {
|
|
7
|
+
super(api);
|
|
8
|
+
this.api = api;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
exports.FireberryServerSDK = FireberryServerSDK;
|
|
12
|
+
//# sourceMappingURL=fireberrySDK.server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fireberrySDK.server.js","sourceRoot":"","sources":["../src/fireberrySDK.server.ts"],"names":[],"mappings":";;;AAAA,2DAAmD;AAGnD,MAAa,kBAAmB,SAAQ,gCAAY;IAClD,YAAmB,GAAmB;QACpC,KAAK,CAAC,GAAG,CAAC,CAAC;QADM,QAAG,GAAH,GAAG,CAAgB;IAEtC,CAAC;CACF;AAJD,gDAIC"}
|