@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.
Files changed (258) hide show
  1. package/.eslintrc.json +36 -0
  2. package/.prettierrc.json +7 -0
  3. package/.vscode/settings.json +35 -0
  4. package/README.md +37 -0
  5. package/dist/base.fireberrySDK.d.ts +7 -0
  6. package/dist/base.fireberrySDK.js +10 -0
  7. package/dist/base.fireberrySDK.js.map +1 -0
  8. package/dist/context/context.d.ts +13 -0
  9. package/dist/context/context.js +22 -0
  10. package/dist/context/context.js.map +1 -0
  11. package/dist/context/context.record.test.d.ts +1 -0
  12. package/dist/context/context.record.test.js +45 -0
  13. package/dist/context/context.record.test.js.map +1 -0
  14. package/dist/context/index.d.ts +5 -0
  15. package/dist/context/index.js +18 -0
  16. package/dist/context/index.js.map +1 -0
  17. package/dist/context/record.d.ts +9 -0
  18. package/dist/context/record.js +33 -0
  19. package/dist/context/record.js.map +1 -0
  20. package/dist/context/user.d.ts +5 -0
  21. package/dist/context/user.js +27 -0
  22. package/dist/context/user.js.map +1 -0
  23. package/dist/fireberry.sdk.d.ts +4 -0
  24. package/dist/fireberry.sdk.js +13 -0
  25. package/dist/fireberry.sdk.js.map +1 -0
  26. package/dist/fireberryAPI/fireberryV2Api.d.ts +17 -0
  27. package/dist/fireberryAPI/fireberryV2Api.js +54 -0
  28. package/dist/fireberryAPI/fireberryV2Api.js.map +1 -0
  29. package/dist/fireberryAPI/fireberryV2Api.test.d.ts +1 -0
  30. package/dist/fireberryAPI/fireberryV2Api.test.js +56 -0
  31. package/dist/fireberryAPI/fireberryV2Api.test.js.map +1 -0
  32. package/dist/fireberryAPI/index.d.ts +2 -0
  33. package/dist/fireberryAPI/index.js +21 -0
  34. package/dist/fireberryAPI/index.js.map +1 -0
  35. package/dist/fireberryAPI/types.d.ts +10 -0
  36. package/dist/fireberryAPI/types.js +3 -0
  37. package/dist/fireberryAPI/types.js.map +1 -0
  38. package/dist/fireberrySDK.client.d.ts +5 -0
  39. package/dist/fireberrySDK.client.js +13 -0
  40. package/dist/fireberrySDK.client.js.map +1 -0
  41. package/dist/fireberrySDK.server.d.ts +6 -0
  42. package/dist/fireberrySDK.server.js +12 -0
  43. package/dist/fireberrySDK.server.js.map +1 -0
  44. package/dist/index.d.ts +6 -0
  45. package/dist/index.js +25 -0
  46. package/dist/index.js.map +1 -0
  47. package/dist/jest.config.d.ts +6 -0
  48. package/dist/jest.config.js +11 -0
  49. package/dist/src/context/context.d.ts +13 -0
  50. package/dist/src/context/context.js +21 -0
  51. package/dist/src/context/context.record.test.d.ts +1 -0
  52. package/dist/src/context/context.record.test.js +36 -0
  53. package/dist/src/context/index.d.ts +5 -0
  54. package/dist/src/context/index.js +17 -0
  55. package/dist/src/context/record.d.ts +9 -0
  56. package/dist/src/context/record.js +32 -0
  57. package/dist/src/context/user.d.ts +8 -0
  58. package/dist/src/context/user.js +31 -0
  59. package/dist/src/fireberry.sdk.d.ts +9 -0
  60. package/dist/src/fireberry.sdk.js +14 -0
  61. package/dist/src/fireberryAPI/fireberryV2Api.d.ts +14 -0
  62. package/dist/src/fireberryAPI/fireberryV2Api.js +41 -0
  63. package/dist/src/fireberryAPI/index.d.ts +2 -0
  64. package/dist/src/fireberryAPI/index.js +20 -0
  65. package/dist/src/fireberryAPI/types.d.ts +10 -0
  66. package/dist/src/fireberryAPI/types.js +2 -0
  67. package/dist/src/index.d.ts +9 -0
  68. package/dist/src/index.js +6 -0
  69. package/dist/src/utils/axios.util.d.ts +6 -0
  70. package/dist/src/utils/axios.util.js +24 -0
  71. package/dist/src/utils/index.d.ts +2 -0
  72. package/dist/src/utils/index.js +18 -0
  73. package/dist/src/utils/queryParam.util.d.ts +1 -0
  74. package/dist/src/utils/queryParam.util.js +10 -0
  75. package/dist/utils/axios.util.d.ts +6 -0
  76. package/dist/utils/axios.util.js +24 -0
  77. package/dist/utils/axios.util.js.map +1 -0
  78. package/dist/utils/index.d.ts +2 -0
  79. package/dist/utils/index.js +19 -0
  80. package/dist/utils/index.js.map +1 -0
  81. package/dist/utils/queryParam.util.d.ts +1 -0
  82. package/dist/utils/queryParam.util.js +12 -0
  83. package/dist/utils/queryParam.util.js.map +1 -0
  84. package/jest.config.ts +10 -0
  85. package/node_modules/asynckit/LICENSE +21 -0
  86. package/node_modules/asynckit/README.md +233 -0
  87. package/node_modules/asynckit/bench.js +76 -0
  88. package/node_modules/asynckit/index.js +6 -0
  89. package/node_modules/asynckit/lib/abort.js +29 -0
  90. package/node_modules/asynckit/lib/async.js +34 -0
  91. package/node_modules/asynckit/lib/defer.js +26 -0
  92. package/node_modules/asynckit/lib/iterate.js +75 -0
  93. package/node_modules/asynckit/lib/readable_asynckit.js +91 -0
  94. package/node_modules/asynckit/lib/readable_parallel.js +25 -0
  95. package/node_modules/asynckit/lib/readable_serial.js +25 -0
  96. package/node_modules/asynckit/lib/readable_serial_ordered.js +29 -0
  97. package/node_modules/asynckit/lib/state.js +37 -0
  98. package/node_modules/asynckit/lib/streamify.js +141 -0
  99. package/node_modules/asynckit/lib/terminator.js +29 -0
  100. package/node_modules/asynckit/package.json +63 -0
  101. package/node_modules/asynckit/parallel.js +43 -0
  102. package/node_modules/asynckit/serial.js +17 -0
  103. package/node_modules/asynckit/serialOrdered.js +75 -0
  104. package/node_modules/asynckit/stream.js +21 -0
  105. package/node_modules/axios/CHANGELOG.md +874 -0
  106. package/node_modules/axios/LICENSE +7 -0
  107. package/node_modules/axios/MIGRATION_GUIDE.md +3 -0
  108. package/node_modules/axios/README.md +1650 -0
  109. package/node_modules/axios/SECURITY.md +6 -0
  110. package/node_modules/axios/dist/axios.js +3448 -0
  111. package/node_modules/axios/dist/axios.js.map +1 -0
  112. package/node_modules/axios/dist/axios.min.js +2 -0
  113. package/node_modules/axios/dist/axios.min.js.map +1 -0
  114. package/node_modules/axios/dist/browser/axios.cjs +3258 -0
  115. package/node_modules/axios/dist/browser/axios.cjs.map +1 -0
  116. package/node_modules/axios/dist/esm/axios.js +3281 -0
  117. package/node_modules/axios/dist/esm/axios.js.map +1 -0
  118. package/node_modules/axios/dist/esm/axios.min.js +2 -0
  119. package/node_modules/axios/dist/esm/axios.min.js.map +1 -0
  120. package/node_modules/axios/dist/node/axios.cjs +4354 -0
  121. package/node_modules/axios/dist/node/axios.cjs.map +1 -0
  122. package/node_modules/axios/index.d.cts +542 -0
  123. package/node_modules/axios/index.d.ts +559 -0
  124. package/node_modules/axios/index.js +43 -0
  125. package/node_modules/axios/lib/adapters/README.md +37 -0
  126. package/node_modules/axios/lib/adapters/adapters.js +77 -0
  127. package/node_modules/axios/lib/adapters/http.js +685 -0
  128. package/node_modules/axios/lib/adapters/xhr.js +260 -0
  129. package/node_modules/axios/lib/axios.js +89 -0
  130. package/node_modules/axios/lib/cancel/CancelToken.js +121 -0
  131. package/node_modules/axios/lib/cancel/CanceledError.js +25 -0
  132. package/node_modules/axios/lib/cancel/isCancel.js +5 -0
  133. package/node_modules/axios/lib/core/Axios.js +225 -0
  134. package/node_modules/axios/lib/core/AxiosError.js +100 -0
  135. package/node_modules/axios/lib/core/AxiosHeaders.js +298 -0
  136. package/node_modules/axios/lib/core/InterceptorManager.js +71 -0
  137. package/node_modules/axios/lib/core/README.md +8 -0
  138. package/node_modules/axios/lib/core/buildFullPath.js +21 -0
  139. package/node_modules/axios/lib/core/dispatchRequest.js +81 -0
  140. package/node_modules/axios/lib/core/mergeConfig.js +106 -0
  141. package/node_modules/axios/lib/core/settle.js +27 -0
  142. package/node_modules/axios/lib/core/transformData.js +28 -0
  143. package/node_modules/axios/lib/defaults/index.js +156 -0
  144. package/node_modules/axios/lib/defaults/transitional.js +7 -0
  145. package/node_modules/axios/lib/env/README.md +3 -0
  146. package/node_modules/axios/lib/env/classes/FormData.js +2 -0
  147. package/node_modules/axios/lib/env/data.js +1 -0
  148. package/node_modules/axios/lib/helpers/AxiosTransformStream.js +191 -0
  149. package/node_modules/axios/lib/helpers/AxiosURLSearchParams.js +58 -0
  150. package/node_modules/axios/lib/helpers/HttpStatusCode.js +71 -0
  151. package/node_modules/axios/lib/helpers/README.md +7 -0
  152. package/node_modules/axios/lib/helpers/ZlibHeaderTransformStream.js +28 -0
  153. package/node_modules/axios/lib/helpers/bind.js +7 -0
  154. package/node_modules/axios/lib/helpers/buildURL.js +63 -0
  155. package/node_modules/axios/lib/helpers/callbackify.js +16 -0
  156. package/node_modules/axios/lib/helpers/combineURLs.js +15 -0
  157. package/node_modules/axios/lib/helpers/cookies.js +42 -0
  158. package/node_modules/axios/lib/helpers/deprecatedMethod.js +26 -0
  159. package/node_modules/axios/lib/helpers/formDataToJSON.js +95 -0
  160. package/node_modules/axios/lib/helpers/formDataToStream.js +111 -0
  161. package/node_modules/axios/lib/helpers/fromDataURI.js +53 -0
  162. package/node_modules/axios/lib/helpers/isAbsoluteURL.js +15 -0
  163. package/node_modules/axios/lib/helpers/isAxiosError.js +14 -0
  164. package/node_modules/axios/lib/helpers/isURLSameOrigin.js +67 -0
  165. package/node_modules/axios/lib/helpers/null.js +2 -0
  166. package/node_modules/axios/lib/helpers/parseHeaders.js +55 -0
  167. package/node_modules/axios/lib/helpers/parseProtocol.js +6 -0
  168. package/node_modules/axios/lib/helpers/readBlob.js +15 -0
  169. package/node_modules/axios/lib/helpers/speedometer.js +55 -0
  170. package/node_modules/axios/lib/helpers/spread.js +28 -0
  171. package/node_modules/axios/lib/helpers/throttle.js +33 -0
  172. package/node_modules/axios/lib/helpers/toFormData.js +219 -0
  173. package/node_modules/axios/lib/helpers/toURLEncodedForm.js +18 -0
  174. package/node_modules/axios/lib/helpers/validator.js +91 -0
  175. package/node_modules/axios/lib/platform/browser/classes/Blob.js +3 -0
  176. package/node_modules/axios/lib/platform/browser/classes/FormData.js +3 -0
  177. package/node_modules/axios/lib/platform/browser/classes/URLSearchParams.js +4 -0
  178. package/node_modules/axios/lib/platform/browser/index.js +13 -0
  179. package/node_modules/axios/lib/platform/common/utils.js +47 -0
  180. package/node_modules/axios/lib/platform/index.js +7 -0
  181. package/node_modules/axios/lib/platform/node/classes/FormData.js +3 -0
  182. package/node_modules/axios/lib/platform/node/classes/URLSearchParams.js +4 -0
  183. package/node_modules/axios/lib/platform/node/index.js +12 -0
  184. package/node_modules/axios/lib/utils.js +723 -0
  185. package/node_modules/axios/package.json +218 -0
  186. package/node_modules/combined-stream/License +19 -0
  187. package/node_modules/combined-stream/Readme.md +138 -0
  188. package/node_modules/combined-stream/lib/combined_stream.js +208 -0
  189. package/node_modules/combined-stream/package.json +25 -0
  190. package/node_modules/delayed-stream/.npmignore +1 -0
  191. package/node_modules/delayed-stream/License +19 -0
  192. package/node_modules/delayed-stream/Makefile +7 -0
  193. package/node_modules/delayed-stream/Readme.md +141 -0
  194. package/node_modules/delayed-stream/lib/delayed_stream.js +107 -0
  195. package/node_modules/delayed-stream/package.json +27 -0
  196. package/node_modules/dotenv/CHANGELOG.md +475 -0
  197. package/node_modules/dotenv/LICENSE +23 -0
  198. package/node_modules/dotenv/README-es.md +448 -0
  199. package/node_modules/dotenv/README.md +728 -0
  200. package/node_modules/dotenv/config.d.ts +1 -0
  201. package/node_modules/dotenv/config.js +9 -0
  202. package/node_modules/dotenv/lib/cli-options.js +11 -0
  203. package/node_modules/dotenv/lib/env-options.js +24 -0
  204. package/node_modules/dotenv/lib/main.d.ts +153 -0
  205. package/node_modules/dotenv/lib/main.js +361 -0
  206. package/node_modules/dotenv/package.json +65 -0
  207. package/node_modules/follow-redirects/LICENSE +18 -0
  208. package/node_modules/follow-redirects/README.md +155 -0
  209. package/node_modules/follow-redirects/debug.js +15 -0
  210. package/node_modules/follow-redirects/http.js +1 -0
  211. package/node_modules/follow-redirects/https.js +1 -0
  212. package/node_modules/follow-redirects/index.js +672 -0
  213. package/node_modules/follow-redirects/package.json +58 -0
  214. package/node_modules/form-data/License +19 -0
  215. package/node_modules/form-data/README.md.bak +358 -0
  216. package/node_modules/form-data/Readme.md +358 -0
  217. package/node_modules/form-data/index.d.ts +62 -0
  218. package/node_modules/form-data/lib/browser.js +2 -0
  219. package/node_modules/form-data/lib/form_data.js +501 -0
  220. package/node_modules/form-data/lib/populate.js +10 -0
  221. package/node_modules/form-data/package.json +68 -0
  222. package/node_modules/mime-db/HISTORY.md +507 -0
  223. package/node_modules/mime-db/LICENSE +23 -0
  224. package/node_modules/mime-db/README.md +100 -0
  225. package/node_modules/mime-db/db.json +8519 -0
  226. package/node_modules/mime-db/index.js +12 -0
  227. package/node_modules/mime-db/package.json +60 -0
  228. package/node_modules/mime-types/HISTORY.md +397 -0
  229. package/node_modules/mime-types/LICENSE +23 -0
  230. package/node_modules/mime-types/README.md +113 -0
  231. package/node_modules/mime-types/index.js +188 -0
  232. package/node_modules/mime-types/package.json +44 -0
  233. package/node_modules/proxy-from-env/.eslintrc +29 -0
  234. package/node_modules/proxy-from-env/.travis.yml +10 -0
  235. package/node_modules/proxy-from-env/LICENSE +20 -0
  236. package/node_modules/proxy-from-env/README.md +131 -0
  237. package/node_modules/proxy-from-env/index.js +108 -0
  238. package/node_modules/proxy-from-env/package.json +34 -0
  239. package/node_modules/proxy-from-env/test.js +483 -0
  240. package/package.json +48 -0
  241. package/src/base.fireberrySDK.ts +7 -0
  242. package/src/context/context.record.test.ts +47 -0
  243. package/src/context/context.ts +28 -0
  244. package/src/context/index.ts +6 -0
  245. package/src/context/record.ts +22 -0
  246. package/src/context/user.ts +15 -0
  247. package/src/fireberry.sdk.ts +14 -0
  248. package/src/fireberryAPI/fireberryV2Api.test.ts +57 -0
  249. package/src/fireberryAPI/fireberryV2Api.ts +61 -0
  250. package/src/fireberryAPI/index.ts +2 -0
  251. package/src/fireberryAPI/types.ts +10 -0
  252. package/src/fireberrySDK.client.ts +10 -0
  253. package/src/fireberrySDK.server.ts +8 -0
  254. package/src/index.ts +9 -0
  255. package/src/utils/axios.util.ts +20 -0
  256. package/src/utils/index.ts +2 -0
  257. package/src/utils/queryParam.util.ts +8 -0
  258. 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
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "printWidth": 100,
3
+ "tabWidth": 2,
4
+ "singleQuote": true,
5
+ "jsxBracketSameLine": true,
6
+ "trailingComma": "es5"
7
+ }
@@ -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,7 @@
1
+ import { Context } from './context';
2
+ import { FireberryV2Api } from './fireberryAPI';
3
+ export declare abstract class FireberrySDK {
4
+ api: FireberryV2Api;
5
+ context?: Context;
6
+ constructor(api: FireberryV2Api);
7
+ }
@@ -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,5 @@
1
+ export * from './context';
2
+ export type CurrentRecordDetails = Partial<{
3
+ recordType: number;
4
+ recordId: string;
5
+ }>;
@@ -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,5 @@
1
+ export declare class UserContext {
2
+ constructor();
3
+ get(_fieldName: string): Promise<void>;
4
+ all(): Promise<void>;
5
+ }
@@ -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,4 @@
1
+ import { FireberryClientSDK } from './fireberrySDK.client';
2
+ import { FireberryServerSDK } from './fireberrySDK.server';
3
+ declare const _default: () => FireberryClientSDK | FireberryServerSDK;
4
+ export default _default;
@@ -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,2 @@
1
+ export { FireberryV2Api } from './fireberryV2Api';
2
+ export * from './types';
@@ -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,10 @@
1
+ export type BusinessObject = {
2
+ createdBy: string;
3
+ createdByName: string;
4
+ createdOn: Date;
5
+ ownerId: string;
6
+ ownerName: string;
7
+ modifiedBy: string;
8
+ modifiedByName: string;
9
+ modifiedOn: Date;
10
+ };
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/fireberryAPI/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,5 @@
1
+ import { FireberrySDK } from './base.fireberrySDK';
2
+ import { FireberryV2Api } from './fireberryAPI';
3
+ export declare class FireberryClientSDK extends FireberrySDK {
4
+ constructor(api: FireberryV2Api);
5
+ }
@@ -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,6 @@
1
+ import { FireberrySDK } from './base.fireberrySDK';
2
+ import { FireberryV2Api } from './fireberryAPI';
3
+ export declare class FireberryServerSDK extends FireberrySDK {
4
+ api: FireberryV2Api;
5
+ constructor(api: FireberryV2Api);
6
+ }
@@ -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"}