@fireberry/sdk 0.0.4 → 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 (276) 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/{fireberryAPI/types.js → cjs/types/index.js} +1 -1
  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 +54 -27
  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.map +0 -1
  85. package/dist/fireberrySDK.client.d.ts +0 -5
  86. package/dist/fireberrySDK.client.js +0 -13
  87. package/dist/fireberrySDK.client.js.map +0 -1
  88. package/dist/fireberrySDK.server.d.ts +0 -6
  89. package/dist/fireberrySDK.server.js +0 -12
  90. package/dist/fireberrySDK.server.js.map +0 -1
  91. package/dist/index.d.ts +0 -6
  92. package/dist/index.js +0 -25
  93. package/dist/index.js.map +0 -1
  94. package/dist/utils/axios.util.d.ts +0 -6
  95. package/dist/utils/axios.util.js +0 -24
  96. package/dist/utils/axios.util.js.map +0 -1
  97. package/dist/utils/index.d.ts +0 -2
  98. package/dist/utils/index.js +0 -19
  99. package/dist/utils/index.js.map +0 -1
  100. package/dist/utils/queryParam.util.d.ts +0 -1
  101. package/dist/utils/queryParam.util.js +0 -12
  102. package/dist/utils/queryParam.util.js.map +0 -1
  103. package/jest.config.ts +0 -10
  104. package/node_modules/asynckit/README.md +0 -233
  105. package/node_modules/asynckit/bench.js +0 -76
  106. package/node_modules/asynckit/index.js +0 -6
  107. package/node_modules/asynckit/lib/abort.js +0 -29
  108. package/node_modules/asynckit/lib/async.js +0 -34
  109. package/node_modules/asynckit/lib/defer.js +0 -26
  110. package/node_modules/asynckit/lib/iterate.js +0 -75
  111. package/node_modules/asynckit/lib/readable_asynckit.js +0 -91
  112. package/node_modules/asynckit/lib/readable_parallel.js +0 -25
  113. package/node_modules/asynckit/lib/readable_serial.js +0 -25
  114. package/node_modules/asynckit/lib/readable_serial_ordered.js +0 -29
  115. package/node_modules/asynckit/lib/state.js +0 -37
  116. package/node_modules/asynckit/lib/streamify.js +0 -141
  117. package/node_modules/asynckit/lib/terminator.js +0 -29
  118. package/node_modules/asynckit/package.json +0 -63
  119. package/node_modules/asynckit/parallel.js +0 -43
  120. package/node_modules/asynckit/serial.js +0 -17
  121. package/node_modules/asynckit/serialOrdered.js +0 -75
  122. package/node_modules/asynckit/stream.js +0 -21
  123. package/node_modules/axios/CHANGELOG.md +0 -874
  124. package/node_modules/axios/LICENSE +0 -7
  125. package/node_modules/axios/MIGRATION_GUIDE.md +0 -3
  126. package/node_modules/axios/README.md +0 -1650
  127. package/node_modules/axios/SECURITY.md +0 -6
  128. package/node_modules/axios/dist/axios.js +0 -3448
  129. package/node_modules/axios/dist/axios.js.map +0 -1
  130. package/node_modules/axios/dist/axios.min.js +0 -2
  131. package/node_modules/axios/dist/axios.min.js.map +0 -1
  132. package/node_modules/axios/dist/browser/axios.cjs +0 -3258
  133. package/node_modules/axios/dist/browser/axios.cjs.map +0 -1
  134. package/node_modules/axios/dist/esm/axios.js +0 -3281
  135. package/node_modules/axios/dist/esm/axios.js.map +0 -1
  136. package/node_modules/axios/dist/esm/axios.min.js +0 -2
  137. package/node_modules/axios/dist/esm/axios.min.js.map +0 -1
  138. package/node_modules/axios/dist/node/axios.cjs +0 -4354
  139. package/node_modules/axios/dist/node/axios.cjs.map +0 -1
  140. package/node_modules/axios/index.d.cts +0 -542
  141. package/node_modules/axios/index.d.ts +0 -559
  142. package/node_modules/axios/index.js +0 -43
  143. package/node_modules/axios/lib/adapters/README.md +0 -37
  144. package/node_modules/axios/lib/adapters/adapters.js +0 -77
  145. package/node_modules/axios/lib/adapters/http.js +0 -685
  146. package/node_modules/axios/lib/adapters/xhr.js +0 -260
  147. package/node_modules/axios/lib/axios.js +0 -89
  148. package/node_modules/axios/lib/cancel/CancelToken.js +0 -121
  149. package/node_modules/axios/lib/cancel/CanceledError.js +0 -25
  150. package/node_modules/axios/lib/cancel/isCancel.js +0 -5
  151. package/node_modules/axios/lib/core/Axios.js +0 -225
  152. package/node_modules/axios/lib/core/AxiosError.js +0 -100
  153. package/node_modules/axios/lib/core/AxiosHeaders.js +0 -298
  154. package/node_modules/axios/lib/core/InterceptorManager.js +0 -71
  155. package/node_modules/axios/lib/core/README.md +0 -8
  156. package/node_modules/axios/lib/core/buildFullPath.js +0 -21
  157. package/node_modules/axios/lib/core/dispatchRequest.js +0 -81
  158. package/node_modules/axios/lib/core/mergeConfig.js +0 -106
  159. package/node_modules/axios/lib/core/settle.js +0 -27
  160. package/node_modules/axios/lib/core/transformData.js +0 -28
  161. package/node_modules/axios/lib/defaults/index.js +0 -156
  162. package/node_modules/axios/lib/defaults/transitional.js +0 -7
  163. package/node_modules/axios/lib/env/README.md +0 -3
  164. package/node_modules/axios/lib/env/classes/FormData.js +0 -2
  165. package/node_modules/axios/lib/env/data.js +0 -1
  166. package/node_modules/axios/lib/helpers/AxiosTransformStream.js +0 -191
  167. package/node_modules/axios/lib/helpers/AxiosURLSearchParams.js +0 -58
  168. package/node_modules/axios/lib/helpers/HttpStatusCode.js +0 -71
  169. package/node_modules/axios/lib/helpers/README.md +0 -7
  170. package/node_modules/axios/lib/helpers/ZlibHeaderTransformStream.js +0 -28
  171. package/node_modules/axios/lib/helpers/bind.js +0 -7
  172. package/node_modules/axios/lib/helpers/buildURL.js +0 -63
  173. package/node_modules/axios/lib/helpers/callbackify.js +0 -16
  174. package/node_modules/axios/lib/helpers/combineURLs.js +0 -15
  175. package/node_modules/axios/lib/helpers/cookies.js +0 -42
  176. package/node_modules/axios/lib/helpers/deprecatedMethod.js +0 -26
  177. package/node_modules/axios/lib/helpers/formDataToJSON.js +0 -95
  178. package/node_modules/axios/lib/helpers/formDataToStream.js +0 -111
  179. package/node_modules/axios/lib/helpers/fromDataURI.js +0 -53
  180. package/node_modules/axios/lib/helpers/isAbsoluteURL.js +0 -15
  181. package/node_modules/axios/lib/helpers/isAxiosError.js +0 -14
  182. package/node_modules/axios/lib/helpers/isURLSameOrigin.js +0 -67
  183. package/node_modules/axios/lib/helpers/null.js +0 -2
  184. package/node_modules/axios/lib/helpers/parseHeaders.js +0 -55
  185. package/node_modules/axios/lib/helpers/parseProtocol.js +0 -6
  186. package/node_modules/axios/lib/helpers/readBlob.js +0 -15
  187. package/node_modules/axios/lib/helpers/speedometer.js +0 -55
  188. package/node_modules/axios/lib/helpers/spread.js +0 -28
  189. package/node_modules/axios/lib/helpers/throttle.js +0 -33
  190. package/node_modules/axios/lib/helpers/toFormData.js +0 -219
  191. package/node_modules/axios/lib/helpers/toURLEncodedForm.js +0 -18
  192. package/node_modules/axios/lib/helpers/validator.js +0 -91
  193. package/node_modules/axios/lib/platform/browser/classes/Blob.js +0 -3
  194. package/node_modules/axios/lib/platform/browser/classes/FormData.js +0 -3
  195. package/node_modules/axios/lib/platform/browser/classes/URLSearchParams.js +0 -4
  196. package/node_modules/axios/lib/platform/browser/index.js +0 -13
  197. package/node_modules/axios/lib/platform/common/utils.js +0 -47
  198. package/node_modules/axios/lib/platform/index.js +0 -7
  199. package/node_modules/axios/lib/platform/node/classes/FormData.js +0 -3
  200. package/node_modules/axios/lib/platform/node/classes/URLSearchParams.js +0 -4
  201. package/node_modules/axios/lib/platform/node/index.js +0 -12
  202. package/node_modules/axios/lib/utils.js +0 -723
  203. package/node_modules/axios/package.json +0 -218
  204. package/node_modules/combined-stream/License +0 -19
  205. package/node_modules/combined-stream/Readme.md +0 -138
  206. package/node_modules/combined-stream/lib/combined_stream.js +0 -208
  207. package/node_modules/combined-stream/package.json +0 -25
  208. package/node_modules/delayed-stream/.npmignore +0 -1
  209. package/node_modules/delayed-stream/License +0 -19
  210. package/node_modules/delayed-stream/Makefile +0 -7
  211. package/node_modules/delayed-stream/Readme.md +0 -141
  212. package/node_modules/delayed-stream/lib/delayed_stream.js +0 -107
  213. package/node_modules/delayed-stream/package.json +0 -27
  214. package/node_modules/dotenv/CHANGELOG.md +0 -475
  215. package/node_modules/dotenv/LICENSE +0 -23
  216. package/node_modules/dotenv/README-es.md +0 -448
  217. package/node_modules/dotenv/README.md +0 -728
  218. package/node_modules/dotenv/config.d.ts +0 -1
  219. package/node_modules/dotenv/config.js +0 -9
  220. package/node_modules/dotenv/lib/cli-options.js +0 -11
  221. package/node_modules/dotenv/lib/env-options.js +0 -24
  222. package/node_modules/dotenv/lib/main.d.ts +0 -153
  223. package/node_modules/dotenv/lib/main.js +0 -361
  224. package/node_modules/dotenv/package.json +0 -65
  225. package/node_modules/follow-redirects/LICENSE +0 -18
  226. package/node_modules/follow-redirects/README.md +0 -155
  227. package/node_modules/follow-redirects/debug.js +0 -15
  228. package/node_modules/follow-redirects/http.js +0 -1
  229. package/node_modules/follow-redirects/https.js +0 -1
  230. package/node_modules/follow-redirects/index.js +0 -672
  231. package/node_modules/follow-redirects/package.json +0 -58
  232. package/node_modules/form-data/License +0 -19
  233. package/node_modules/form-data/README.md.bak +0 -358
  234. package/node_modules/form-data/Readme.md +0 -358
  235. package/node_modules/form-data/index.d.ts +0 -62
  236. package/node_modules/form-data/lib/browser.js +0 -2
  237. package/node_modules/form-data/lib/form_data.js +0 -501
  238. package/node_modules/form-data/lib/populate.js +0 -10
  239. package/node_modules/form-data/package.json +0 -68
  240. package/node_modules/mime-db/HISTORY.md +0 -507
  241. package/node_modules/mime-db/LICENSE +0 -23
  242. package/node_modules/mime-db/README.md +0 -100
  243. package/node_modules/mime-db/db.json +0 -8519
  244. package/node_modules/mime-db/index.js +0 -12
  245. package/node_modules/mime-db/package.json +0 -60
  246. package/node_modules/mime-types/HISTORY.md +0 -397
  247. package/node_modules/mime-types/LICENSE +0 -23
  248. package/node_modules/mime-types/README.md +0 -113
  249. package/node_modules/mime-types/index.js +0 -188
  250. package/node_modules/mime-types/package.json +0 -44
  251. package/node_modules/proxy-from-env/.eslintrc +0 -29
  252. package/node_modules/proxy-from-env/.travis.yml +0 -10
  253. package/node_modules/proxy-from-env/LICENSE +0 -20
  254. package/node_modules/proxy-from-env/README.md +0 -131
  255. package/node_modules/proxy-from-env/index.js +0 -108
  256. package/node_modules/proxy-from-env/package.json +0 -34
  257. package/node_modules/proxy-from-env/test.js +0 -483
  258. package/src/base.fireberrySDK.ts +0 -7
  259. package/src/context/context.record.test.ts +0 -47
  260. package/src/context/context.ts +0 -28
  261. package/src/context/index.ts +0 -6
  262. package/src/context/record.ts +0 -22
  263. package/src/context/user.ts +0 -15
  264. package/src/fireberry.sdk.ts +0 -14
  265. package/src/fireberryAPI/fireberryV2Api.test.ts +0 -57
  266. package/src/fireberryAPI/fireberryV2Api.ts +0 -61
  267. package/src/fireberryAPI/index.ts +0 -2
  268. package/src/fireberryAPI/types.ts +0 -10
  269. package/src/fireberrySDK.client.ts +0 -10
  270. package/src/fireberrySDK.server.ts +0 -8
  271. package/src/index.ts +0 -9
  272. package/src/utils/axios.util.ts +0 -20
  273. package/src/utils/index.ts +0 -2
  274. package/src/utils/queryParam.util.ts +0 -8
  275. package/tsconfig.json +0 -123
  276. /package/dist/{context → cjs/context}/index.js +0 -0
