@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.
- package/{node_modules/asynckit/LICENSE → LICENSE.md} +2 -2
- package/README.md +85 -37
- package/dist/cjs/constants/index.d.ts +13 -0
- package/dist/cjs/constants/index.d.ts.map +1 -0
- package/dist/cjs/constants/index.js +16 -0
- package/dist/cjs/constants/index.js.map +1 -0
- package/dist/cjs/context/context.d.ts +7 -0
- package/dist/cjs/context/context.d.ts.map +1 -0
- package/dist/cjs/context/context.js +11 -0
- package/dist/cjs/context/context.js.map +1 -0
- package/dist/cjs/context/index.d.ts +2 -0
- package/dist/cjs/context/index.d.ts.map +1 -0
- package/dist/cjs/context/index.js.map +1 -0
- package/dist/cjs/fireberrySDK.client.d.ts +18 -0
- package/dist/cjs/fireberrySDK.client.d.ts.map +1 -0
- package/dist/cjs/fireberrySDK.client.js +66 -0
- package/dist/cjs/fireberrySDK.client.js.map +1 -0
- package/dist/cjs/iframeMessageManager.d.ts +12 -0
- package/dist/cjs/iframeMessageManager.d.ts.map +1 -0
- package/dist/cjs/iframeMessageManager.js +68 -0
- package/dist/cjs/iframeMessageManager.js.map +1 -0
- package/dist/cjs/types/index.d.ts +67 -0
- package/dist/cjs/types/index.d.ts.map +1 -0
- package/dist/{src/fireberryAPI/types.js → cjs/types/index.js} +1 -0
- package/dist/cjs/types/index.js.map +1 -0
- package/dist/esm/constants/index.d.ts +13 -0
- package/dist/esm/constants/index.d.ts.map +1 -0
- package/dist/esm/constants/index.js +13 -0
- package/dist/esm/constants/index.js.map +1 -0
- package/dist/esm/context/context.d.ts +7 -0
- package/dist/esm/context/context.d.ts.map +1 -0
- package/dist/esm/context/context.js +7 -0
- package/dist/esm/context/context.js.map +1 -0
- package/dist/esm/context/index.d.ts +2 -0
- package/dist/esm/context/index.d.ts.map +1 -0
- package/dist/esm/context/index.js +2 -0
- package/dist/esm/context/index.js.map +1 -0
- package/dist/esm/fireberrySDK.client.d.ts +18 -0
- package/dist/esm/fireberrySDK.client.d.ts.map +1 -0
- package/dist/esm/fireberrySDK.client.js +62 -0
- package/dist/esm/fireberrySDK.client.js.map +1 -0
- package/dist/esm/iframeMessageManager.d.ts +12 -0
- package/dist/esm/iframeMessageManager.d.ts.map +1 -0
- package/dist/esm/iframeMessageManager.js +64 -0
- package/dist/esm/iframeMessageManager.js.map +1 -0
- package/dist/esm/types/index.d.ts +67 -0
- package/dist/esm/types/index.d.ts.map +1 -0
- package/dist/esm/types/index.js +2 -0
- package/dist/esm/types/index.js.map +1 -0
- package/package.json +51 -28
- package/.eslintrc.json +0 -36
- package/.prettierrc.json +0 -7
- package/.vscode/settings.json +0 -35
- package/dist/base.fireberrySDK.d.ts +0 -7
- package/dist/base.fireberrySDK.js +0 -10
- package/dist/base.fireberrySDK.js.map +0 -1
- package/dist/context/context.d.ts +0 -13
- package/dist/context/context.js +0 -22
- package/dist/context/context.js.map +0 -1
- package/dist/context/context.record.test.d.ts +0 -1
- package/dist/context/context.record.test.js +0 -45
- package/dist/context/context.record.test.js.map +0 -1
- package/dist/context/index.d.ts +0 -5
- package/dist/context/index.js.map +0 -1
- package/dist/context/record.d.ts +0 -9
- package/dist/context/record.js +0 -33
- package/dist/context/record.js.map +0 -1
- package/dist/context/user.d.ts +0 -5
- package/dist/context/user.js +0 -27
- package/dist/context/user.js.map +0 -1
- package/dist/fireberry.sdk.d.ts +0 -4
- package/dist/fireberry.sdk.js +0 -13
- package/dist/fireberry.sdk.js.map +0 -1
- package/dist/fireberryAPI/fireberryV2Api.d.ts +0 -17
- package/dist/fireberryAPI/fireberryV2Api.js +0 -54
- package/dist/fireberryAPI/fireberryV2Api.js.map +0 -1
- package/dist/fireberryAPI/fireberryV2Api.test.d.ts +0 -1
- package/dist/fireberryAPI/fireberryV2Api.test.js +0 -56
- package/dist/fireberryAPI/fireberryV2Api.test.js.map +0 -1
- package/dist/fireberryAPI/index.d.ts +0 -2
- package/dist/fireberryAPI/index.js +0 -21
- package/dist/fireberryAPI/index.js.map +0 -1
- package/dist/fireberryAPI/types.d.ts +0 -10
- package/dist/fireberryAPI/types.js +0 -3
- package/dist/fireberryAPI/types.js.map +0 -1
- package/dist/fireberrySDK.client.d.ts +0 -5
- package/dist/fireberrySDK.client.js +0 -13
- package/dist/fireberrySDK.client.js.map +0 -1
- package/dist/fireberrySDK.server.d.ts +0 -6
- package/dist/fireberrySDK.server.js +0 -12
- package/dist/fireberrySDK.server.js.map +0 -1
- package/dist/index.d.ts +0 -6
- package/dist/index.js +0 -25
- package/dist/index.js.map +0 -1
- package/dist/jest.config.d.ts +0 -6
- package/dist/jest.config.js +0 -11
- package/dist/src/context/context.d.ts +0 -13
- package/dist/src/context/context.js +0 -21
- package/dist/src/context/context.record.test.d.ts +0 -1
- package/dist/src/context/context.record.test.js +0 -36
- package/dist/src/context/index.d.ts +0 -5
- package/dist/src/context/index.js +0 -17
- package/dist/src/context/record.d.ts +0 -9
- package/dist/src/context/record.js +0 -32
- package/dist/src/context/user.d.ts +0 -8
- package/dist/src/context/user.js +0 -31
- package/dist/src/fireberry.sdk.d.ts +0 -9
- package/dist/src/fireberry.sdk.js +0 -14
- package/dist/src/fireberryAPI/fireberryV2Api.d.ts +0 -14
- package/dist/src/fireberryAPI/fireberryV2Api.js +0 -41
- package/dist/src/fireberryAPI/index.d.ts +0 -2
- package/dist/src/fireberryAPI/index.js +0 -20
- package/dist/src/fireberryAPI/types.d.ts +0 -10
- package/dist/src/index.d.ts +0 -9
- package/dist/src/index.js +0 -6
- package/dist/src/utils/axios.util.d.ts +0 -6
- package/dist/src/utils/axios.util.js +0 -24
- package/dist/src/utils/index.d.ts +0 -2
- package/dist/src/utils/index.js +0 -18
- package/dist/src/utils/queryParam.util.d.ts +0 -1
- package/dist/src/utils/queryParam.util.js +0 -10
- package/dist/utils/axios.util.d.ts +0 -6
- package/dist/utils/axios.util.js +0 -24
- package/dist/utils/axios.util.js.map +0 -1
- package/dist/utils/index.d.ts +0 -2
- package/dist/utils/index.js +0 -19
- package/dist/utils/index.js.map +0 -1
- package/dist/utils/queryParam.util.d.ts +0 -1
- package/dist/utils/queryParam.util.js +0 -12
- package/dist/utils/queryParam.util.js.map +0 -1
- package/jest.config.ts +0 -10
- package/node_modules/asynckit/README.md +0 -233
- package/node_modules/asynckit/bench.js +0 -76
- package/node_modules/asynckit/index.js +0 -6
- package/node_modules/asynckit/lib/abort.js +0 -29
- package/node_modules/asynckit/lib/async.js +0 -34
- package/node_modules/asynckit/lib/defer.js +0 -26
- package/node_modules/asynckit/lib/iterate.js +0 -75
- package/node_modules/asynckit/lib/readable_asynckit.js +0 -91
- package/node_modules/asynckit/lib/readable_parallel.js +0 -25
- package/node_modules/asynckit/lib/readable_serial.js +0 -25
- package/node_modules/asynckit/lib/readable_serial_ordered.js +0 -29
- package/node_modules/asynckit/lib/state.js +0 -37
- package/node_modules/asynckit/lib/streamify.js +0 -141
- package/node_modules/asynckit/lib/terminator.js +0 -29
- package/node_modules/asynckit/package.json +0 -63
- package/node_modules/asynckit/parallel.js +0 -43
- package/node_modules/asynckit/serial.js +0 -17
- package/node_modules/asynckit/serialOrdered.js +0 -75
- package/node_modules/asynckit/stream.js +0 -21
- package/node_modules/axios/CHANGELOG.md +0 -874
- package/node_modules/axios/LICENSE +0 -7
- package/node_modules/axios/MIGRATION_GUIDE.md +0 -3
- package/node_modules/axios/README.md +0 -1650
- package/node_modules/axios/SECURITY.md +0 -6
- package/node_modules/axios/dist/axios.js +0 -3448
- package/node_modules/axios/dist/axios.js.map +0 -1
- package/node_modules/axios/dist/axios.min.js +0 -2
- package/node_modules/axios/dist/axios.min.js.map +0 -1
- package/node_modules/axios/dist/browser/axios.cjs +0 -3258
- package/node_modules/axios/dist/browser/axios.cjs.map +0 -1
- package/node_modules/axios/dist/esm/axios.js +0 -3281
- package/node_modules/axios/dist/esm/axios.js.map +0 -1
- package/node_modules/axios/dist/esm/axios.min.js +0 -2
- package/node_modules/axios/dist/esm/axios.min.js.map +0 -1
- package/node_modules/axios/dist/node/axios.cjs +0 -4354
- package/node_modules/axios/dist/node/axios.cjs.map +0 -1
- package/node_modules/axios/index.d.cts +0 -542
- package/node_modules/axios/index.d.ts +0 -559
- package/node_modules/axios/index.js +0 -43
- package/node_modules/axios/lib/adapters/README.md +0 -37
- package/node_modules/axios/lib/adapters/adapters.js +0 -77
- package/node_modules/axios/lib/adapters/http.js +0 -685
- package/node_modules/axios/lib/adapters/xhr.js +0 -260
- package/node_modules/axios/lib/axios.js +0 -89
- package/node_modules/axios/lib/cancel/CancelToken.js +0 -121
- package/node_modules/axios/lib/cancel/CanceledError.js +0 -25
- package/node_modules/axios/lib/cancel/isCancel.js +0 -5
- package/node_modules/axios/lib/core/Axios.js +0 -225
- package/node_modules/axios/lib/core/AxiosError.js +0 -100
- package/node_modules/axios/lib/core/AxiosHeaders.js +0 -298
- package/node_modules/axios/lib/core/InterceptorManager.js +0 -71
- package/node_modules/axios/lib/core/README.md +0 -8
- package/node_modules/axios/lib/core/buildFullPath.js +0 -21
- package/node_modules/axios/lib/core/dispatchRequest.js +0 -81
- package/node_modules/axios/lib/core/mergeConfig.js +0 -106
- package/node_modules/axios/lib/core/settle.js +0 -27
- package/node_modules/axios/lib/core/transformData.js +0 -28
- package/node_modules/axios/lib/defaults/index.js +0 -156
- package/node_modules/axios/lib/defaults/transitional.js +0 -7
- package/node_modules/axios/lib/env/README.md +0 -3
- package/node_modules/axios/lib/env/classes/FormData.js +0 -2
- package/node_modules/axios/lib/env/data.js +0 -1
- package/node_modules/axios/lib/helpers/AxiosTransformStream.js +0 -191
- package/node_modules/axios/lib/helpers/AxiosURLSearchParams.js +0 -58
- package/node_modules/axios/lib/helpers/HttpStatusCode.js +0 -71
- package/node_modules/axios/lib/helpers/README.md +0 -7
- package/node_modules/axios/lib/helpers/ZlibHeaderTransformStream.js +0 -28
- package/node_modules/axios/lib/helpers/bind.js +0 -7
- package/node_modules/axios/lib/helpers/buildURL.js +0 -63
- package/node_modules/axios/lib/helpers/callbackify.js +0 -16
- package/node_modules/axios/lib/helpers/combineURLs.js +0 -15
- package/node_modules/axios/lib/helpers/cookies.js +0 -42
- package/node_modules/axios/lib/helpers/deprecatedMethod.js +0 -26
- package/node_modules/axios/lib/helpers/formDataToJSON.js +0 -95
- package/node_modules/axios/lib/helpers/formDataToStream.js +0 -111
- package/node_modules/axios/lib/helpers/fromDataURI.js +0 -53
- package/node_modules/axios/lib/helpers/isAbsoluteURL.js +0 -15
- package/node_modules/axios/lib/helpers/isAxiosError.js +0 -14
- package/node_modules/axios/lib/helpers/isURLSameOrigin.js +0 -67
- package/node_modules/axios/lib/helpers/null.js +0 -2
- package/node_modules/axios/lib/helpers/parseHeaders.js +0 -55
- package/node_modules/axios/lib/helpers/parseProtocol.js +0 -6
- package/node_modules/axios/lib/helpers/readBlob.js +0 -15
- package/node_modules/axios/lib/helpers/speedometer.js +0 -55
- package/node_modules/axios/lib/helpers/spread.js +0 -28
- package/node_modules/axios/lib/helpers/throttle.js +0 -33
- package/node_modules/axios/lib/helpers/toFormData.js +0 -219
- package/node_modules/axios/lib/helpers/toURLEncodedForm.js +0 -18
- package/node_modules/axios/lib/helpers/validator.js +0 -91
- package/node_modules/axios/lib/platform/browser/classes/Blob.js +0 -3
- package/node_modules/axios/lib/platform/browser/classes/FormData.js +0 -3
- package/node_modules/axios/lib/platform/browser/classes/URLSearchParams.js +0 -4
- package/node_modules/axios/lib/platform/browser/index.js +0 -13
- package/node_modules/axios/lib/platform/common/utils.js +0 -47
- package/node_modules/axios/lib/platform/index.js +0 -7
- package/node_modules/axios/lib/platform/node/classes/FormData.js +0 -3
- package/node_modules/axios/lib/platform/node/classes/URLSearchParams.js +0 -4
- package/node_modules/axios/lib/platform/node/index.js +0 -12
- package/node_modules/axios/lib/utils.js +0 -723
- package/node_modules/axios/package.json +0 -218
- package/node_modules/combined-stream/License +0 -19
- package/node_modules/combined-stream/Readme.md +0 -138
- package/node_modules/combined-stream/lib/combined_stream.js +0 -208
- package/node_modules/combined-stream/package.json +0 -25
- package/node_modules/delayed-stream/.npmignore +0 -1
- package/node_modules/delayed-stream/License +0 -19
- package/node_modules/delayed-stream/Makefile +0 -7
- package/node_modules/delayed-stream/Readme.md +0 -141
- package/node_modules/delayed-stream/lib/delayed_stream.js +0 -107
- package/node_modules/delayed-stream/package.json +0 -27
- package/node_modules/dotenv/CHANGELOG.md +0 -475
- package/node_modules/dotenv/LICENSE +0 -23
- package/node_modules/dotenv/README-es.md +0 -448
- package/node_modules/dotenv/README.md +0 -728
- package/node_modules/dotenv/config.d.ts +0 -1
- package/node_modules/dotenv/config.js +0 -9
- package/node_modules/dotenv/lib/cli-options.js +0 -11
- package/node_modules/dotenv/lib/env-options.js +0 -24
- package/node_modules/dotenv/lib/main.d.ts +0 -153
- package/node_modules/dotenv/lib/main.js +0 -361
- package/node_modules/dotenv/package.json +0 -65
- package/node_modules/follow-redirects/LICENSE +0 -18
- package/node_modules/follow-redirects/README.md +0 -155
- package/node_modules/follow-redirects/debug.js +0 -15
- package/node_modules/follow-redirects/http.js +0 -1
- package/node_modules/follow-redirects/https.js +0 -1
- package/node_modules/follow-redirects/index.js +0 -672
- package/node_modules/follow-redirects/package.json +0 -58
- package/node_modules/form-data/License +0 -19
- package/node_modules/form-data/README.md.bak +0 -358
- package/node_modules/form-data/Readme.md +0 -358
- package/node_modules/form-data/index.d.ts +0 -62
- package/node_modules/form-data/lib/browser.js +0 -2
- package/node_modules/form-data/lib/form_data.js +0 -501
- package/node_modules/form-data/lib/populate.js +0 -10
- package/node_modules/form-data/package.json +0 -68
- package/node_modules/mime-db/HISTORY.md +0 -507
- package/node_modules/mime-db/LICENSE +0 -23
- package/node_modules/mime-db/README.md +0 -100
- package/node_modules/mime-db/db.json +0 -8519
- package/node_modules/mime-db/index.js +0 -12
- package/node_modules/mime-db/package.json +0 -60
- package/node_modules/mime-types/HISTORY.md +0 -397
- package/node_modules/mime-types/LICENSE +0 -23
- package/node_modules/mime-types/README.md +0 -113
- package/node_modules/mime-types/index.js +0 -188
- package/node_modules/mime-types/package.json +0 -44
- package/node_modules/proxy-from-env/.eslintrc +0 -29
- package/node_modules/proxy-from-env/.travis.yml +0 -10
- package/node_modules/proxy-from-env/LICENSE +0 -20
- package/node_modules/proxy-from-env/README.md +0 -131
- package/node_modules/proxy-from-env/index.js +0 -108
- package/node_modules/proxy-from-env/package.json +0 -34
- package/node_modules/proxy-from-env/test.js +0 -483
- package/src/base.fireberrySDK.ts +0 -7
- package/src/context/context.record.test.ts +0 -47
- package/src/context/context.ts +0 -28
- package/src/context/index.ts +0 -6
- package/src/context/record.ts +0 -22
- package/src/context/user.ts +0 -15
- package/src/fireberry.sdk.ts +0 -14
- package/src/fireberryAPI/fireberryV2Api.test.ts +0 -57
- package/src/fireberryAPI/fireberryV2Api.ts +0 -61
- package/src/fireberryAPI/index.ts +0 -2
- package/src/fireberryAPI/types.ts +0 -10
- package/src/fireberrySDK.client.ts +0 -10
- package/src/fireberrySDK.server.ts +0 -8
- package/src/index.ts +0 -9
- package/src/utils/axios.util.ts +0 -20
- package/src/utils/index.ts +0 -2
- package/src/utils/queryParam.util.ts +0 -8
- package/tsconfig.json +0 -123
- /package/dist/{context → cjs/context}/index.js +0 -0
package/dist/fireberry.sdk.js
DELETED
|
@@ -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,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 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/fireberryAPI/types.ts"],"names":[],"mappings":""}
|
|
@@ -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,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
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"}
|
package/dist/jest.config.d.ts
DELETED
package/dist/jest.config.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
* For a detailed explanation regarding each configuration property and type check, visit:
|
|
4
|
-
* https://jestjs.io/docs/configuration
|
|
5
|
-
*/
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.default = {
|
|
8
|
-
moduleDirectories: ['node_modules', 'src'],
|
|
9
|
-
preset: 'ts-jest',
|
|
10
|
-
modulePathIgnorePatterns: ['<rootDir>/dist/'],
|
|
11
|
-
};
|
|
@@ -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,21 +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)('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(fireberryApi);
|
|
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;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,36 +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
|
-
const __1 = require("..");
|
|
13
|
-
describe('SDK context', () => {
|
|
14
|
-
it('throw an error when trying to reach record functions', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
15
|
-
const fireberry = new __1.FireberrySDK({ tokenId: '9796da37-d499-432d-b698-e8daf41bf7ed' });
|
|
16
|
-
yield expect(fireberry.context.record.get('name')).rejects.toThrow('Record context is not set. Please set the recordId and recordType before calling this method.');
|
|
17
|
-
yield expect(fireberry.context.record.all()).rejects.toThrow('Record context is not set. Please set the recordId and recordType before calling this method.');
|
|
18
|
-
}));
|
|
19
|
-
it('retrieved a record', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
20
|
-
const customFieldName = 'pcfSystemField123';
|
|
21
|
-
const extendCustomObject = { [customFieldName]: 'test' };
|
|
22
|
-
const fireberry = new __1.FireberrySDK({
|
|
23
|
-
tokenId: '9796da37-d499-432d-b698-e8daf41bf7ed',
|
|
24
|
-
currentRecordDetails: { recordId: 'test', recordType: 1 },
|
|
25
|
-
});
|
|
26
|
-
const record = Object.assign({ createdBy: 'test', createdByName: 'test', createdOn: new Date(), modifiedBy: 'test', modifiedByName: 'test', modifiedOn: new Date(), ownerId: 'test', ownerName: 'test' }, extendCustomObject);
|
|
27
|
-
const mockAddListener = jest.spyOn(fireberry.api, 'get');
|
|
28
|
-
mockAddListener.mockImplementation((_recordType, _recordId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
29
|
-
return record;
|
|
30
|
-
}));
|
|
31
|
-
const specificFieldValue = yield fireberry.context.record.get(customFieldName);
|
|
32
|
-
expect(specificFieldValue).toBe(extendCustomObject[customFieldName]);
|
|
33
|
-
const recordResult = yield fireberry.context.record.all();
|
|
34
|
-
expect(recordResult).toBe(record);
|
|
35
|
-
}));
|
|
36
|
-
});
|
|
@@ -1,17 +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("./context"), exports);
|
|
@@ -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,32 +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;
|
package/dist/src/context/user.js
DELETED
|
@@ -1,31 +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(fireberryApi) {
|
|
15
|
-
this.fireberryApi = fireberryApi;
|
|
16
|
-
this.recordType = CRM_USER;
|
|
17
|
-
}
|
|
18
|
-
// api/v3/record/9/me/:fieldname?
|
|
19
|
-
get(fieldName) {
|
|
20
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
21
|
-
throw new Error('Not implemented');
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
all() {
|
|
25
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
26
|
-
throw new Error('Not implemented');
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
exports.UserContext = UserContext;
|
|
31
|
-
const CRM_USER = 9;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { Config } from '.';
|
|
2
|
-
import { Context } from './context';
|
|
3
|
-
import { FireberryV2Api } from './fireberryAPI';
|
|
4
|
-
export declare class FireberrySDK {
|
|
5
|
-
private config?;
|
|
6
|
-
context: Context;
|
|
7
|
-
api: FireberryV2Api;
|
|
8
|
-
constructor(config?: Config | undefined);
|
|
9
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FireberrySDK = void 0;
|
|
4
|
-
const context_1 = require("./context");
|
|
5
|
-
const fireberryAPI_1 = require("./fireberryAPI");
|
|
6
|
-
class FireberrySDK {
|
|
7
|
-
constructor(config) {
|
|
8
|
-
var _a;
|
|
9
|
-
this.config = config;
|
|
10
|
-
this.api = new fireberryAPI_1.FireberryV2Api(this.config);
|
|
11
|
-
this.context = new context_1.Context(this.api, (_a = this.config) === null || _a === void 0 ? void 0 : _a.currentRecordDetails);
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
exports.FireberrySDK = FireberrySDK;
|
|
@@ -1,14 +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
|
-
/**
|
|
7
|
-
* Retrieves a record by its type and ID.
|
|
8
|
-
* @param recordType - The type of the record.
|
|
9
|
-
* @param recordId - The ID of the record.
|
|
10
|
-
* @returns A Promise that resolves to the retrieved record
|
|
11
|
-
*/
|
|
12
|
-
get<T extends BusinessObject>(recordType: number, recordId: string): Promise<T>;
|
|
13
|
-
query(fields: string[], recordType: number, query: string, shouldShowRealValues?: boolean): Promise<import("axios").AxiosResponse<any, any>>;
|
|
14
|
-
}
|
|
@@ -1,41 +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
|
-
/**
|
|
19
|
-
* Retrieves a record by its type and ID.
|
|
20
|
-
* @param recordType - The type of the record.
|
|
21
|
-
* @param recordId - The ID of the record.
|
|
22
|
-
* @returns A Promise that resolves to the retrieved record
|
|
23
|
-
*/
|
|
24
|
-
get(recordType, recordId) {
|
|
25
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
26
|
-
return (yield this.api.get(`/api/v2/record/${recordType}/${recordId}/getrecord`)).data;
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
query(fields_1, recordType_1, query_1) {
|
|
30
|
-
return __awaiter(this, arguments, void 0, function* (fields, recordType, query, shouldShowRealValues = false) {
|
|
31
|
-
const payload = {
|
|
32
|
-
recordType: recordType,
|
|
33
|
-
fields,
|
|
34
|
-
query,
|
|
35
|
-
show_real_value: shouldShowRealValues ? 1 : 0,
|
|
36
|
-
};
|
|
37
|
-
return yield this.api.post('/api/query', payload);
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
exports.FireberryV2Api = FireberryV2Api;
|
|
@@ -1,20 +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);
|