@fireberry/sdk 0.0.3 → 0.0.5

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 (304) hide show
  1. package/{node_modules/asynckit/LICENSE → LICENSE.md} +2 -2
  2. package/README.md +85 -37
  3. package/dist/cjs/constants/index.d.ts +13 -0
  4. package/dist/cjs/constants/index.d.ts.map +1 -0
  5. package/dist/cjs/constants/index.js +16 -0
  6. package/dist/cjs/constants/index.js.map +1 -0
  7. package/dist/cjs/context/context.d.ts +7 -0
  8. package/dist/cjs/context/context.d.ts.map +1 -0
  9. package/dist/cjs/context/context.js +11 -0
  10. package/dist/cjs/context/context.js.map +1 -0
  11. package/dist/cjs/context/index.d.ts +2 -0
  12. package/dist/cjs/context/index.d.ts.map +1 -0
  13. package/dist/cjs/context/index.js.map +1 -0
  14. package/dist/cjs/fireberrySDK.client.d.ts +18 -0
  15. package/dist/cjs/fireberrySDK.client.d.ts.map +1 -0
  16. package/dist/cjs/fireberrySDK.client.js +66 -0
  17. package/dist/cjs/fireberrySDK.client.js.map +1 -0
  18. package/dist/cjs/iframeMessageManager.d.ts +12 -0
  19. package/dist/cjs/iframeMessageManager.d.ts.map +1 -0
  20. package/dist/cjs/iframeMessageManager.js +68 -0
  21. package/dist/cjs/iframeMessageManager.js.map +1 -0
  22. package/dist/cjs/types/index.d.ts +67 -0
  23. package/dist/cjs/types/index.d.ts.map +1 -0
  24. package/dist/{src/fireberryAPI/types.js → cjs/types/index.js} +1 -0
  25. package/dist/cjs/types/index.js.map +1 -0
  26. package/dist/esm/constants/index.d.ts +13 -0
  27. package/dist/esm/constants/index.d.ts.map +1 -0
  28. package/dist/esm/constants/index.js +13 -0
  29. package/dist/esm/constants/index.js.map +1 -0
  30. package/dist/esm/context/context.d.ts +7 -0
  31. package/dist/esm/context/context.d.ts.map +1 -0
  32. package/dist/esm/context/context.js +7 -0
  33. package/dist/esm/context/context.js.map +1 -0
  34. package/dist/esm/context/index.d.ts +2 -0
  35. package/dist/esm/context/index.d.ts.map +1 -0
  36. package/dist/esm/context/index.js +2 -0
  37. package/dist/esm/context/index.js.map +1 -0
  38. package/dist/esm/fireberrySDK.client.d.ts +18 -0
  39. package/dist/esm/fireberrySDK.client.d.ts.map +1 -0
  40. package/dist/esm/fireberrySDK.client.js +62 -0
  41. package/dist/esm/fireberrySDK.client.js.map +1 -0
  42. package/dist/esm/iframeMessageManager.d.ts +12 -0
  43. package/dist/esm/iframeMessageManager.d.ts.map +1 -0
  44. package/dist/esm/iframeMessageManager.js +64 -0
  45. package/dist/esm/iframeMessageManager.js.map +1 -0
  46. package/dist/esm/types/index.d.ts +67 -0
  47. package/dist/esm/types/index.d.ts.map +1 -0
  48. package/dist/esm/types/index.js +2 -0
  49. package/dist/esm/types/index.js.map +1 -0
  50. package/package.json +51 -28
  51. package/.eslintrc.json +0 -36
  52. package/.prettierrc.json +0 -7
  53. package/.vscode/settings.json +0 -35
  54. package/dist/base.fireberrySDK.d.ts +0 -7
  55. package/dist/base.fireberrySDK.js +0 -10
  56. package/dist/base.fireberrySDK.js.map +0 -1
  57. package/dist/context/context.d.ts +0 -13
  58. package/dist/context/context.js +0 -22
  59. package/dist/context/context.js.map +0 -1
  60. package/dist/context/context.record.test.d.ts +0 -1
  61. package/dist/context/context.record.test.js +0 -45
  62. package/dist/context/context.record.test.js.map +0 -1
  63. package/dist/context/index.d.ts +0 -5
  64. package/dist/context/index.js.map +0 -1
  65. package/dist/context/record.d.ts +0 -9
  66. package/dist/context/record.js +0 -33
  67. package/dist/context/record.js.map +0 -1
  68. package/dist/context/user.d.ts +0 -5
  69. package/dist/context/user.js +0 -27
  70. package/dist/context/user.js.map +0 -1
  71. package/dist/fireberry.sdk.d.ts +0 -4
  72. package/dist/fireberry.sdk.js +0 -13
  73. package/dist/fireberry.sdk.js.map +0 -1
  74. package/dist/fireberryAPI/fireberryV2Api.d.ts +0 -17
  75. package/dist/fireberryAPI/fireberryV2Api.js +0 -54
  76. package/dist/fireberryAPI/fireberryV2Api.js.map +0 -1
  77. package/dist/fireberryAPI/fireberryV2Api.test.d.ts +0 -1
  78. package/dist/fireberryAPI/fireberryV2Api.test.js +0 -56
  79. package/dist/fireberryAPI/fireberryV2Api.test.js.map +0 -1
  80. package/dist/fireberryAPI/index.d.ts +0 -2
  81. package/dist/fireberryAPI/index.js +0 -21
  82. package/dist/fireberryAPI/index.js.map +0 -1
  83. package/dist/fireberryAPI/types.d.ts +0 -10
  84. package/dist/fireberryAPI/types.js +0 -3
  85. package/dist/fireberryAPI/types.js.map +0 -1
  86. package/dist/fireberrySDK.client.d.ts +0 -5
  87. package/dist/fireberrySDK.client.js +0 -13
  88. package/dist/fireberrySDK.client.js.map +0 -1
  89. package/dist/fireberrySDK.server.d.ts +0 -6
  90. package/dist/fireberrySDK.server.js +0 -12
  91. package/dist/fireberrySDK.server.js.map +0 -1
  92. package/dist/index.d.ts +0 -6
  93. package/dist/index.js +0 -25
  94. package/dist/index.js.map +0 -1
  95. package/dist/jest.config.d.ts +0 -6
  96. package/dist/jest.config.js +0 -11
  97. package/dist/src/context/context.d.ts +0 -13
  98. package/dist/src/context/context.js +0 -21
  99. package/dist/src/context/context.record.test.d.ts +0 -1
  100. package/dist/src/context/context.record.test.js +0 -36
  101. package/dist/src/context/index.d.ts +0 -5
  102. package/dist/src/context/index.js +0 -17
  103. package/dist/src/context/record.d.ts +0 -9
  104. package/dist/src/context/record.js +0 -32
  105. package/dist/src/context/user.d.ts +0 -8
  106. package/dist/src/context/user.js +0 -31
  107. package/dist/src/fireberry.sdk.d.ts +0 -9
  108. package/dist/src/fireberry.sdk.js +0 -14
  109. package/dist/src/fireberryAPI/fireberryV2Api.d.ts +0 -14
  110. package/dist/src/fireberryAPI/fireberryV2Api.js +0 -41
  111. package/dist/src/fireberryAPI/index.d.ts +0 -2
  112. package/dist/src/fireberryAPI/index.js +0 -20
  113. package/dist/src/fireberryAPI/types.d.ts +0 -10
  114. package/dist/src/index.d.ts +0 -9
  115. package/dist/src/index.js +0 -6
  116. package/dist/src/utils/axios.util.d.ts +0 -6
  117. package/dist/src/utils/axios.util.js +0 -24
  118. package/dist/src/utils/index.d.ts +0 -2
  119. package/dist/src/utils/index.js +0 -18
  120. package/dist/src/utils/queryParam.util.d.ts +0 -1
  121. package/dist/src/utils/queryParam.util.js +0 -10
  122. package/dist/utils/axios.util.d.ts +0 -6
  123. package/dist/utils/axios.util.js +0 -24
  124. package/dist/utils/axios.util.js.map +0 -1
  125. package/dist/utils/index.d.ts +0 -2
  126. package/dist/utils/index.js +0 -19
  127. package/dist/utils/index.js.map +0 -1
  128. package/dist/utils/queryParam.util.d.ts +0 -1
  129. package/dist/utils/queryParam.util.js +0 -12
  130. package/dist/utils/queryParam.util.js.map +0 -1
  131. package/jest.config.ts +0 -10
  132. package/node_modules/asynckit/README.md +0 -233
  133. package/node_modules/asynckit/bench.js +0 -76
  134. package/node_modules/asynckit/index.js +0 -6
  135. package/node_modules/asynckit/lib/abort.js +0 -29
  136. package/node_modules/asynckit/lib/async.js +0 -34
  137. package/node_modules/asynckit/lib/defer.js +0 -26
  138. package/node_modules/asynckit/lib/iterate.js +0 -75
  139. package/node_modules/asynckit/lib/readable_asynckit.js +0 -91
  140. package/node_modules/asynckit/lib/readable_parallel.js +0 -25
  141. package/node_modules/asynckit/lib/readable_serial.js +0 -25
  142. package/node_modules/asynckit/lib/readable_serial_ordered.js +0 -29
  143. package/node_modules/asynckit/lib/state.js +0 -37
  144. package/node_modules/asynckit/lib/streamify.js +0 -141
  145. package/node_modules/asynckit/lib/terminator.js +0 -29
  146. package/node_modules/asynckit/package.json +0 -63
  147. package/node_modules/asynckit/parallel.js +0 -43
  148. package/node_modules/asynckit/serial.js +0 -17
  149. package/node_modules/asynckit/serialOrdered.js +0 -75
  150. package/node_modules/asynckit/stream.js +0 -21
  151. package/node_modules/axios/CHANGELOG.md +0 -874
  152. package/node_modules/axios/LICENSE +0 -7
  153. package/node_modules/axios/MIGRATION_GUIDE.md +0 -3
  154. package/node_modules/axios/README.md +0 -1650
  155. package/node_modules/axios/SECURITY.md +0 -6
  156. package/node_modules/axios/dist/axios.js +0 -3448
  157. package/node_modules/axios/dist/axios.js.map +0 -1
  158. package/node_modules/axios/dist/axios.min.js +0 -2
  159. package/node_modules/axios/dist/axios.min.js.map +0 -1
  160. package/node_modules/axios/dist/browser/axios.cjs +0 -3258
  161. package/node_modules/axios/dist/browser/axios.cjs.map +0 -1
  162. package/node_modules/axios/dist/esm/axios.js +0 -3281
  163. package/node_modules/axios/dist/esm/axios.js.map +0 -1
  164. package/node_modules/axios/dist/esm/axios.min.js +0 -2
  165. package/node_modules/axios/dist/esm/axios.min.js.map +0 -1
  166. package/node_modules/axios/dist/node/axios.cjs +0 -4354
  167. package/node_modules/axios/dist/node/axios.cjs.map +0 -1
  168. package/node_modules/axios/index.d.cts +0 -542
  169. package/node_modules/axios/index.d.ts +0 -559
  170. package/node_modules/axios/index.js +0 -43
  171. package/node_modules/axios/lib/adapters/README.md +0 -37
  172. package/node_modules/axios/lib/adapters/adapters.js +0 -77
  173. package/node_modules/axios/lib/adapters/http.js +0 -685
  174. package/node_modules/axios/lib/adapters/xhr.js +0 -260
  175. package/node_modules/axios/lib/axios.js +0 -89
  176. package/node_modules/axios/lib/cancel/CancelToken.js +0 -121
  177. package/node_modules/axios/lib/cancel/CanceledError.js +0 -25
  178. package/node_modules/axios/lib/cancel/isCancel.js +0 -5
  179. package/node_modules/axios/lib/core/Axios.js +0 -225
  180. package/node_modules/axios/lib/core/AxiosError.js +0 -100
  181. package/node_modules/axios/lib/core/AxiosHeaders.js +0 -298
  182. package/node_modules/axios/lib/core/InterceptorManager.js +0 -71
  183. package/node_modules/axios/lib/core/README.md +0 -8
  184. package/node_modules/axios/lib/core/buildFullPath.js +0 -21
  185. package/node_modules/axios/lib/core/dispatchRequest.js +0 -81
  186. package/node_modules/axios/lib/core/mergeConfig.js +0 -106
  187. package/node_modules/axios/lib/core/settle.js +0 -27
  188. package/node_modules/axios/lib/core/transformData.js +0 -28
  189. package/node_modules/axios/lib/defaults/index.js +0 -156
  190. package/node_modules/axios/lib/defaults/transitional.js +0 -7
  191. package/node_modules/axios/lib/env/README.md +0 -3
  192. package/node_modules/axios/lib/env/classes/FormData.js +0 -2
  193. package/node_modules/axios/lib/env/data.js +0 -1
  194. package/node_modules/axios/lib/helpers/AxiosTransformStream.js +0 -191
  195. package/node_modules/axios/lib/helpers/AxiosURLSearchParams.js +0 -58
  196. package/node_modules/axios/lib/helpers/HttpStatusCode.js +0 -71
  197. package/node_modules/axios/lib/helpers/README.md +0 -7
  198. package/node_modules/axios/lib/helpers/ZlibHeaderTransformStream.js +0 -28
  199. package/node_modules/axios/lib/helpers/bind.js +0 -7
  200. package/node_modules/axios/lib/helpers/buildURL.js +0 -63
  201. package/node_modules/axios/lib/helpers/callbackify.js +0 -16
  202. package/node_modules/axios/lib/helpers/combineURLs.js +0 -15
  203. package/node_modules/axios/lib/helpers/cookies.js +0 -42
  204. package/node_modules/axios/lib/helpers/deprecatedMethod.js +0 -26
  205. package/node_modules/axios/lib/helpers/formDataToJSON.js +0 -95
  206. package/node_modules/axios/lib/helpers/formDataToStream.js +0 -111
  207. package/node_modules/axios/lib/helpers/fromDataURI.js +0 -53
  208. package/node_modules/axios/lib/helpers/isAbsoluteURL.js +0 -15
  209. package/node_modules/axios/lib/helpers/isAxiosError.js +0 -14
  210. package/node_modules/axios/lib/helpers/isURLSameOrigin.js +0 -67
  211. package/node_modules/axios/lib/helpers/null.js +0 -2
  212. package/node_modules/axios/lib/helpers/parseHeaders.js +0 -55
  213. package/node_modules/axios/lib/helpers/parseProtocol.js +0 -6
  214. package/node_modules/axios/lib/helpers/readBlob.js +0 -15
  215. package/node_modules/axios/lib/helpers/speedometer.js +0 -55
  216. package/node_modules/axios/lib/helpers/spread.js +0 -28
  217. package/node_modules/axios/lib/helpers/throttle.js +0 -33
  218. package/node_modules/axios/lib/helpers/toFormData.js +0 -219
  219. package/node_modules/axios/lib/helpers/toURLEncodedForm.js +0 -18
  220. package/node_modules/axios/lib/helpers/validator.js +0 -91
  221. package/node_modules/axios/lib/platform/browser/classes/Blob.js +0 -3
  222. package/node_modules/axios/lib/platform/browser/classes/FormData.js +0 -3
  223. package/node_modules/axios/lib/platform/browser/classes/URLSearchParams.js +0 -4
  224. package/node_modules/axios/lib/platform/browser/index.js +0 -13
  225. package/node_modules/axios/lib/platform/common/utils.js +0 -47
  226. package/node_modules/axios/lib/platform/index.js +0 -7
  227. package/node_modules/axios/lib/platform/node/classes/FormData.js +0 -3
  228. package/node_modules/axios/lib/platform/node/classes/URLSearchParams.js +0 -4
  229. package/node_modules/axios/lib/platform/node/index.js +0 -12
  230. package/node_modules/axios/lib/utils.js +0 -723
  231. package/node_modules/axios/package.json +0 -218
  232. package/node_modules/combined-stream/License +0 -19
  233. package/node_modules/combined-stream/Readme.md +0 -138
  234. package/node_modules/combined-stream/lib/combined_stream.js +0 -208
  235. package/node_modules/combined-stream/package.json +0 -25
  236. package/node_modules/delayed-stream/.npmignore +0 -1
  237. package/node_modules/delayed-stream/License +0 -19
  238. package/node_modules/delayed-stream/Makefile +0 -7
  239. package/node_modules/delayed-stream/Readme.md +0 -141
  240. package/node_modules/delayed-stream/lib/delayed_stream.js +0 -107
  241. package/node_modules/delayed-stream/package.json +0 -27
  242. package/node_modules/dotenv/CHANGELOG.md +0 -475
  243. package/node_modules/dotenv/LICENSE +0 -23
  244. package/node_modules/dotenv/README-es.md +0 -448
  245. package/node_modules/dotenv/README.md +0 -728
  246. package/node_modules/dotenv/config.d.ts +0 -1
  247. package/node_modules/dotenv/config.js +0 -9
  248. package/node_modules/dotenv/lib/cli-options.js +0 -11
  249. package/node_modules/dotenv/lib/env-options.js +0 -24
  250. package/node_modules/dotenv/lib/main.d.ts +0 -153
  251. package/node_modules/dotenv/lib/main.js +0 -361
  252. package/node_modules/dotenv/package.json +0 -65
  253. package/node_modules/follow-redirects/LICENSE +0 -18
  254. package/node_modules/follow-redirects/README.md +0 -155
  255. package/node_modules/follow-redirects/debug.js +0 -15
  256. package/node_modules/follow-redirects/http.js +0 -1
  257. package/node_modules/follow-redirects/https.js +0 -1
  258. package/node_modules/follow-redirects/index.js +0 -672
  259. package/node_modules/follow-redirects/package.json +0 -58
  260. package/node_modules/form-data/License +0 -19
  261. package/node_modules/form-data/README.md.bak +0 -358
  262. package/node_modules/form-data/Readme.md +0 -358
  263. package/node_modules/form-data/index.d.ts +0 -62
  264. package/node_modules/form-data/lib/browser.js +0 -2
  265. package/node_modules/form-data/lib/form_data.js +0 -501
  266. package/node_modules/form-data/lib/populate.js +0 -10
  267. package/node_modules/form-data/package.json +0 -68
  268. package/node_modules/mime-db/HISTORY.md +0 -507
  269. package/node_modules/mime-db/LICENSE +0 -23
  270. package/node_modules/mime-db/README.md +0 -100
  271. package/node_modules/mime-db/db.json +0 -8519
  272. package/node_modules/mime-db/index.js +0 -12
  273. package/node_modules/mime-db/package.json +0 -60
  274. package/node_modules/mime-types/HISTORY.md +0 -397
  275. package/node_modules/mime-types/LICENSE +0 -23
  276. package/node_modules/mime-types/README.md +0 -113
  277. package/node_modules/mime-types/index.js +0 -188
  278. package/node_modules/mime-types/package.json +0 -44
  279. package/node_modules/proxy-from-env/.eslintrc +0 -29
  280. package/node_modules/proxy-from-env/.travis.yml +0 -10
  281. package/node_modules/proxy-from-env/LICENSE +0 -20
  282. package/node_modules/proxy-from-env/README.md +0 -131
  283. package/node_modules/proxy-from-env/index.js +0 -108
  284. package/node_modules/proxy-from-env/package.json +0 -34
  285. package/node_modules/proxy-from-env/test.js +0 -483
  286. package/src/base.fireberrySDK.ts +0 -7
  287. package/src/context/context.record.test.ts +0 -47
  288. package/src/context/context.ts +0 -28
  289. package/src/context/index.ts +0 -6
  290. package/src/context/record.ts +0 -22
  291. package/src/context/user.ts +0 -15
  292. package/src/fireberry.sdk.ts +0 -14
  293. package/src/fireberryAPI/fireberryV2Api.test.ts +0 -57
  294. package/src/fireberryAPI/fireberryV2Api.ts +0 -61
  295. package/src/fireberryAPI/index.ts +0 -2
  296. package/src/fireberryAPI/types.ts +0 -10
  297. package/src/fireberrySDK.client.ts +0 -10
  298. package/src/fireberrySDK.server.ts +0 -8
  299. package/src/index.ts +0 -9
  300. package/src/utils/axios.util.ts +0 -20
  301. package/src/utils/index.ts +0 -2
  302. package/src/utils/queryParam.util.ts +0 -8
  303. package/tsconfig.json +0 -123
  304. /package/dist/{context → cjs/context}/index.js +0 -0