@@ -1,13 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,17 +0,0 @@
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
- }
@@ -1,54 +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.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
@@ -1 +0,0 @@
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"}
@@ -1 +0,0 @@
1
- export {};
@@ -1,56 +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 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
@@ -1 +0,0 @@
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"}
@@ -1,2 +0,0 @@
1
- export { FireberryV2Api } from './fireberryV2Api';
2
- export * from './types';
@@ -1,21 +0,0 @@
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
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/fireberryAPI/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,mDAAkD;AAAzC,gHAAA,cAAc,OAAA;AACvB,0CAAwB"}
@@ -1,10 +0,0 @@
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
- };
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/fireberryAPI/types.ts"],"names":[],"mappings":""}
@@ -1,5 +0,0 @@
1
- import { FireberrySDK } from './base.fireberrySDK';
2
- import { FireberryV2Api } from './fireberryAPI';
3
- export declare class FireberryClientSDK extends FireberrySDK {
4
- constructor(api: FireberryV2Api);
5
- }
@@ -1,13 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,6 +0,0 @@
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
- }
@@ -1,12 +0,0 @@
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
@@ -1 +0,0 @@
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"}
package/dist/index.d.ts DELETED
@@ -1,6 +0,0 @@
1
- export declare const IS_DEVELOPMENT: boolean;
2
- export { default } from './fireberry.sdk';
3
- export type Config = Partial<{
4
- tokenId?: string;
5
- }>;
6
- export * from './fireberryAPI/types';
package/dist/index.js DELETED
@@ -1,25 +0,0 @@
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
- var __importDefault = (this && this.__importDefault) || function (mod) {
17
- return (mod && mod.__esModule) ? mod : { "default": mod };
18
- };
19
- Object.defineProperty(exports, "__esModule", { value: true });
20
- exports.default = exports.IS_DEVELOPMENT = void 0;
21
- exports.IS_DEVELOPMENT = ['development', 'test'].includes(process.env.NODE_ENV);
22
- var fireberry_sdk_1 = require("./fireberry.sdk");
23
- Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(fireberry_sdk_1).default; } });
24
- __exportStar(require("./fireberryAPI/types"), exports);
25
- //# sourceMappingURL=index.js.map
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAa,QAAA,cAAc,GAAG,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,QAAS,CAAC,CAAC;AAEtF,iDAA0C;AAAjC,yHAAA,OAAO,OAAA;AAMhB,uDAAqC"}
@@ -1,6 +0,0 @@
1
- import { AxiosInstance } from 'axios';
2
- import { Config } from '..';
3
- export declare abstract class AxiosFireberryAPI {
4
- protected api: AxiosInstance;
5
- constructor(config: Config);
6
- }
@@ -1,24 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.AxiosFireberryAPI = void 0;
7
- const axios_1 = __importDefault(require("axios"));
8
- class AxiosFireberryAPI {
9
- constructor(config) {
10
- var _a;
11
- const baseURL = 'https://api.fireberry.com';
12
- const tokenid = (_a = config === null || config === void 0 ? void 0 : config.tokenId) !== null && _a !== void 0 ? _a : undefined;
13
- this.api = axios_1.default.create({
14
- baseURL,
15
- headers: {
16
- 'Content-Type': 'application/json',
17
- tokenid,
18
- },
19
- withCredentials: true,
20
- });
21
- }
22
- }
23
- exports.AxiosFireberryAPI = AxiosFireberryAPI;
24
- //# sourceMappingURL=axios.util.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"axios.util.js","sourceRoot":"","sources":["../../src/utils/axios.util.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA6C;AAG7C,MAAsB,iBAAiB;IAGrC,YAAY,MAAc;;QACxB,MAAM,OAAO,GAAG,2BAA2B,CAAC;QAC5C,MAAM,OAAO,GAAG,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,OAAO,mCAAI,SAAS,CAAC;QAE7C,IAAI,CAAC,GAAG,GAAG,eAAK,CAAC,MAAM,CAAC;YACtB,OAAO;YACP,OAAO,EAAE;gBACP,cAAc,EAAE,kBAAkB;gBAClC,OAAO;aACR;YACD,eAAe,EAAE,IAAI;SACtB,CAAC,CAAC;IACL,CAAC;CACF;AAhBD,8CAgBC"}
@@ -1,2 +0,0 @@
1
- export * from './axios.util';
2
- export * from './queryParam.util';
@@ -1,19 +0,0 @@
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("./axios.util"), exports);
18
- __exportStar(require("./queryParam.util"), exports);
19
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA6B;AAC7B,oDAAkC"}
@@ -1 +0,0 @@
1
- export declare function getParam(param: string): string | undefined;
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getParam = void 0;
4
- function getParam(param) {
5
- if (typeof window !== 'undefined') {
6
- const searchParams = new URLSearchParams(window.location.search);
7
- return searchParams.get(param) || undefined;
8
- }
9
- return undefined;
10
- }
11
- exports.getParam = getParam;
12
- //# sourceMappingURL=queryParam.util.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"queryParam.util.js","sourceRoot":"","sources":["../../src/utils/queryParam.util.ts"],"names":[],"mappings":";;;AAAA,SAAgB,QAAQ,CAAC,KAAa;IACpC,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE,CAAC;QAClC,MAAM,YAAY,GAAG,IAAI,eAAe,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QAEjE,OAAO,YAAY,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,SAAS,CAAC;IAC9C,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAPD,4BAOC"}
package/jest.config.ts DELETED
@@ -1,10 +0,0 @@
1
- /*
2
- * For a detailed explanation regarding each configuration property and type check, visit:
3
- * https://jestjs.io/docs/configuration
4
- */
5
-
6
- export default {
7
- moduleDirectories: ['node_modules', 'src'],
8
- preset: 'ts-jest',
9
- modulePathIgnorePatterns: ['<rootDir>/dist/'],
10
- };
@@ -1,233 +0,0 @@
1
- # asynckit [![NPM Module](https://img.shields.io/npm/v/asynckit.svg?style=flat)](https://www.npmjs.com/package/asynckit)
2
-
3
- Minimal async jobs utility library, with streams support.
4
-
5
- [![PhantomJS Build](https://img.shields.io/travis/alexindigo/asynckit/v0.4.0.svg?label=browser&style=flat)](https://travis-ci.org/alexindigo/asynckit)
6
- [![Linux Build](https://img.shields.io/travis/alexindigo/asynckit/v0.4.0.svg?label=linux:0.12-6.x&style=flat)](https://travis-ci.org/alexindigo/asynckit)
7
- [![Windows Build](https://img.shields.io/appveyor/ci/alexindigo/asynckit/v0.4.0.svg?label=windows:0.12-6.x&style=flat)](https://ci.appveyor.com/project/alexindigo/asynckit)
8
-
9
- [![Coverage Status](https://img.shields.io/coveralls/alexindigo/asynckit/v0.4.0.svg?label=code+coverage&style=flat)](https://coveralls.io/github/alexindigo/asynckit?branch=master)
10
- [![Dependency Status](https://img.shields.io/david/alexindigo/asynckit/v0.4.0.svg?style=flat)](https://david-dm.org/alexindigo/asynckit)
11
- [![bitHound Overall Score](https://www.bithound.io/github/alexindigo/asynckit/badges/score.svg)](https://www.bithound.io/github/alexindigo/asynckit)
12
-
13
- <!-- [![Readme](https://img.shields.io/badge/readme-tested-brightgreen.svg?style=flat)](https://www.npmjs.com/package/reamde) -->
14
-
15
- AsyncKit provides harness for `parallel` and `serial` iterators over list of items represented by arrays or objects.
16
- Optionally it accepts abort function (should be synchronously return by iterator for each item), and terminates left over jobs upon an error event. For specific iteration order built-in (`ascending` and `descending`) and custom sort helpers also supported, via `asynckit.serialOrdered` method.
17
-
18
- It ensures async operations to keep behavior more stable and prevent `Maximum call stack size exceeded` errors, from sync iterators.
19
-
20
- | compression | size |
21
- | :----------------- | -------: |
22
- | asynckit.js | 12.34 kB |
23
- | asynckit.min.js | 4.11 kB |
24
- | asynckit.min.js.gz | 1.47 kB |
25
-
26
-
27
- ## Install
28
-
29
- ```sh
30
- $ npm install --save asynckit
31
- ```
32
-
33
- ## Examples
34
-
35
- ### Parallel Jobs
36
-
37
- Runs iterator over provided array in parallel. Stores output in the `result` array,
38
- on the matching positions. In unlikely event of an error from one of the jobs,
39
- will terminate rest of the active jobs (if abort function is provided)
40
- and return error along with salvaged data to the main callback function.
41
-
42
- #### Input Array
43
-
44
- ```javascript
45
- var parallel = require('asynckit').parallel
46
- , assert = require('assert')
47
- ;
48
-
49
- var source = [ 1, 1, 4, 16, 64, 32, 8, 2 ]
50
- , expectedResult = [ 2, 2, 8, 32, 128, 64, 16, 4 ]
51
- , expectedTarget = [ 1, 1, 2, 4, 8, 16, 32, 64 ]
52
- , target = []
53
- ;
54
-
55
- parallel(source, asyncJob, function(err, result)
56
- {
57
- assert.deepEqual(result, expectedResult);
58
- assert.deepEqual(target, expectedTarget);
59
- });
60
-
61
- // async job accepts one element from the array
62
- // and a callback function
63
- function asyncJob(item, cb)
64
- {
65
- // different delays (in ms) per item
66
- var delay = item * 25;
67
-
68
- // pretend different jobs take different time to finish
69
- // and not in consequential order
70
- var timeoutId = setTimeout(function() {
71
- target.push(item);
72
- cb(null, item * 2);
73
- }, delay);
74
-
75
- // allow to cancel "leftover" jobs upon error
76
- // return function, invoking of which will abort this job
77
- return clearTimeout.bind(null, timeoutId);
78
- }
79
- ```
80
-
81
- More examples could be found in [test/test-parallel-array.js](test/test-parallel-array.js).
82
-
83
- #### Input Object
84
-
85
- Also it supports named jobs, listed via object.
86
-
87
- ```javascript
88
- var parallel = require('asynckit/parallel')
89
- , assert = require('assert')
90
- ;
91
-
92
- var source = { first: 1, one: 1, four: 4, sixteen: 16, sixtyFour: 64, thirtyTwo: 32, eight: 8, two: 2 }
93
- , expectedResult = { first: 2, one: 2, four: 8, sixteen: 32, sixtyFour: 128, thirtyTwo: 64, eight: 16, two: 4 }
94
- , expectedTarget = [ 1, 1, 2, 4, 8, 16, 32, 64 ]
95
- , expectedKeys = [ 'first', 'one', 'two', 'four', 'eight', 'sixteen', 'thirtyTwo', 'sixtyFour' ]
96
- , target = []
97
- , keys = []
98
- ;
99
-
100
- parallel(source, asyncJob, function(err, result)
101
- {
102
- assert.deepEqual(result, expectedResult);
103
- assert.deepEqual(target, expectedTarget);
104
- assert.deepEqual(keys, expectedKeys);
105
- });
106
-
107
- // supports full value, key, callback (shortcut) interface
108
- function asyncJob(item, key, cb)
109
- {
110
- // different delays (in ms) per item
111
- var delay = item * 25;
112
-
113
- // pretend different jobs take different time to finish
114
- // and not in consequential order
115
- var timeoutId = setTimeout(function() {
116
- keys.push(key);
117
- target.push(item);
118
- cb(null, item * 2);
119
- }, delay);
120
-
121
- // allow to cancel "leftover" jobs upon error
122
- // return function, invoking of which will abort this job
123
- return clearTimeout.bind(null, timeoutId);
124
- }
125
- ```
126
-
127
- More examples could be found in [test/test-parallel-object.js](test/test-parallel-object.js).
128
-
129
- ### Serial Jobs
130
-
131
- Runs iterator over provided array sequentially. Stores output in the `result` array,
132
- on the matching positions. In unlikely event of an error from one of the jobs,
133
- will not proceed to the rest of the items in the list
134
- and return error along with salvaged data to the main callback function.
135
-
136
- #### Input Array
137
-
138
- ```javascript
139
- var serial = require('asynckit/serial')
140
- , assert = require('assert')
141
- ;
142
-
143
- var source = [ 1, 1, 4, 16, 64, 32, 8, 2 ]
144
- , expectedResult = [ 2, 2, 8, 32, 128, 64, 16, 4 ]
145
- , expectedTarget = [ 0, 1, 2, 3, 4, 5, 6, 7 ]
146
- , target = []
147
- ;
148
-
149
- serial(source, asyncJob, function(err, result)
150
- {
151
- assert.deepEqual(result, expectedResult);
152
- assert.deepEqual(target, expectedTarget);
153
- });
154
-
155
- // extended interface (item, key, callback)
156
- // also supported for arrays
157
- function asyncJob(item, key, cb)
158
- {
159
- target.push(key);
160
-
161
- // it will be automatically made async
162
- // even it iterator "returns" in the same event loop
163
- cb(null, item * 2);
164
- }
165
- ```
166
-
167
- More examples could be found in [test/test-serial-array.js](test/test-serial-array.js).
168
-
169
- #### Input Object
170
-
171
- Also it supports named jobs, listed via object.
172
-
173
- ```javascript
174
- var serial = require('asynckit').serial
175
- , assert = require('assert')
176
- ;
177
-
178
- var source = [ 1, 1, 4, 16, 64, 32, 8, 2 ]
179
- , expectedResult = [ 2, 2, 8, 32, 128, 64, 16, 4 ]
180
- , expectedTarget = [ 0, 1, 2, 3, 4, 5, 6, 7 ]
181
- , target = []
182
- ;
183
-
184
- var source = { first: 1, one: 1, four: 4, sixteen: 16, sixtyFour: 64, thirtyTwo: 32, eight: 8, two: 2 }
185
- , expectedResult = { first: 2, one: 2, four: 8, sixteen: 32, sixtyFour: 128, thirtyTwo: 64, eight: 16, two: 4 }
186
- , expectedTarget = [ 1, 1, 4, 16, 64, 32, 8, 2 ]
187
- , target = []
188
- ;
189
-
190
-
191
- serial(source, asyncJob, function(err, result)
192
- {
193
- assert.deepEqual(result, expectedResult);
194
- assert.deepEqual(target, expectedTarget);
195
- });
196
-
197
- // shortcut interface (item, callback)
198
- // works for object as well as for the arrays
199
- function asyncJob(item, cb)
200
- {
201
- target.push(item);
202
-
203
- // it will be automatically made async
204
- // even it iterator "returns" in the same event loop
205
- cb(null, item * 2);
206
- }
207
- ```
208
-
209
- More examples could be found in [test/test-serial-object.js](test/test-serial-object.js).
210
-
211
- _Note: Since _object_ is an _unordered_ collection of properties,
212
- it may produce unexpected results with sequential iterations.
213
- Whenever order of the jobs' execution is important please use `serialOrdered` method._
214
-
215
- ### Ordered Serial Iterations
216
-
217
- TBD
218
-
219
- For example [compare-property](compare-property) package.
220
-
221
- ### Streaming interface
222
-
223
- TBD
224
-
225
- ## Want to Know More?
226
-
227
- More examples can be found in [test folder](test/).
228
-
229
- Or open an [issue](https://github.com/alexindigo/asynckit/issues) with questions and/or suggestions.
230
-
231
- ## License
232
-
233
- AsyncKit is licensed under the MIT license.