@storyteq/platform-integration 0.0.6 → 1.0.0
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/.env +13 -0
- package/README.md +22 -28
- package/build/classes/BaseFrameController.d.ts +21 -0
- package/build/classes/CreateMediaPage.d.ts +26 -0
- package/build/classes/CrmAnalyticsPage.d.ts +4 -0
- package/build/get-frame-url.d.ts +1 -0
- package/build/index.d.ts +2 -0
- package/build/index.js +2 -0
- package/build/index.js.map +1 -0
- package/build/interfaces/one-of.interface.d.ts +1 -0
- package/build/test.d.ts +1 -0
- package/package.json +25 -32
- package/.babelrc +0 -15
- package/.browserslistrc +0 -10
- package/.dependabot/config.yml +0 -9
- package/.env.example +0 -2
- package/.eslintrc +0 -13
- package/.travis.yml +0 -5
- package/public/.gitkeep +0 -0
- package/src/classes/BaseFrameController.js +0 -73
- package/src/classes/CreateMediaPage.js +0 -15
- package/src/classes/CrmAnalyticsPage.js +0 -13
- package/src/get-frame-url.js +0 -1
- package/src/index.js +0 -43
- package/src/test.html +0 -16
- package/webpack/webpack.common.js +0 -52
- package/webpack/webpack.config.dev.js +0 -39
- package/webpack/webpack.config.prod.js +0 -28
package/.env
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# TEST_API_KEY=06023eb02feac0258564a71d1d0edd07
|
|
2
|
+
# TEST_API_KEY=27543bdd5851ec047afe7691062f097d
|
|
3
|
+
TEST_API_KEY=d950768763a548a45c961af5f662a0b5
|
|
4
|
+
# TEST_API_KEY=af5a7b6ebb73f5bb330c7d50552d1682
|
|
5
|
+
# TEST_API_KEY=cfda83df9fb0d83521c11c23d854d8bc
|
|
6
|
+
|
|
7
|
+
# ITG:
|
|
8
|
+
#TEST_API_KEY=b2d233a1df6a7bdfc89aaba3a70477e0
|
|
9
|
+
|
|
10
|
+
# IWG:
|
|
11
|
+
#TEST_API_KEY=5f54670019cf34e5af9746cb0cc927ee
|
|
12
|
+
|
|
13
|
+
ENVIRONMENT="testing"
|
package/README.md
CHANGED
|
@@ -4,21 +4,14 @@ Integrate with components of the Storyteq platform.
|
|
|
4
4
|
|
|
5
5
|
## Development
|
|
6
6
|
|
|
7
|
-
Inside of src/
|
|
7
|
+
Inside of src/test.ts you need to set up your TEST_API_KEY.
|
|
8
8
|
|
|
9
9
|
```
|
|
10
|
-
cp .env.example .env
|
|
11
|
-
# Edit your env
|
|
12
|
-
# TEST_API_KEY="YOUR_TOKEN"
|
|
13
|
-
# ENVIRONMENT="testing"
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
nvm use 10
|
|
17
10
|
npm i
|
|
18
11
|
npm start
|
|
19
12
|
```
|
|
20
13
|
|
|
21
|
-
To change the platform url you need to edit
|
|
14
|
+
To change the platform url you need to edit window.APP_URL variable.
|
|
22
15
|
|
|
23
16
|
## Usage
|
|
24
17
|
|
|
@@ -27,7 +20,7 @@ npm i @storyteq/platform-integration
|
|
|
27
20
|
```
|
|
28
21
|
|
|
29
22
|
```
|
|
30
|
-
import StoryteqPlatform from '@storyteq/platform-integration';
|
|
23
|
+
import * as StoryteqPlatform from '@storyteq/platform-integration';
|
|
31
24
|
```
|
|
32
25
|
### General usage
|
|
33
26
|
|
|
@@ -45,7 +38,7 @@ Destroy the currently active page instance.
|
|
|
45
38
|
|
|
46
39
|
## Production usage
|
|
47
40
|
|
|
48
|
-
In order for the generated iframe to load correctly, your domains need to be whitelisted in our Content-Security-Policy headers. Please share your testing and production domains with us so we can add them as allowed frame-ancestors.
|
|
41
|
+
In order for the generated iframe to load correctly, your domains need to be whitelisted in our Content-Security-Policy headers. Please share your testing and production domains with us, so we can add them as allowed frame-ancestors.
|
|
49
42
|
|
|
50
43
|
## Available pages
|
|
51
44
|
|
|
@@ -158,12 +151,12 @@ By setting the value of ```mediaRecreateHash``` to a media hash, all parameter v
|
|
|
158
151
|
|
|
159
152
|
##### forceMediaPreviewBeforeCreate
|
|
160
153
|
\
|
|
161
|
-
For after effects template, ```forceMediaPreviewBeforeCreate``` allows you to
|
|
154
|
+
For after effects template, ```forceMediaPreviewBeforeCreate``` allows you to enforce the creation of a 'rich preview' before action creation/publishing can be made.
|
|
162
155
|
|
|
163
|
-
| Option (string) | Description
|
|
164
|
-
|
|
165
|
-
| always
|
|
166
|
-
| on_first_render | Only
|
|
156
|
+
| Option (string) | Description |
|
|
157
|
+
|-----------------|-------------------------------------------------------------------------------------------|
|
|
158
|
+
| always | Always enforce rich preview before creation, even after changes are applied |
|
|
159
|
+
| on_first_render | Only enforce rich preview once. Changing parameter values will not enforce a new preview. |
|
|
167
160
|
|
|
168
161
|
##### customizationItems
|
|
169
162
|
\
|
|
@@ -171,15 +164,16 @@ For after effects template, ```forceMediaPreviewBeforeCreate``` allows you to en
|
|
|
171
164
|
\
|
|
172
165
|
Possible configurations:
|
|
173
166
|
|
|
174
|
-
| Attribute
|
|
175
|
-
|
|
176
|
-
| host_product_name
|
|
177
|
-
| media_alias
|
|
178
|
-
| button_media_create | Media create button custom description/text
|
|
179
|
-
| end_screen_title
|
|
180
|
-
| end_screen_subtitle | Subtitle of the screen indicating a media has been created/published
|
|
181
|
-
| color_theme_hex
|
|
182
|
-
| full_screen
|
|
167
|
+
| Attribute | Description | Option(s) |
|
|
168
|
+
|---------------------|------------------------------------------------------------------------------------------------|--------------------------------|
|
|
169
|
+
| host_product_name | Name of your company/product | Free text (string) |
|
|
170
|
+
| media_alias | Alias of media/creative | Free text (string) |
|
|
171
|
+
| button_media_create | Media create button custom description/text | Free text (string) |
|
|
172
|
+
| end_screen_title | Title of the screen indicating a media has been created/published | Free text (string) |
|
|
173
|
+
| end_screen_subtitle | Subtitle of the screen indicating a media has been created/published | Free text (string) |
|
|
174
|
+
| color_theme_hex | Color theme of UI elements such as buttons, loading bars, etc. | Hex code (string) |
|
|
175
|
+
| full_screen | Choice of having the create form cover the whole screen or not | true/false |
|
|
176
|
+
| cancelable | Shows a cancel button on the create media form that will event a 'canceled' event when pressed | true/false (defaults to false) |
|
|
183
177
|
|
|
184
178
|
##### endScreenActions
|
|
185
179
|
\
|
|
@@ -188,6 +182,6 @@ The end screen is what appears after you have initiated the creation/publishing
|
|
|
188
182
|
\
|
|
189
183
|
Possible configurations:
|
|
190
184
|
|
|
191
|
-
| Attribute/Action
|
|
192
|
-
|
|
193
|
-
| create_another_media | By including this, a button will appear that allow you to recreate a media | Free text (string, inside button)
|
|
185
|
+
| Attribute/Action | Description | Option(s) |
|
|
186
|
+
|----------------------|----------------------------------------------------------------------------|-----------------------------------|
|
|
187
|
+
| create_another_media | By including this, a button will appear that allow you to recreate a media | Free text (string, inside button) |
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { OneOf } from '../interfaces/one-of.interface';
|
|
2
|
+
export declare class BaseFrameController<T extends Array<string>> {
|
|
3
|
+
readonly spawnElement: string;
|
|
4
|
+
readonly authToken: string | false;
|
|
5
|
+
readonly availableEvents: T;
|
|
6
|
+
private _url;
|
|
7
|
+
private _eventListeners;
|
|
8
|
+
private _readyForToken;
|
|
9
|
+
private _jwtToken;
|
|
10
|
+
private _frame;
|
|
11
|
+
private _readyForTokenCb;
|
|
12
|
+
constructor(spawnElement: string, authToken: string | false, uri: string, config: string, availableEvents: T, extraSearchParams?: Record<string, string>);
|
|
13
|
+
private _init;
|
|
14
|
+
private _spawn;
|
|
15
|
+
private _receiveMessage;
|
|
16
|
+
private _initiatePageListeners;
|
|
17
|
+
on(event: OneOf<T>, cb: (data: unknown) => void): this;
|
|
18
|
+
sendMessage(message: any): this;
|
|
19
|
+
setJwtToken(token: string): this;
|
|
20
|
+
destroy(): void;
|
|
21
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { BaseFrameController } from './BaseFrameController';
|
|
2
|
+
export declare const AVAILABLE_CREATE_MEDIA_EVENTS: ['loaded', 'created', 'batch-created', 'canceled'];
|
|
3
|
+
export interface ICreateMediaConfig {
|
|
4
|
+
creationType?: 'batch';
|
|
5
|
+
assetManagerScope?: Array<unknown>;
|
|
6
|
+
publish?: Array<{
|
|
7
|
+
type: string;
|
|
8
|
+
variant?: string;
|
|
9
|
+
parameters?: Array<string>;
|
|
10
|
+
}>;
|
|
11
|
+
mediaRecreateHash?: string;
|
|
12
|
+
ui?: {
|
|
13
|
+
customizationItems?: Array<{
|
|
14
|
+
item: string;
|
|
15
|
+
value: string | boolean;
|
|
16
|
+
}>;
|
|
17
|
+
endScreenActions?: Array<{
|
|
18
|
+
action: string;
|
|
19
|
+
value: string;
|
|
20
|
+
}>;
|
|
21
|
+
forceMediaPreviewBeforeCreate?: 'on_first_render' | 'always';
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
export declare class CreateMediaPage extends BaseFrameController<typeof AVAILABLE_CREATE_MEDIA_EVENTS> {
|
|
25
|
+
constructor(spawnElement: string, STAuthToken: string | false, templateId: number, config?: ICreateMediaConfig, companyId?: string);
|
|
26
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getFrameUrl(): string;
|
package/build/index.d.ts
ADDED
package/build/index.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("lodash-es")):"function"==typeof define&&define.amd?define(["lodash-es"],t):"object"==typeof exports?exports["@storyteq/platform-integration"]=t(require("lodash-es")):e["@storyteq/platform-integration"]=t(e._)}(this,(function(e){return function(){"use strict";var t={731:function(t){t.exports=e}},n={};function r(e){var s=n[e];if(void 0!==s)return s.exports;var i=n[e]={exports:{}};return t[e](i,i.exports,r),i.exports}r.d=function(e,t){for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var s={};return function(){r.r(s),r.d(s,{AVAILABLE_CREATE_MEDIA_EVENTS:function(){return n},CreateMediaPage:function(){return i},CrmAnalyticsPage:function(){return o}});var e=r(731);class t{constructor(t,n,r,s,i,o={}){this.spawnElement=t,this.authToken=n,this.availableEvents=i,this._eventListeners=[],this._readyForToken=!1,this._readyForTokenCb=()=>{this._readyForToken=!0,this._jwtToken&&(this.setJwtToken(this._jwtToken),this._jwtToken="")},this._receiveMessage=t=>{if(t.origin===this._url.origin)try{const n=JSON.parse(t.data);this._eventListeners.forEach((({event:t,cb:r})=>{const s=(0,e.omit)(n,["event"]);t===n.event&&r(s)}))}catch(e){console.error("[Storyteq platform integration] Failed to parse incoming frame message;",t.data)}},this._url=new URL(r,window.APP_URL??"https://platform.storyteq.com");const a={no_navigation:"true",config:s,...o};n?a.auth_token=n:(a.auth_via_message="",this._eventListeners.push({event:"ready_for_token",cb:this._readyForTokenCb})),(0,e.forEach)(a,((e,t)=>{this._url.searchParams.set(t,e)})),this._init()}_init(){["interactive","complete"].includes(document.readyState)?this._spawn():document.addEventListener("readystatechange",(()=>{["interactive","complete"].includes(document.readyState)&&this._spawn()}))}_spawn(){const e=document.createElement("iframe");e.src=this._url.toString(),e.style.width="100%",e.style.height="100%",e.style.position="absolute",e.style.border="none";const t=document.querySelector(this.spawnElement);t||console.error(`[Storyteq platform integration] Failed to find target element ${this.spawnElement}`),t.style.position="relative",t.appendChild(e),this._frame=e,this._initiatePageListeners()}_initiatePageListeners(){window.addEventListener("message",this._receiveMessage,!1)}on(e,t){return this.availableEvents.includes(e)||console.error(`[Storyteq platform integration] Trying to listen to unsupported event "${e}"`),this._eventListeners.push({event:e,cb:t}),this}sendMessage(e){return this._frame.contentWindow.postMessage(e,{targetOrigin:this._url.origin}),this}setJwtToken(e){return this._readyForToken?this.sendMessage({type:"JWT_TOKEN",token:e}):this._jwtToken=e,this}destroy(){if(this._frame){window.removeEventListener("message",this._receiveMessage),this._eventListeners=[];try{this._frame.parentElement.removeChild(this._frame)}catch(e){}}}}const n=["loaded","created","batch-created","canceled"];class i extends t{constructor(e,t,r,s={},i){super(e,t,"/integration",JSON.stringify(s),n,{company_id:i,templateId:`${r}`})}}class o extends t{constructor(e,t,n,r,s){super(e,t,`/campaigns/${r}/templates/${n}`,JSON.stringify(s),["loaded"])}}}(),s}()}));
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","mappings":"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","sources":["webpack://@storyteq/platform-integration/webpack/universalModuleDefinition","webpack://@storyteq/platform-integration/external umd {\"commonjs\":\"lodash-es\",\"commonjs2\":\"lodash-es\",\"amd\":\"lodash-es\",\"root\":\"_\"}","webpack://@storyteq/platform-integration/webpack/bootstrap","webpack://@storyteq/platform-integration/webpack/runtime/define property getters","webpack://@storyteq/platform-integration/webpack/runtime/hasOwnProperty shorthand","webpack://@storyteq/platform-integration/webpack/runtime/make namespace object","webpack://@storyteq/platform-integration/./src/classes/BaseFrameController.ts","webpack://@storyteq/platform-integration/./src/get-frame-url.ts","webpack://@storyteq/platform-integration/./src/classes/CreateMediaPage.ts","webpack://@storyteq/platform-integration/./src/classes/CrmAnalyticsPage.ts"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory(require(\"lodash-es\"));\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([\"lodash-es\"], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"@storyteq/platform-integration\"] = factory(require(\"lodash-es\"));\n\telse\n\t\troot[\"@storyteq/platform-integration\"] = factory(root[\"_\"]);\n})(this, function(__WEBPACK_EXTERNAL_MODULE__731__) {\nreturn ","module.exports = __WEBPACK_EXTERNAL_MODULE__731__;","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// define getter functions for harmony exports\n__webpack_require__.d = function(exports, definition) {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }","// define __esModule on exports\n__webpack_require__.r = function(exports) {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import { forEach, omit } from 'lodash-es';\nimport { getFrameUrl } from '../get-frame-url';\nimport { OneOf } from '../interfaces/one-of.interface';\n\nexport class BaseFrameController<T extends Array<string>> {\n private _url: URL;\n private _eventListeners: Array<{ event: string; cb: (data: unknown) => void }> = [];\n private _readyForToken = false;\n private _jwtToken: string;\n private _frame: HTMLIFrameElement;\n\n private _readyForTokenCb = () => {\n this._readyForToken = true;\n\n if (this._jwtToken) {\n this.setJwtToken(this._jwtToken);\n this._jwtToken = '';\n }\n };\n\n constructor(\n public readonly spawnElement: string,\n public readonly authToken: string | false,\n uri: string,\n config: string,\n public readonly availableEvents: T,\n extraSearchParams: Record<string, string> = {}\n ) {\n this._url = new URL(uri, getFrameUrl());\n\n const searchParams: Record<string, string> = {\n no_navigation: 'true',\n config: config,\n ...extraSearchParams,\n };\n\n if (authToken) {\n searchParams.auth_token = authToken;\n } else {\n searchParams.auth_via_message = '';\n\n this._eventListeners.push({ event: 'ready_for_token', cb: this._readyForTokenCb });\n }\n\n forEach(searchParams, (value: string, key: string) => {\n this._url.searchParams.set(key, value);\n });\n\n this._init();\n }\n\n private _init(): void {\n if (!['interactive', 'complete'].includes(document.readyState)) {\n document.addEventListener('readystatechange', () => {\n if (['interactive', 'complete'].includes(document.readyState)) this._spawn();\n });\n } else this._spawn();\n }\n\n private _spawn(): void {\n const iframe: HTMLIFrameElement = document.createElement('iframe');\n\n iframe.src = this._url.toString();\n iframe.style.width = '100%';\n iframe.style.height = '100%';\n iframe.style.position = 'absolute';\n iframe.style.border = 'none';\n\n const spawnElement: HTMLElement = document.querySelector(this.spawnElement);\n\n if (!spawnElement) {\n console.error(`[Storyteq platform integration] Failed to find target element ${this.spawnElement}`);\n }\n\n spawnElement.style.position = 'relative';\n spawnElement.appendChild(iframe);\n\n this._frame = iframe;\n\n this._initiatePageListeners();\n }\n\n private _receiveMessage = (e: MessageEvent) => {\n if (e.origin === this._url.origin) {\n try {\n const messagePayload = JSON.parse(e.data);\n\n this._eventListeners.forEach(({ event, cb }) => {\n const eventPayload = omit(messagePayload, ['event']);\n\n if (event === messagePayload.event) cb(eventPayload);\n });\n } catch (error) {\n console.error('[Storyteq platform integration] Failed to parse incoming frame message;', e.data);\n }\n }\n };\n\n private _initiatePageListeners(): void {\n window.addEventListener('message', this._receiveMessage, false);\n }\n\n public on(event: OneOf<T>, cb: (data: unknown) => void): this {\n if (!this.availableEvents.includes(event)) {\n console.error(`[Storyteq platform integration] Trying to listen to unsupported event \"${event}\"`);\n }\n\n this._eventListeners.push({\n event,\n cb,\n });\n\n return this;\n }\n\n public sendMessage(message: any): this {\n this._frame.contentWindow.postMessage(message, { targetOrigin: this._url.origin });\n\n return this;\n }\n\n public setJwtToken(token: string): this {\n if (!this._readyForToken) {\n this._jwtToken = token;\n } else {\n this.sendMessage({ type: 'JWT_TOKEN', token });\n }\n\n return this;\n }\n\n public destroy(): void {\n if (!this._frame) {\n return;\n }\n\n window.removeEventListener('message', this._receiveMessage);\n\n this._eventListeners = [];\n\n try {\n this._frame.parentElement.removeChild(this._frame);\n } catch (error) {}\n }\n}\n","export function getFrameUrl() {\n return window.APP_URL ?? 'https://platform.storyteq.com';\n}\n","import { BaseFrameController } from './BaseFrameController';\n\nexport const AVAILABLE_CREATE_MEDIA_EVENTS: ['loaded', 'created', 'batch-created', 'canceled'] = [\n 'loaded',\n 'created',\n 'batch-created',\n 'canceled',\n];\n\nexport interface ICreateMediaConfig {\n creationType?: 'batch';\n assetManagerScope?: Array<unknown>; // Scope the asset selection to a set of asset providers\n publish?: Array<{ type: string; variant?: string; parameters?: Array<string> }>; // Upon rendering completion, publish to this channel\n mediaRecreateHash?: string;\n ui?: {\n customizationItems?: Array<{ item: string; value: string | boolean }>;\n endScreenActions?: Array<{ action: string; value: string }>;\n forceMediaPreviewBeforeCreate?: 'on_first_render' | 'always';\n }; // Customize the UI\n}\nexport class CreateMediaPage extends BaseFrameController<typeof AVAILABLE_CREATE_MEDIA_EVENTS> {\n constructor(\n spawnElement: string,\n STAuthToken: string | false,\n templateId: number,\n config: ICreateMediaConfig = {},\n companyId?: string\n ) {\n const page = `/integration`;\n\n super(spawnElement, STAuthToken, page, JSON.stringify(config), AVAILABLE_CREATE_MEDIA_EVENTS, {\n company_id: companyId,\n templateId: `${templateId}`,\n });\n }\n}\n","import { BaseFrameController } from './BaseFrameController';\n\nexport class CrmAnalyticsPage extends BaseFrameController<['loaded']> {\n constructor(spawnElement: string, STAuthToken: string | false, templateId: number, campaignId: number, config?) {\n const page = `/campaigns/${campaignId}/templates/${templateId}`;\n\n super(spawnElement, STAuthToken, page, JSON.stringify(config), ['loaded']);\n }\n}\n"],"names":["root","factory","exports","module","require","define","amd","this","__WEBPACK_EXTERNAL_MODULE__731__","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","undefined","__webpack_modules__","d","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","r","Symbol","toStringTag","value","BaseFrameController","constructor","spawnElement","authToken","uri","config","availableEvents","extraSearchParams","_eventListeners","_readyForToken","_readyForTokenCb","_jwtToken","setJwtToken","_receiveMessage","e","origin","_url","messagePayload","JSON","parse","data","forEach","event","cb","eventPayload","omit","error","console","URL","window","APP_URL","searchParams","no_navigation","auth_token","auth_via_message","push","set","_init","includes","document","readyState","_spawn","addEventListener","iframe","createElement","src","toString","style","width","height","position","border","querySelector","appendChild","_frame","_initiatePageListeners","on","sendMessage","message","contentWindow","postMessage","targetOrigin","token","type","destroy","removeEventListener","parentElement","removeChild","AVAILABLE_CREATE_MEDIA_EVENTS","CreateMediaPage","STAuthToken","templateId","companyId","super","stringify","company_id","CrmAnalyticsPage","campaignId"],"sourceRoot":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type OneOf<T extends Array<unknown>> = T extends Array<infer U> ? U : void;
|
package/build/test.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storyteq/platform-integration",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "Integrate with views from the Storyteq platform",
|
|
5
|
-
"main": "
|
|
5
|
+
"main": "build/index.js",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"build": "
|
|
7
|
+
"build": "webpack --config webpack/webpack.config.prod.js",
|
|
8
8
|
"start": "webpack-dev-server --open --config webpack/webpack.config.dev.js",
|
|
9
|
-
"release": "standard-version"
|
|
9
|
+
"release": "standard-version",
|
|
10
|
+
"prepack": "npm run build"
|
|
10
11
|
},
|
|
11
12
|
"repository": {
|
|
12
13
|
"type": "git",
|
|
13
|
-
"url": "git
|
|
14
|
+
"url": "git+https://github.com/storyteq/platform-integration.git"
|
|
14
15
|
},
|
|
15
16
|
"keywords": [
|
|
16
17
|
"storyteq"
|
|
@@ -18,34 +19,26 @@
|
|
|
18
19
|
"author": "Storyteq",
|
|
19
20
|
"license": "MIT",
|
|
20
21
|
"devDependencies": {
|
|
21
|
-
"@
|
|
22
|
-
"@
|
|
23
|
-
"@
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"webpack": "^4.43.0",
|
|
40
|
-
"webpack-cli": "^3.3.11",
|
|
41
|
-
"webpack-dev-server": "^3.11.0",
|
|
42
|
-
"webpack-merge": "^4.2.2"
|
|
22
|
+
"@types/lodash-es": "^4.17.7",
|
|
23
|
+
"@typescript-eslint/eslint-plugin": "^5.0.0",
|
|
24
|
+
"@typescript-eslint/parser": "^5.0.0",
|
|
25
|
+
"clean-webpack-plugin": "^4.0.0",
|
|
26
|
+
"copy-webpack-plugin": "^11.0.0",
|
|
27
|
+
"eslint": "^8.37.0",
|
|
28
|
+
"eslint-config-prettier": "^8.3.0",
|
|
29
|
+
"eslint-plugin-prettier": "^4.0.0",
|
|
30
|
+
"file-loader": "^6.2.0",
|
|
31
|
+
"html-webpack-plugin": "^5.5.0",
|
|
32
|
+
"prettier": "^2.3.2",
|
|
33
|
+
"standard-version": "^9.5.0",
|
|
34
|
+
"typescript": "^5.0.3",
|
|
35
|
+
"ts-loader": "^9.4.2",
|
|
36
|
+
"webpack": "^5.77.0",
|
|
37
|
+
"webpack-cli": "^5.0.1",
|
|
38
|
+
"webpack-dev-server": "^4.13.1",
|
|
39
|
+
"webpack-merge": "^5.8.0"
|
|
43
40
|
},
|
|
44
41
|
"dependencies": {
|
|
45
|
-
"
|
|
46
|
-
"core-js": "^3.6.5",
|
|
47
|
-
"dotenv-webpack": "^1.8.0",
|
|
48
|
-
"lodash.omit": "^4.5.0",
|
|
49
|
-
"query-string": "^6.13.1"
|
|
42
|
+
"lodash-es": "^4.17.21"
|
|
50
43
|
}
|
|
51
44
|
}
|
package/.babelrc
DELETED
package/.browserslistrc
DELETED
package/.dependabot/config.yml
DELETED
package/.env.example
DELETED
package/.eslintrc
DELETED
package/.travis.yml
DELETED
package/public/.gitkeep
DELETED
|
File without changes
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import omit from 'lodash.omit';
|
|
2
|
-
import queryString from 'query-string';
|
|
3
|
-
import activeFrameUrl from '../get-frame-url.js';
|
|
4
|
-
|
|
5
|
-
class BaseFrameController {
|
|
6
|
-
constructor(spawnElement, authToken, uri, config, templateId) {
|
|
7
|
-
this.spawnElement = spawnElement;
|
|
8
|
-
const queryParams = queryString.stringify({ no_navigation: true, config });
|
|
9
|
-
this.url = `${activeFrameUrl()}${uri}?auth_token=${authToken}&templateId=${templateId}&${queryParams}`;
|
|
10
|
-
this._init();
|
|
11
|
-
this.eventListeners = [];
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
_init() {
|
|
15
|
-
if (!['interactive', 'complete'].includes(document.readyState)) {
|
|
16
|
-
document.addEventListener('readystatechange', () => {
|
|
17
|
-
if (['interactive', 'complete'].includes(document.readyState)) this._spawn();
|
|
18
|
-
});
|
|
19
|
-
} else this._spawn();
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
_spawn() {
|
|
23
|
-
const iframe = document.createElement('iframe');
|
|
24
|
-
iframe.src = this.url;
|
|
25
|
-
iframe.frameBorder = '0';
|
|
26
|
-
iframe.style.width = '100%';
|
|
27
|
-
iframe.style.height = '100%';
|
|
28
|
-
iframe.style.position = 'absolute';
|
|
29
|
-
|
|
30
|
-
const spawnElement = document.querySelector(this.spawnElement);
|
|
31
|
-
if (!spawnElement) console.error(`[Storyteq platform integration] Failed to find target element ${this.spawnElement}`);
|
|
32
|
-
spawnElement.style.position = 'relative';
|
|
33
|
-
spawnElement.appendChild(iframe);
|
|
34
|
-
|
|
35
|
-
this.frame = iframe;
|
|
36
|
-
this._initiatePageListeners();
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
_initiatePageListeners() {
|
|
40
|
-
const receiveMessage = (e) => {
|
|
41
|
-
try {
|
|
42
|
-
const messagePayload = JSON.parse(e.data);
|
|
43
|
-
this.eventListeners
|
|
44
|
-
.forEach(({ event, cb }) => {
|
|
45
|
-
const eventPayload = omit(messagePayload, ['event']);
|
|
46
|
-
if (event === messagePayload.event) cb(eventPayload);
|
|
47
|
-
});
|
|
48
|
-
} catch (error) {
|
|
49
|
-
console.error('[Storyteq platform integration] Failed to parse incoming frame message;', e.data);
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
window.addEventListener('message', receiveMessage, false);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
on(event, cb) {
|
|
56
|
-
if (!this.availableEvents.includes(event)) console.error(`[Storyteq platform integration] Trying to listen to unsupported event "${event}"`);
|
|
57
|
-
this.eventListeners.push({
|
|
58
|
-
event,
|
|
59
|
-
cb,
|
|
60
|
-
});
|
|
61
|
-
return this;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
destroy() {
|
|
65
|
-
if (!this.frame) return;
|
|
66
|
-
this.eventListeners = [];
|
|
67
|
-
try {
|
|
68
|
-
this.frame.parentElement.removeChild(this.frame);
|
|
69
|
-
} catch (error) {}
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
export default BaseFrameController;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import BaseFrameController from './BaseFrameController';
|
|
2
|
-
|
|
3
|
-
class CreateMediaPage extends BaseFrameController{
|
|
4
|
-
constructor(spawnElement, STauthToken, templateId, config) {
|
|
5
|
-
const page = '/integration';
|
|
6
|
-
super(spawnElement, STauthToken, page, JSON.stringify(config), templateId);
|
|
7
|
-
this.availableEvents = [
|
|
8
|
-
'loaded',
|
|
9
|
-
'created',
|
|
10
|
-
'batch-created',
|
|
11
|
-
];
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export default CreateMediaPage;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import BaseFrameController from './BaseFrameController';
|
|
2
|
-
|
|
3
|
-
class CrmAnalyticsPage extends BaseFrameController {
|
|
4
|
-
constructor(spawnElement, STauthToken, templateId, campaignId, config) {
|
|
5
|
-
const page = `/campaigns/${campaignId}/templates/${templateId}`;
|
|
6
|
-
super(spawnElement, STauthToken, page, JSON.stringify(config));
|
|
7
|
-
this.availableEvents = [
|
|
8
|
-
'loaded',
|
|
9
|
-
];
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export default CrmAnalyticsPage;
|
package/src/get-frame-url.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default () => typeof window.APP_URL !== 'undefined' ? window.APP_URL : 'https://platform.storyteq.com';
|
package/src/index.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
const isTesting = (process && process.env && process.env.ENVIRONMENT === 'testing');
|
|
2
|
-
if (isTesting) {
|
|
3
|
-
window.APP_URL = 'https://platform.storyteq.com';
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
import CreateMediaPage from './classes/CreateMediaPage';
|
|
7
|
-
import CrmAnalyticsPage from './classes/CrmAnalyticsPage';
|
|
8
|
-
|
|
9
|
-
if (isTesting) {
|
|
10
|
-
// const createMediaPage = new CreateMediaPage(
|
|
11
|
-
// '#frame-tester',
|
|
12
|
-
// process.env.TEST_API_KEY,
|
|
13
|
-
// 1077,
|
|
14
|
-
// {
|
|
15
|
-
// publish: [
|
|
16
|
-
// {
|
|
17
|
-
// type: 'brandfolder',
|
|
18
|
-
// },
|
|
19
|
-
// ],
|
|
20
|
-
// }
|
|
21
|
-
// );
|
|
22
|
-
|
|
23
|
-
// createMediaPage
|
|
24
|
-
// .on('loaded', (pl) => console.log('loaded', pl))
|
|
25
|
-
// .on('created', (media) => console.log('CREATED', media));
|
|
26
|
-
|
|
27
|
-
const crmAnalyticsPage = new CrmAnalyticsPage(
|
|
28
|
-
'#frame-tester',
|
|
29
|
-
process.env.TEST_API_KEY,
|
|
30
|
-
115,
|
|
31
|
-
15
|
|
32
|
-
);
|
|
33
|
-
|
|
34
|
-
crmAnalyticsPage
|
|
35
|
-
.on('loaded', (pl) => console.log('loaded', pl));
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
export default {
|
|
41
|
-
createMediaPage: CreateMediaPage,
|
|
42
|
-
crmAnalyticsPage: CrmAnalyticsPage,
|
|
43
|
-
};
|
package/src/test.html
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8">
|
|
5
|
-
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
6
|
-
<style>
|
|
7
|
-
body {
|
|
8
|
-
padding: 0;
|
|
9
|
-
margin: 0;
|
|
10
|
-
}
|
|
11
|
-
</style>
|
|
12
|
-
</head>
|
|
13
|
-
<body>
|
|
14
|
-
<div id="frame-tester" style="width: 1000px; height: 500px;"></div>
|
|
15
|
-
</body>
|
|
16
|
-
</html>
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
const Path = require('path');
|
|
2
|
-
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
|
|
3
|
-
const CopyWebpackPlugin = require('copy-webpack-plugin');
|
|
4
|
-
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
|
5
|
-
const Dotenv = require('dotenv-webpack');
|
|
6
|
-
|
|
7
|
-
module.exports = {
|
|
8
|
-
entry: {
|
|
9
|
-
app: Path.resolve(__dirname, '../src/index.js'),
|
|
10
|
-
},
|
|
11
|
-
output: {
|
|
12
|
-
path: Path.join(__dirname, '../build'),
|
|
13
|
-
filename: 'js/[name].js',
|
|
14
|
-
},
|
|
15
|
-
optimization: {
|
|
16
|
-
splitChunks: {
|
|
17
|
-
chunks: 'all',
|
|
18
|
-
name: false,
|
|
19
|
-
},
|
|
20
|
-
},
|
|
21
|
-
plugins: [
|
|
22
|
-
new Dotenv(),
|
|
23
|
-
new CleanWebpackPlugin(),
|
|
24
|
-
new CopyWebpackPlugin({ patterns: [{ from: Path.resolve(__dirname, '../public'), to: 'public' }] }),
|
|
25
|
-
new HtmlWebpackPlugin({
|
|
26
|
-
template: Path.resolve(__dirname, '../src/test.html'),
|
|
27
|
-
}),
|
|
28
|
-
],
|
|
29
|
-
resolve: {
|
|
30
|
-
alias: {
|
|
31
|
-
'~': Path.resolve(__dirname, '../src'),
|
|
32
|
-
},
|
|
33
|
-
},
|
|
34
|
-
module: {
|
|
35
|
-
rules: [
|
|
36
|
-
{
|
|
37
|
-
test: /\.mjs$/,
|
|
38
|
-
include: /node_modules/,
|
|
39
|
-
type: 'javascript/auto',
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
test: /\.(ico|jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2)(\?.*)?$/,
|
|
43
|
-
use: {
|
|
44
|
-
loader: 'file-loader',
|
|
45
|
-
options: {
|
|
46
|
-
name: '[path][name].[ext]',
|
|
47
|
-
},
|
|
48
|
-
},
|
|
49
|
-
},
|
|
50
|
-
],
|
|
51
|
-
},
|
|
52
|
-
};
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
const Path = require('path');
|
|
2
|
-
const Webpack = require('webpack');
|
|
3
|
-
const merge = require('webpack-merge');
|
|
4
|
-
const common = require('./webpack.common.js');
|
|
5
|
-
|
|
6
|
-
module.exports = merge(common, {
|
|
7
|
-
mode: 'development',
|
|
8
|
-
devtool: 'cheap-eval-source-map',
|
|
9
|
-
output: {
|
|
10
|
-
chunkFilename: 'js/[name].chunk.js'
|
|
11
|
-
},
|
|
12
|
-
devServer: {
|
|
13
|
-
inline: true,
|
|
14
|
-
hot: true
|
|
15
|
-
},
|
|
16
|
-
plugins: [
|
|
17
|
-
new Webpack.DefinePlugin({
|
|
18
|
-
'process.env.NODE_ENV': JSON.stringify('development')
|
|
19
|
-
})
|
|
20
|
-
],
|
|
21
|
-
module: {
|
|
22
|
-
rules: [
|
|
23
|
-
{
|
|
24
|
-
test: /\.js$/,
|
|
25
|
-
include: Path.resolve(__dirname, '../src'),
|
|
26
|
-
enforce: 'pre',
|
|
27
|
-
loader: 'eslint-loader',
|
|
28
|
-
options: {
|
|
29
|
-
emitWarning: true
|
|
30
|
-
}
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
test: /\.js$/,
|
|
34
|
-
include: Path.resolve(__dirname, '../src'),
|
|
35
|
-
loader: 'babel-loader'
|
|
36
|
-
}
|
|
37
|
-
]
|
|
38
|
-
}
|
|
39
|
-
});
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
const Webpack = require('webpack');
|
|
2
|
-
const merge = require('webpack-merge');
|
|
3
|
-
const common = require('./webpack.common.js');
|
|
4
|
-
|
|
5
|
-
module.exports = merge(common, {
|
|
6
|
-
mode: 'production',
|
|
7
|
-
devtool: 'source-map',
|
|
8
|
-
stats: 'errors-only',
|
|
9
|
-
bail: true,
|
|
10
|
-
output: {
|
|
11
|
-
filename: 'js/[name].js'
|
|
12
|
-
},
|
|
13
|
-
plugins: [
|
|
14
|
-
new Webpack.DefinePlugin({
|
|
15
|
-
'process.env.NODE_ENV': JSON.stringify('production')
|
|
16
|
-
}),
|
|
17
|
-
new Webpack.optimize.ModuleConcatenationPlugin(),
|
|
18
|
-
],
|
|
19
|
-
module: {
|
|
20
|
-
rules: [
|
|
21
|
-
{
|
|
22
|
-
test: /\.js$/,
|
|
23
|
-
exclude: /node_modules/,
|
|
24
|
-
use: 'babel-loader'
|
|
25
|
-
},
|
|
26
|
-
]
|
|
27
|
-
}
|
|
28
|
-
});
|