@@ -0,0 +1,62 @@
1
+ import { MESSAGE_TYPES, REQUEST_ACTIONS } from './constants';
2
+ import { Context } from './context';
3
+ import { IframeMessageManager } from './iframeMessageManager';
4
+ export class FireberryClientSDK extends IframeMessageManager {
5
+ constructor() {
6
+ super();
7
+ this._context = null;
8
+ }
9
+ get api() {
10
+ return {
11
+ query: this.query.bind(this),
12
+ create: this.create.bind(this),
13
+ delete: this.delete.bind(this),
14
+ update: this.update.bind(this),
15
+ };
16
+ }
17
+ get context() {
18
+ return this._context;
19
+ }
20
+ async initializeContext() {
21
+ var _a, _b, _c;
22
+ if (this.context) {
23
+ return this;
24
+ }
25
+ const response = await this.sendMessageWithPromise({
26
+ type: MESSAGE_TYPES.REQUEST_CONTEXT,
27
+ });
28
+ const { status, data, statusText } = (_a = response === null || response === void 0 ? void 0 : response.error) !== null && _a !== void 0 ? _a : {};
29
+ if (status && status !== 200) {
30
+ throw new Error((_b = data === null || data === void 0 ? void 0 : data.Message) !== null && _b !== void 0 ? _b : statusText);
31
+ }
32
+ const { recordId, objectType, userInfo } = (_c = response.data) !== null && _c !== void 0 ? _c : {};
33
+ this.setContext(new Context({
34
+ record: { id: recordId, type: objectType },
35
+ user: { fullName: userInfo.fullName, id: userInfo.id },
36
+ }));
37
+ return this;
38
+ }
39
+ setContext(context) {
40
+ this._context = context;
41
+ }
42
+ query(objectType, payload) {
43
+ return this.sendMessageWithPromise(Object.assign({ type: MESSAGE_TYPES.REQUEST, action: REQUEST_ACTIONS.QUERY, objecttype: objectType }, payload));
44
+ }
45
+ create(objectType, payload) {
46
+ return this.sendMessageWithPromise(Object.assign({ type: MESSAGE_TYPES.REQUEST, action: REQUEST_ACTIONS.CREATE, objectType }, payload));
47
+ }
48
+ delete(objectType, recordId) {
49
+ return this.sendMessageWithPromise({
50
+ type: MESSAGE_TYPES.REQUEST,
51
+ action: REQUEST_ACTIONS.DELETE,
52
+ objectType,
53
+ recordId,
54
+ });
55
+ }
56
+ update(objectType, recordId, payload) {
57
+ return this.sendMessageWithPromise(Object.assign({ type: MESSAGE_TYPES.REQUEST, action: REQUEST_ACTIONS.UPDATE, objectType,
58
+ recordId }, payload));
59
+ }
60
+ }
61
+ export default FireberryClientSDK;
62
+ //# sourceMappingURL=fireberrySDK.client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fireberrySDK.client.js","sourceRoot":"","sources":["../../src/fireberrySDK.client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC7D,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAY9D,MAAM,OAAO,kBAA2C,SAAQ,oBAA2B;IAEzF;QACE,KAAK,EAAE,CAAC;QAFF,aAAQ,GAAmB,IAAI,CAAC;IAGxC,CAAC;IAED,IAAI,GAAG;QACL,OAAO;YACL,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC;YAC5B,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC;YAC9B,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC;YAC9B,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC;SAC/B,CAAC;IACJ,CAAC;IAED,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAID,KAAK,CAAC,iBAAi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CAAC,sBAAsB,iBAChC,IAAI,EAAE,aAAa,CAAC,OAAO,EAC3B,MAAM,EAAE,eAAe,CAAC,MAAM,EAC9B,UAAU,IACP,OAAO,EACV,CAAC;IACL,CAAC;IAEO,MAAM,CAAC,UAA2B,EAAE,QAAgB;QAC1D,OAAO,IAAI,CAAC,sBAAsB,CAAC;YACjC,IAAI,EAAE,aAAa,CAAC,OAAO;YAC3B,MAAM,EAAE,eAAe,CAAC,MAAM;YAC9B,UAAU;YACV,QAAQ;SACT,CAAC,CAAC;IACL,CAAC;IAEO,MAAM,CACZ,UAA2B,EAC3B,QAAgB,EAChB,OAAU;QAEV,OAAO,IAAI,CAAC,sBAAsB,iBAChC,IAAI,EAAE,aAAa,CAAC,OAAO,EAC3B,MAAM,EAAE,eAAe,CAAC,MAAM,EAC9B,UAAU;YACV,QAAQ,IACL,OAAO,EACV,CAAC;IACL,CAAC;CACF;AAWD,eAAe,kBAAkB,CAAC"}
@@ -0,0 +1,12 @@
1
+ import { MessagePayload, Response, ResponseData } from './types';
2
+ export declare class IframeMessageManager<TData extends Response> {
3
+ private requestIdCounter;
4
+ private pendingRequests;
5
+ constructor();
6
+ private listen;
7
+ private sendMessage;
8
+ protected sendMessageWithPromise(payload: MessagePayload): Promise<ResponseData<TData>>;
9
+ private handleMessage;
10
+ destroy(): void;
11
+ }
12
+ //# sourceMappingURL=iframeMessageManager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"iframeMessageManager.d.ts","sourceRoot":"","sources":["../../src/iframeMessageManager.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEjE,qBAAa,oBAAoB,CAAC,KAAK,SAAS,QAAQ;IACtD,OAAO,CAAC,gBAAgB,CAAa;IACrC,OAAO,CAAC,eAAe,CAOT;;IAMd,OAAO,CAAC,MAAM;IAOd,OAAO,CAAC,WAAW;IAMnB,SAAS,CAAC,sBAAsB,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;IAsBvF,OAAO,CAAC,aAAa;IAiCd,OAAO,IAAI,IAAI;CASvB"}
@@ -0,0 +1,64 @@
1
+ import { MESSAGE_TYPES, TIMEOUT_DURATION } from './constants';
2
+ export class IframeMessageManager {
3
+ constructor() {
4
+ this.requestIdCounter = 0;
5
+ this.pendingRequests = new Map();
6
+ this.listen();
7
+ }
8
+ listen() {
9
+ this.handleMessage = this.handleMessage.bind(this);
10
+ window.addEventListener('message', this.handleMessage);
11
+ return this;
12
+ }
13
+ sendMessage(payload) {
14
+ if (window.parent && window.parent !== window) {
15
+ window.parent.postMessage(payload, '*');
16
+ }
17
+ }
18
+ sendMessageWithPromise(payload) {
19
+ const requestId = `req_${++this.requestIdCounter}_${Date.now()}`;
20
+ return new Promise((resolve, reject) => {
21
+ this.pendingRequests.set(requestId, { resolve, reject });
22
+ const payloadWithId = Object.assign(Object.assign({}, payload), { requestId });
23
+ this.sendMessage(payloadWithId);
24
+ setTimeout(() => {
25
+ if (this.pendingRequests.has(requestId)) {
26
+ this.pendingRequests.delete(requestId);
27
+ reject(new Error('Request timeout: No response received'));
28
+ }
29
+ }, TIMEOUT_DURATION);
30
+ });
31
+ }
32
+ handleMessage(event) {
33
+ const { data: payload } = event;
34
+ if (!payload || typeof payload !== 'object' || !payload.type) {
35
+ return;
36
+ }
37
+ const { type, requestId } = payload;
38
+ const handlePendingRequest = (requestId, callback) => {
39
+ if (requestId && this.pendingRequests.has(requestId)) {
40
+ const { resolve } = this.pendingRequests.get(requestId);
41
+ this.pendingRequests.delete(requestId);
42
+ resolve(payload);
43
+ }
44
+ if (callback) {
45
+ callback(payload);
46
+ }
47
+ };
48
+ switch (type) {
49
+ case MESSAGE_TYPES.RESPONSE:
50
+ handlePendingRequest(requestId);
51
+ break;
52
+ default:
53
+ throw new Error(`Unknown response type: ${type}`);
54
+ }
55
+ }
56
+ destroy() {
57
+ window.removeEventListener('message', this.handleMessage);
58
+ this.pendingRequests.forEach(({ reject }) => {
59
+ reject(new Error('SDK destroyed'));
60
+ });
61
+ this.pendingRequests.clear();
62
+ }
63
+ }
64
+ //# sourceMappingURL=iframeMessageManager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"iframeMessageManager.js","sourceRoot":"","sources":["../../src/iframeMessageManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAG9D,MAAM,OAAO,oBAAoB;IAW/B;QAVQ,qBAAgB,GAAW,CAAC,CAAC;QAC7B,oBAAe,GAOnB,IAAI,GAAG,EAAE,CAAC;QAGZ,IAAI,CAAC,MAAM,EAAE,CAAC;IAChB,CAAC;IAEO,MAAM;QACZ,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACnD,MAAM,CAAC,gBAAgB,CAAC,SAAS,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;QAEvD,OAAO,IAAI,CAAC;IACd,CAAC;IAEO,WAAW,CAAC,OAAuB;QACzC,IAAI,MAAM,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,KAAK,MAAM,EAAE,CAAC;YAC9C,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;QAC1C,CAAC;IACH,CAAC;IAES,sBAAsB,CAAC,OAAuB;QACtD,MAAM,SAAS,GAAG,OAAO,EAAE,IAAI,CAAC,gBAAgB,IAAI,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC;QAEjE,OAAO,IAAI,OAAO,CAAsB,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YAC1D,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,SAAS,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC;YAEzD,MAAM,aAAa,mCACd,OAAO,KACV,SAAS,GACV,CAAC;YAEF,IAAI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,EAAE,CAAC,CAAC;QACtD,CAAC;IACH,CAAC;IAEM,OAAO;QACZ,MAAM,CAAC,mBAAmB,CAAC,SAAS,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;QAE1D,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE;YAC1C,MAAM,CAAC,IAAI,KAAK,CAAC,eAAe,CAAC,CAAC,CAAC;QACrC,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,eAAe,CAAC,KAAK,EAAE,CAAC;IAC/B,CAAC;CACF"}
@@ -0,0 +1,67 @@
1
+ import { MESSAGE_TYPES, REQUEST_ACTIONS } from '../constants';
2
+ import { Context } from '../context';
3
+ export type Response = Partial<BusinessObject> & Partial<Context>;
4
+ export type Data = Partial<BusinessObject> & {
5
+ requestId?: string;
6
+ };
7
+ export type MessageType = (typeof MESSAGE_TYPES)[keyof typeof MESSAGE_TYPES];
8
+ export type RequestAction = (typeof REQUEST_ACTIONS)[keyof typeof REQUEST_ACTIONS];
9
+ export type MessagePayload = Record<string, unknown> & {
10
+ type: MessageType;
11
+ } & Partial<RequestPayload>;
12
+ export type Payload = Record<string, unknown>;
13
+ export type ResponseError = {
14
+ data: Record<string, any> & {
15
+ Message?: string;
16
+ };
17
+ status: number;
18
+ statusText: string;
19
+ };
20
+ export type RecordDetails = Partial<{
21
+ type: number;
22
+ id: string;
23
+ }>;
24
+ export type UserDetails = Partial<{
25
+ fullName: string;
26
+ id: string;
27
+ }>;
28
+ export type ContextDetails = {
29
+ record: RecordDetails;
30
+ user: UserDetails;
31
+ };
32
+ export type RequestPayload = {
33
+ action: RequestAction;
34
+ objectType?: string | number;
35
+ recordId?: string;
36
+ };
37
+ export type BusinessObject = {
38
+ createdBy: string;
39
+ createdByName: string;
40
+ createdOn: Date;
41
+ ownerId: string;
42
+ ownerName: string;
43
+ modifiedBy: string;
44
+ modifiedByName: string;
45
+ modifiedOn: Date;
46
+ };
47
+ export type ResponseData<T extends Response> = {
48
+ type?: MessageType;
49
+ success: boolean;
50
+ data: T & Data;
51
+ error?: ResponseError;
52
+ isParentReady: boolean;
53
+ requestId: string;
54
+ };
55
+ export type QueryPayload = {
56
+ fields: string;
57
+ query: string;
58
+ page_size?: number;
59
+ page_number?: number;
60
+ };
61
+ export interface API<TData extends Response> {
62
+ query: (objectType: string | number, payload: QueryPayload) => Promise<ResponseData<TData>>;
63
+ create: <T extends Payload>(objectType: string | number, payload: T) => Promise<ResponseData<TData>>;
64
+ delete: (objectType: string | number, recordId: string) => Promise<ResponseData<TData>>;
65
+ update: <T extends Payload>(objectType: string | number, recordId: string, payload: T) => Promise<ResponseData<TData>>;
66
+ }
67
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC9D,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAErC,MAAM,MAAM,QAAQ,GAAG,OAAO,CAAC,cAAc,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;AAClE,MAAM,MAAM,IAAI,GAAG,OAAO,CAAC,cAAc,CAAC,GAAG;IAAE,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AACpE,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,OAAO,aAAa,CAAC,CAAC;AAC7E,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,eAAe,CAAC,CAAC,MAAM,OAAO,eAAe,CAAC,CAAC;AAEnF,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG;IACrD,IAAI,EAAE,WAAW,CAAC;CACnB,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;AAC5B,MAAM,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,EA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,EAAE,OAAO,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,MAAM,WAAW,GAAG,CAAC,KAAK,SAAS,QAAQ;IACzC,KAAK,EAAE,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,EAAE,OAAO,EAAE,YAAY,KAAK,OAAO,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC;IAC5F,MAAM,EAAE,CAAC,CAAC,SAAS,OAAO,EACxB,UAAU,EAAE,MAAM,GAAG,MAAM,EAC3B,OAAO,EAAE,CAAC,KACP,OAAO,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC;IAClC,MAAM,EAAE,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,EAAE,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC;IACxF,MAAM,EAAE,CAAC,CAAC,SAAS,OAAO,EACxB,UAAU,EAAE,MAAM,GAAG,MAAM,EAC3B,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,CAAC,KACP,OAAO,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC;CACnC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":""}
package/package.json CHANGED
@@ -1,44 +1,67 @@
1
1
  {
2
2
  "name": "@fireberry/sdk",
3
- "version": "0.0.3",
4
- "description": "",
5
- "main": "dist/index.js",
6
- "types": "dist/index.d.ts",
3
+ "version": "0.0.5",
4
+ "description": "Fireberry SDK",
5
+ "type": "module",
6
+ "sideEffects": false,
7
7
  "scripts": {
8
8
  "prepare": "npm run build",
9
- "build": "tsc ",
10
- "test": "jest --watchAll"
9
+ "format": "prettier --write \"src/**/*.ts\"",
10
+ "lint": " tsc --noEmit && eslint \"src/**/*.ts\"",
11
+ "build": "npm run clean && npm run build:esm && npm run build:cjs",
12
+ "dev:cjs": "tsc -p tsconfig.cjs.json --watch",
13
+ "dev:esm": "tsc -p tsconfig.json --watch",
14
+ "build:cjs": "tsc -p tsconfig.cjs.json",
15
+ "build:esm": "tsc -p tsconfig.json",
16
+ "test": "jest --watchAll",
17
+ "clean": "rm -rf dist"
11
18
  },
12
- "dependencies": {
13
- "axios": "^1.6.8",
14
- "dotenv": "^16.4.5"
19
+ "exports": {
20
+ "./client": {
21
+ "import": {
22
+ "types": "./dist/esm/fireberrySDK.client.d.ts",
23
+ "default": "./dist/esm/fireberrySDK.client.js"
24
+ },
25
+ "require": {
26
+ "types": "./dist/cjs/fireberrySDK.client.d.ts",
27
+ "default": "./dist/cjs/fireberrySDK.client.js"
28
+ }
29
+ }
15
30
  },
16
- "bundleDependencies": [
17
- "axios",
18
- "dotenv"
31
+ "files": [
32
+ "dist"
19
33
  ],
34
+ "bundleDependencies": [],
20
35
  "repository": {
21
36
  "type": "git",
22
- "url": "https://powerlinksoftware.visualstudio.com/AppPlatform/_git/FireberrySDK"
37
+ "url": "https://github.com/fireberry-crm/sdk.git"
23
38
  },
24
- "author": "Itay Zemah @Fireberry",
25
- "license": "ISC",
39
+ "maintainers": [
40
+ {
41
+ "name": "Johnny Marelly",
42
+ "email": "johnnym@fireberry.com"
43
+ }
44
+ ],
45
+ "contributors": [
46
+ {
47
+ "name": "Itay Zemah",
48
+ "email": "itay@fireberry.com"
49
+ },
50
+ {
51
+ "name": "Johnny Marelly",
52
+ "email": "johnnym@fireberry.com"
53
+ }
54
+ ],
55
+ "license": "MIT",
26
56
  "devDependencies": {
27
- "@babel/preset-typescript": "^7.24.1",
28
- "@types/jest": "^29.5.12",
29
- "@types/jsdom": "^21.1.6",
30
57
  "@types/node": "^20.12.8",
31
- "@typescript-eslint/eslint-plugin": "^7.8.0",
32
- "@typescript-eslint/parser": "^7.8.0",
33
- "babel-jest": "^29.7.0",
34
- "eslint": "^8.57.0",
35
- "eslint-config-prettier": "^9.1.0",
36
- "eslint-plugin-prettier": "^5.1.3",
37
- "jest": "^29.7.0",
38
- "jsdom": "^24.0.0",
58
+ "@typescript-eslint/eslint-plugin": "^8.46.2",
59
+ "@typescript-eslint/parser": "^8.46.2",
60
+ "eslint": "^9.38.0",
61
+ "eslint-config-prettier": "^10.1.8",
62
+ "eslint-plugin-prettier": "^5.5.4",
63
+ "globals": "^16.4.0",
39
64
  "prettier": "^3.2.5",
40
- "ts-jest": "^29.1.2",
41
- "ts-node": "^10.9.2",
42
65
  "typescript": "^5.4.5"
43
66
  },
44
67
  "keywords": [
package/.eslintrc.json DELETED
@@ -1,36 +0,0 @@
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 DELETED
@@ -1,7 +0,0 @@
1
- {
2
- "printWidth": 100,
3
- "tabWidth": 2,
4
- "singleQuote": true,
5
- "jsxBracketSameLine": true,
6
- "trailingComma": "es5"
7
- }
@@ -1,35 +0,0 @@
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
- }
@@ -1,7 +0,0 @@
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
- }
@@ -1,10 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,13 +0,0 @@
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
- }
@@ -1,22 +0,0 @@
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)('objectId');
10
- const recordTypeParam = (0, utils_1.getParam)('objectType');
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
@@ -1 +0,0 @@
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"}
@@ -1 +0,0 @@
1
- export {};
@@ -1,45 +0,0 @@
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
@@ -1 +0,0 @@
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,MAA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0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/context/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4CAA0B"}
@@ -1,9 +0,0 @@
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
- }
@@ -1,33 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,5 +0,0 @@
1
- export declare class UserContext {
2
- constructor();
3
- get(_fieldName: string): Promise<void>;
4
- all(): Promise<void>;
5
- }
@@ -1,27 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,4 +0,0 @@
1
- import { FireberryClientSDK } from './fireberrySDK.client';
2
- import { FireberryServerSDK } from './fireberrySDK.server';
3
- declare const _default: () => FireberryClientSDK | FireberryServerSDK;
4
- export default _default;