@croct/plug 0.8.3 → 0.10.1

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/README.md CHANGED
@@ -138,6 +138,7 @@ The following references provide guidance to help you get started, integrate, an
138
138
  - [Patch Reference](docs/patch.md)
139
139
  - [User Reference](docs/user.md)
140
140
  - [Session Reference](docs/session.md)
141
+ - [Testing](docs/testing.md)
141
142
  - [Troubleshooting](docs/troubleshooting.md)
142
143
 
143
144
  If you are new to the Croct platform, the [quick start guide](docs/quick-start.md) is a good starting point for
package/fetch.d.ts CHANGED
@@ -1,6 +1,10 @@
1
- import { NullableJsonObject } from './sdk/json';
1
+ import { NullableJsonObject, JsonObject } from './sdk/json';
2
2
  export interface SlotMap {
3
3
  }
4
+ export declare type FetchOptions = {
5
+ timeout?: number;
6
+ attributes?: JsonObject;
7
+ };
4
8
  export declare type SlotId = keyof SlotMap extends never ? string : keyof SlotMap;
5
9
  export declare type SlotContent<I extends SlotId> = I extends keyof SlotMap ? SlotMap[I] : NullableJsonObject;
6
10
  export declare type FetchResponse<I extends SlotId, P extends NullableJsonObject = NullableJsonObject> = {
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@croct/plug",
3
- "version": "0.8.3",
3
+ "version": "0.10.1",
4
4
  "description": "A fully-featured devkit for building natively personalized applications.",
5
5
  "license": "MIT",
6
6
  "author": {
7
7
  "name": "Croct",
8
- "email": "plug-js+lib@croct.com",
8
+ "email": "lib+plug-js@croct.com",
9
9
  "url": "https://croct.com"
10
10
  },
11
11
  "keywords": [
@@ -33,7 +33,8 @@
33
33
  "bundle": "rollup -c"
34
34
  },
35
35
  "dependencies": {
36
- "@croct/sdk": "^0.6.1",
36
+ "@croct/json": "^1.1.0",
37
+ "@croct/sdk": "^0.9.1",
37
38
  "tslib": "^2.2.0"
38
39
  },
39
40
  "devDependencies": {
package/plug.d.ts CHANGED
@@ -7,7 +7,7 @@ import { Optional } from '@croct/sdk/utilityTypes';
7
7
  import { ExternalTrackingEvent as ExternalEvent, ExternalTrackingEventPayload as ExternalEventPayload, ExternalTrackingEventType as ExternalEventType } from '@croct/sdk/trackingEvents';
8
8
  import { PluginFactory } from './plugin';
9
9
  import { EapFeatures } from './eap';
10
- import { SlotId, FetchResponse } from './fetch';
10
+ import { SlotId, FetchResponse, FetchOptions } from './fetch';
11
11
  import { NullableJsonObject, JsonValue } from './sdk/json';
12
12
  export interface PluginConfigurations {
13
13
  [key: string]: any;
@@ -62,7 +62,7 @@ export declare class GlobalPlug implements Plug {
62
62
  /**
63
63
  * This API is unstable and subject to change in future releases.
64
64
  */
65
- fetch<P extends NullableJsonObject, I extends SlotId = SlotId>(slotId: I): Promise<FetchResponse<I, P>>;
65
+ fetch<P extends NullableJsonObject, I extends SlotId = SlotId>(slotId: I, options?: FetchOptions): Promise<FetchResponse<I, P>>;
66
66
  unplug(): Promise<void>;
67
67
  private eap;
68
68
  }
package/plug.js CHANGED
@@ -35,7 +35,7 @@ var GlobalPlug = /** @class */ (function () {
35
35
  GlobalPlug.prototype.plug = function (configuration) {
36
36
  var e_1, _a;
37
37
  var _this = this;
38
- var _b, _c;
38
+ var _b, _c, _d, _e;
39
39
  if (configuration === void 0) { configuration = {}; }
40
40
  if (this.instance !== undefined) {
41
41
  var logger_1 = this.instance.getLogger();
@@ -54,8 +54,10 @@ var GlobalPlug = /** @class */ (function () {
54
54
  throw new Error('The app ID must be specified when it cannot be auto-detected. '
55
55
  + 'Please try again specifying the "appId" option.');
56
56
  }
57
- var plugins = configuration.plugins, sdkConfiguration = tslib_1.__rest(configuration, ["plugins"]);
58
- var sdk = sdkFacade_1.SdkFacade.init(tslib_1.__assign(tslib_1.__assign({}, sdkConfiguration), { appId: appId }));
57
+ var plugins = configuration.plugins, test = configuration.test, sdkConfiguration = tslib_1.__rest(configuration, ["plugins", "test"]);
58
+ var sdk = sdkFacade_1.SdkFacade.init(tslib_1.__assign(tslib_1.__assign({}, sdkConfiguration), { appId: appId, test: test !== null && test !== void 0 ? test : (typeof process === 'object' && (((_c = process.env) === null || _c === void 0 ? void 0 : _c.CROCT_TEST_MODE) !== undefined
59
+ ? process.env.CROCT_TEST_MODE === 'true'
60
+ : ((_d = process.env) === null || _d === void 0 ? void 0 : _d.NODE_ENV) === 'test')) }));
59
61
  this.instance = sdk;
60
62
  var logger = this.instance.getLogger();
61
63
  if (detectedAppId === configuredAppId) {
@@ -142,19 +144,19 @@ var GlobalPlug = /** @class */ (function () {
142
144
  };
143
145
  var this_1 = this;
144
146
  try {
145
- for (var _d = tslib_1.__values(Object.entries(tslib_1.__assign({ playground: true }, plugins))), _e = _d.next(); !_e.done; _e = _d.next()) {
146
- var _f = tslib_1.__read(_e.value, 2), name_1 = _f[0], options = _f[1];
147
+ for (var _f = tslib_1.__values(Object.entries(tslib_1.__assign({ playground: true }, plugins))), _g = _f.next(); !_g.done; _g = _f.next()) {
148
+ var _h = tslib_1.__read(_g.value, 2), name_1 = _h[0], options = _h[1];
147
149
  _loop_1(name_1, options);
148
150
  }
149
151
  }
150
152
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
151
153
  finally {
152
154
  try {
153
- if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
155
+ if (_g && !_g.done && (_a = _f.return)) _a.call(_f);
154
156
  }
155
157
  finally { if (e_1) throw e_1.error; }
156
158
  }
157
- var initializeEap = (_c = window.croctEap) === null || _c === void 0 ? void 0 : _c.initialize;
159
+ var initializeEap = (_e = window.croctEap) === null || _e === void 0 ? void 0 : _e.initialize;
158
160
  if (typeof initializeEap === 'function') {
159
161
  initializeEap.call(this);
160
162
  }
@@ -260,8 +262,9 @@ var GlobalPlug = /** @class */ (function () {
260
262
  /**
261
263
  * This API is unstable and subject to change in future releases.
262
264
  */
263
- GlobalPlug.prototype.fetch = function (slotId) {
264
- return this.eap('fetch').call(this, slotId);
265
+ GlobalPlug.prototype.fetch = function (slotId, options) {
266
+ if (options === void 0) { options = {}; }
267
+ return this.eap('fetch').call(this, slotId, options);
265
268
  };
266
269
  GlobalPlug.prototype.unplug = function () {
267
270
  return tslib_1.__awaiter(this, void 0, void 0, function () {
package/sdk/json.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- import { JsonObject } from '@croct/sdk/json';
2
- export * from '@croct/sdk/json';
1
+ import { JsonObject } from '@croct/json';
2
+ export * from '@croct/json/mutable';
3
3
  export declare type NullableJsonObject = JsonObject | null;
package/sdk/json.js CHANGED
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  var tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("@croct/sdk/json"), exports);
4
+ tslib_1.__exportStar(require("@croct/json/mutable"), exports);
package/sdk/tracking.d.ts CHANGED
@@ -1,3 +1,6 @@
1
+ import { EventInfo as SdkEventInfo } from '@croct/sdk/tracker';
2
+ import { TrackingEvent, TrackingEventType } from '@croct/sdk/trackingEvents';
1
3
  export { TrackerFacade } from '@croct/sdk/facade/trackerFacade';
2
- export { EventInfo, EventListener } from '@croct/sdk/tracker';
4
+ export { EventListener } from '@croct/sdk/tracker';
3
5
  export { TrackingEvent, TrackingEventType, ExternalTrackingEvent, ExternalTrackingEventPayload, ExternalTrackingEventType, } from '@croct/sdk/trackingEvents';
6
+ export declare type EventInfo<T extends TrackingEventType> = SdkEventInfo<TrackingEvent<T>>;