proca 0.8.1 → 1.1.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 (106) hide show
  1. package/README.md +1079 -28
  2. package/package.json +94 -101
  3. package/proca-cli +8 -0
  4. package/src/commands/action/count.mjs +61 -0
  5. package/src/commands/action/list.mjs +204 -0
  6. package/src/commands/action/replay.mjs +54 -0
  7. package/src/commands/campaign/add.mjs +101 -0
  8. package/src/commands/campaign/delete.mjs +61 -0
  9. package/src/commands/campaign/get.mjs +107 -0
  10. package/src/commands/campaign/list.mjs +156 -0
  11. package/src/commands/campaign/queries.graphql +19 -0
  12. package/src/commands/config/add.mjs +101 -0
  13. package/src/commands/config/get.mjs +33 -0
  14. package/src/commands/config/set.mjs +103 -0
  15. package/src/commands/config/token.mjs +34 -0
  16. package/src/commands/config/user.mjs +76 -0
  17. package/src/commands/org/add.mjs +66 -0
  18. package/src/commands/org/crm.mjs +88 -0
  19. package/src/commands/org/delete.mjs +48 -0
  20. package/src/commands/org/get.mjs +97 -0
  21. package/src/commands/org/join.mjs +77 -0
  22. package/src/commands/supporter/count.mjs +96 -0
  23. package/src/commands/user/get.mjs +91 -0
  24. package/src/commands/user/leave.mjs +52 -0
  25. package/src/commands/user/list.mjs +71 -0
  26. package/src/commands/widget/add.mjs +101 -0
  27. package/src/commands/widget/cache.mjs +29 -0
  28. package/src/commands/widget/get.mjs +59 -0
  29. package/src/commands/widget/list.mjs +116 -0
  30. package/src/config.mjs +36 -0
  31. package/src/generated/schema.json +10677 -0
  32. package/src/hooks/help.mjs +14 -0
  33. package/src/hooks/init.mjs +20 -0
  34. package/src/index.mjs +1 -0
  35. package/src/procaCommand.mjs +242 -0
  36. package/src/queries/campaign.mjs +21 -0
  37. package/src/queries/widget.mjs +12 -0
  38. package/src/urql.mjs +60 -0
  39. package/src/util/twitter.mjs +23 -0
  40. package/theme.json +29 -0
  41. package/LICENSE +0 -661
  42. package/dist/App.css +0 -22
  43. package/dist/App.js +0 -25
  44. package/dist/App.test.js +0 -8
  45. package/dist/Wizard.js +0 -32
  46. package/dist/components/Alert.js +0 -49
  47. package/dist/components/Clickify.js +0 -26
  48. package/dist/components/Consent.js +0 -120
  49. package/dist/components/Country.js +0 -94
  50. package/dist/components/Dialog.js +0 -84
  51. package/dist/components/Disabled.js +0 -3
  52. package/dist/components/Emoji.js +0 -12
  53. package/dist/components/FAB.js +0 -70
  54. package/dist/components/Html.js +0 -56
  55. package/dist/components/Loader.js +0 -14
  56. package/dist/components/Openletter.js +0 -443
  57. package/dist/components/Organisation.js +0 -181
  58. package/dist/components/Petition.js +0 -16
  59. package/dist/components/ProcaRoot.js +0 -23
  60. package/dist/components/ProcaStyle.js +0 -94
  61. package/dist/components/ProgressCounter.js +0 -64
  62. package/dist/components/Register.js +0 -345
  63. package/dist/components/Share.js +0 -177
  64. package/dist/components/TextField.js +0 -58
  65. package/dist/components/Twitter.js +0 -127
  66. package/dist/components/TwitterAction.js +0 -111
  67. package/dist/components/TwitterList.js +0 -25
  68. package/dist/components/TwitterText.js +0 -42
  69. package/dist/components/Widget.js +0 -266
  70. package/dist/components/bespoke/Download.js +0 -49
  71. package/dist/components/bespoke/Register-CH.js +0 -505
  72. package/dist/data/countries.json +0 -114
  73. package/dist/hooks/useConfig.js +0 -217
  74. package/dist/hooks/useCount.js +0 -95
  75. package/dist/hooks/useData.js +0 -59
  76. package/dist/hooks/useElementWidth.js +0 -46
  77. package/dist/hooks/useGeoLocation.js +0 -45
  78. package/dist/hooks/useLayout.js +0 -63
  79. package/dist/images/Twitter.js +0 -16
  80. package/dist/images/Twitter.svg +0 -1
  81. package/dist/index.css +0 -13
  82. package/dist/index.js +0 -114
  83. package/dist/lib/domparser.js +0 -12
  84. package/dist/lib/i18n.js +0 -40
  85. package/dist/lib/init.js +0 -7
  86. package/dist/lib/server.js +0 -331
  87. package/dist/lib/urlparser.js +0 -65
  88. package/dist/lib/uuid.js +0 -30
  89. package/dist/locales/README.md +0 -37
  90. package/dist/locales/common.json +0 -189
  91. package/dist/locales/de/common.json +0 -46
  92. package/dist/locales/de/index.js +0 -0
  93. package/dist/locales/en/common.json +0 -45
  94. package/dist/locales/fr/common.json +0 -51
  95. package/dist/locales/index.js +0 -27
  96. package/dist/locales/it/common.json +0 -46
  97. package/dist/logo.svg +0 -1
  98. package/dist/module.js +0 -14
  99. package/dist/slingshot.xcf +0 -0
  100. package/dist/tmp.config/0.json +0 -21
  101. package/dist/tmp.config/2.json +0 -11
  102. package/dist/tmp.config/20.json +0 -29
  103. package/dist/tmp.config/28.json +0 -14
  104. package/dist/tmp.config/32.json +0 -34
  105. package/dist/tmp.config/35.json +0 -14
  106. package/dist/tmp.config/null.json +0 -1
package/dist/index.js DELETED
@@ -1,114 +0,0 @@
1
- function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
2
-
3
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
4
-
5
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
6
-
7
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
8
-
9
- import React from "react";
10
- import ReactDOM from "react-dom";
11
- import "./lib/i18n";
12
- import { setGlobalState, setConfig, goStep, hook } from "./hooks/useConfig";
13
- import ProcaWidget from "./components/Widget.js";
14
- import ProcaAlert from "./components/Alert.js";
15
- import Config from "Config"; // src/tmp.config/{actionpage}.json
16
-
17
- import { initDataState } from "./hooks/useData"; //console.log(querystring);
18
-
19
- var config = {
20
- selector: "#signature-form"
21
- };
22
-
23
- var Alert = function Alert(text, severity) {
24
- var selector = "proca_alert";
25
-
26
- if (!document.querySelector('#' + selector)) {
27
- var elem = document.createElement("div");
28
- elem.id = selector;
29
- document.body.appendChild(elem);
30
- }
31
-
32
- ReactDOM.render( /*#__PURE__*/React.createElement(ProcaAlert, {
33
- text: text,
34
- severity: severity
35
- }), document.querySelector('#' + selector));
36
- };
37
-
38
- var getYAMLConfig = function getYAMLConfig() {
39
- // legacy mode, taking the config from config/{widget}.yaml
40
- if (process.widget.journey) config.journey = process.widget.journey;
41
- if (process.widget.lang) config.lang = process.widget.lang;
42
- config.organisation = process.widget.organisation || "missing organisation name";
43
- if (process.widget.twitter_targets) config.targets = {
44
- twitter_url: process.widget.twitter_targets
45
- };
46
- if (process.widget.actionpage) config.actionPage = process.widget.actionpage;
47
- if (process.widget.actionurl) config.actionUrl = process.widget.actionurl;
48
- if (process.widget.privacy_url) config.privacyUrl = process.widget.privacy_url;
49
- };
50
-
51
- var Widget = function Widget(args) {
52
- if (args) config = _objectSpread({}, config, {}, args); //compile directives, you can't use process.widget[step]
53
-
54
- if (!Config) // no config in src/config/{actionID}
55
- getYAMLConfig();else config = _objectSpread({}, config, {}, Config);
56
- document.querySelectorAll('.proca').forEach(function (dom) {
57
- return dom.style.display = "none";
58
- });
59
-
60
- if (!document.querySelector(config.selector)) {
61
- var elem = document.createElement("div");
62
- elem.id = "proca-widget";
63
- config.selector = "#" + elem.id;
64
- document.body.appendChild(elem);
65
- } //<ProcaWidget config={config} {...config} />,
66
-
67
-
68
- ReactDOM.render( /*#__PURE__*/React.createElement(ProcaWidget, config), document.querySelector(config.selector));
69
- };
70
-
71
- Widget.jump = function (step) {
72
- // if step is empty, jump to next
73
- ProcaWidget.action();
74
- };
75
-
76
- var go = function go(action) {
77
- goStep(action);
78
- };
79
-
80
- var set = function set(atom, key, value) {
81
- config[key] = value; // pointless?
82
-
83
- if (atom && key && value || atom && _typeof(key) === 'object') return setGlobalState(atom, key, value);
84
- setConfig(key, value);
85
- };
86
-
87
- var render = function render() {
88
- try {
89
- var script = document.getElementById("proca");
90
- if (!script) return; //todo: blacklist some param?
91
-
92
- initDataState(script.dataset);
93
- Widget(_objectSpread({}, script.dataset));
94
- } catch (e) {
95
- console.log(e);
96
- }
97
- };
98
-
99
- var autoRender = function autoRender() {
100
- if (window.proca) {
101
- console.log("Powered by proca.foundation");
102
- }
103
-
104
- try {
105
- if (!(document.readyState === "complete" || document.readyState === "loaded")) document.addEventListener("DOMContentLoaded", render);else {
106
- render();
107
- }
108
- } catch (e) {
109
- console.log(e);
110
- }
111
- };
112
-
113
- autoRender();
114
- export { Widget, Alert, set, go, hook, React, ReactDOM }; // <SignatureForm margin= "dense" variant= "filled" />
@@ -1,12 +0,0 @@
1
- var getData = function getData(key, selector) {
2
- var dom = document.querySelector(selector);
3
- return dom.dataset[key];
4
- };
5
-
6
- var getAllData = function getAllData(selector) {
7
- var dom = document.querySelector(selector);
8
- return dom.dataset;
9
- };
10
-
11
- export { getData, getAllData };
12
- export default getData;
package/dist/lib/i18n.js DELETED
@@ -1,40 +0,0 @@
1
- import i18n from "i18next"; //import LanguageDetector from "i18next-browser-languagedetector";
2
-
3
- import { initReactI18next } from "react-i18next";
4
- import locales from "../locales/common.json"; // locales is an alias to src/locales/{process.widget.lang}
5
-
6
- var resources = {};
7
-
8
- if (process.widget) {
9
- resources[process.widget.lang.toLowerCase()] = {
10
- common: locales
11
- };
12
- } else {
13
- resources = {
14
- common: locales
15
- }; // npm published, put all languages
16
-
17
- process.widget = {
18
- lang: "en"
19
- };
20
- }
21
-
22
- i18n // .use(LanguageDetector)
23
- .use(initReactI18next).init({
24
- // we init with resources
25
- resources: resources,
26
- languages: process.widget.lang.toLowerCase(),
27
- lng: process.widget.lang.toLowerCase(),
28
- fallbackLng: "en",
29
- // debug: true,
30
- // have a common namespace used around the full app
31
- ns: ["common"],
32
- defaultNS: "common",
33
- react: {
34
- transSupportBasicHtmlNodes: true
35
- },
36
- interpolation: {
37
- escapeValue: false
38
- }
39
- });
40
- export default i18n;
package/dist/lib/init.js DELETED
@@ -1,7 +0,0 @@
1
- import { initConfigState } from "../hooks/useConfig";
2
- import { initDataState } from "../hooks/useData";
3
- export default function init(config, data) {
4
- initConfigState(config);
5
- initDataState(data);
6
- }
7
- ;
@@ -1,331 +0,0 @@
1
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
-
3
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
4
-
5
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
6
-
7
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
8
-
9
- function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
10
-
11
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
12
-
13
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
14
-
15
- function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
16
-
17
- function graphQL(_x, _x2, _x3) {
18
- return _graphQL.apply(this, arguments);
19
- }
20
-
21
- function _graphQL() {
22
- _graphQL = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(operation, query, options) {
23
- var data, headers;
24
- return regeneratorRuntime.wrap(function _callee$(_context) {
25
- while (1) {
26
- switch (_context.prev = _context.next) {
27
- case 0:
28
- if (!options) options = {};
29
- if (!options.apiUrl) options.apiUrl = process.env.REACT_APP_API_URL || process.env.API_URL;
30
- data = null;
31
- headers = {
32
- "Content-Type": "application/json",
33
- Accept: "application/json"
34
- };
35
-
36
- if (options.authorization) {
37
- // var auth = 'Basic ' + Buffer.from(options.authorization.username + ':' + options.authorization.username.password).toString('base64');
38
- headers.Authorization = "Basic " + options.authorization;
39
- }
40
-
41
- _context.next = 7;
42
- return fetch(process.env.REACT_APP_API_URL || process.env.API_URL, {
43
- method: "POST",
44
- headers: headers,
45
- body: JSON.stringify({
46
- query: query,
47
- variables: options.variables,
48
- operationName: operation || ""
49
- })
50
- }).then(function (res) {
51
- if (!res.ok) {
52
- return {
53
- errors: [{
54
- message: res.statusText,
55
- code: "http_error",
56
- status: res.status
57
- }]
58
- };
59
- }
60
-
61
- return res.json();
62
- }).then(function (response) {
63
- if (response.errors) {
64
- response.errors.forEach(function (error) {
65
- return console.log(error.message);
66
- });
67
- data = response;
68
- return;
69
- }
70
-
71
- data = response.data;
72
- }).catch(function (error) {
73
- console.log(error);
74
- data = {
75
- errors: [{
76
- code: 'network',
77
- message: error
78
- }]
79
- };
80
- return;
81
- });
82
-
83
- case 7:
84
- return _context.abrupt("return", data);
85
-
86
- case 8:
87
- case "end":
88
- return _context.stop();
89
- }
90
- }
91
- }, _callee);
92
- }));
93
- return _graphQL.apply(this, arguments);
94
- }
95
-
96
- function getCount(_x4) {
97
- return _getCount.apply(this, arguments);
98
- }
99
-
100
- function _getCount() {
101
- _getCount = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(actionPage) {
102
- var query, url, data;
103
- return regeneratorRuntime.wrap(function _callee2$(_context2) {
104
- while (1) {
105
- switch (_context2.prev = _context2.next) {
106
- case 0:
107
- //actionCount {actionType, count}
108
- query = "query getCount($actionPage: ID!)\n{actionPage(id:$actionPage) {\n campaign {\n stats {\n supporterCount\n }\n }\n}}\n";
109
- query = query.replace(/(\n)/gm, "").replace(/\s\s+/g, " ");
110
- url = (process.env.REACT_APP_API_URL || process.env.API_URL) + "?query=" + encodeURIComponent(query) + "&variables=" + encodeURIComponent('{"actionPage":' + Number(actionPage) + "}");
111
- data = null;
112
- _context2.next = 6;
113
- return fetch(url).then(function (res) {
114
- if (!res.ok) {
115
- return {
116
- errors: [{
117
- message: res.statusText,
118
- code: "http_error",
119
- status: res.status
120
- }]
121
- };
122
- }
123
-
124
- return res.json();
125
- }).then(function (response) {
126
- if (response.errors) {
127
- response.errors.forEach(function (error) {
128
- return console.log(error.message);
129
- });
130
- data = response;
131
- return;
132
- }
133
-
134
- data = response.data;
135
- }).catch(function (error) {
136
- console.log(error);
137
- data = {
138
- errors: [error],
139
- code: "http_error"
140
- };
141
- return;
142
- });
143
-
144
- case 6:
145
- if (!(!data || data.errors)) {
146
- _context2.next = 8;
147
- break;
148
- }
149
-
150
- return _context2.abrupt("return", null);
151
-
152
- case 8:
153
- return _context2.abrupt("return", data.actionPage.campaign.stats.supporterCount);
154
-
155
- case 9:
156
- case "end":
157
- return _context2.stop();
158
- }
159
- }
160
- }, _callee2);
161
- }));
162
- return _getCount.apply(this, arguments);
163
- }
164
-
165
- function getCountByUrl(_x5) {
166
- return _getCountByUrl.apply(this, arguments);
167
- }
168
-
169
- function _getCountByUrl() {
170
- _getCountByUrl = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3(url) {
171
- var query, response;
172
- return regeneratorRuntime.wrap(function _callee3$(_context3) {
173
- while (1) {
174
- switch (_context3.prev = _context3.next) {
175
- case 0:
176
- query = "query getCountByUrl($url:String)\n{actionPage(url:$url){id,campaign{name,title,\n externalId,stats{supporterCount }}}}\n";
177
- _context3.next = 3;
178
- return graphQL("getCountByUrl", query, {
179
- variables: {
180
- "url": url
181
- }
182
- });
183
-
184
- case 3:
185
- response = _context3.sent;
186
-
187
- if (!(!response || response.errors)) {
188
- _context3.next = 6;
189
- break;
190
- }
191
-
192
- return _context3.abrupt("return", response);
193
-
194
- case 6:
195
- return _context3.abrupt("return", {
196
- total: response.actionPage.campaign.stats.supporterCount,
197
- actionPage: response.actionPage.id
198
- });
199
-
200
- case 7:
201
- case "end":
202
- return _context3.stop();
203
- }
204
- }
205
- }, _callee3);
206
- }));
207
- return _getCountByUrl.apply(this, arguments);
208
- }
209
-
210
- function addAction(_x6, _x7, _x8) {
211
- return _addAction.apply(this, arguments);
212
- }
213
-
214
- function _addAction() {
215
- _addAction = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4(actionPage, actionType, data) {
216
- var query, variables, response;
217
- return regeneratorRuntime.wrap(function _callee4$(_context4) {
218
- while (1) {
219
- switch (_context4.prev = _context4.next) {
220
- case 0:
221
- query = "mutation addAction (\n $contact: ID!, \n $actionPage: ID!,\n $actionType: String!,\n $payload: [CustomFieldInput!],\n $tracking: TrackingInput) \n{\n addAction (actionPageId: $actionPage, action: { actionType: $actionType, fields: $payload}\n contactRef: $contact, tracking: $tracking) \n {contactRef}\n}";
222
- variables = {
223
- actionPage: actionPage,
224
- actionType: actionType,
225
- payload: data.payload,
226
- contact: data.uuid
227
- };
228
-
229
- if (data.tracking && Object.keys(data.tracking).length) {
230
- variables.tracking = data.tracking;
231
- }
232
-
233
- _context4.next = 5;
234
- return graphQL("addAction", query, {
235
- variables: variables
236
- });
237
-
238
- case 5:
239
- response = _context4.sent;
240
- return _context4.abrupt("return", response);
241
-
242
- case 7:
243
- case "end":
244
- return _context4.stop();
245
- }
246
- }
247
- }, _callee4);
248
- }));
249
- return _addAction.apply(this, arguments);
250
- }
251
-
252
- function addActionContact(_x9, _x10, _x11) {
253
- return _addActionContact.apply(this, arguments);
254
- }
255
-
256
- function _addActionContact() {
257
- _addActionContact = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee5(actionType, actionPage, data) {
258
- var query, expected, variables, _i, _Object$entries, _Object$entries$_i, key, value, response;
259
-
260
- return regeneratorRuntime.wrap(function _callee5$(_context5) {
261
- while (1) {
262
- switch (_context5.prev = _context5.next) {
263
- case 0:
264
- query = "mutation addActionContact(\n $action: ActionInput!,\n $contact:ContactInput!,\n $privacy:ConsentInput!,\n $contactRef:ID,\n $actionPage:ID!,\n $tracking:TrackingInput\n){\n addActionContact(\n actionPageId: $actionPage, \n action: $action,\n contactRef:$contactRef,\n contact:$contact,\n privacy:$privacy,\n tracking:$tracking\n ){contactRef,firstName}\n }\n";
265
- expected = "firstname,lastname,email,country,postcode,locality,address,region,birthdate,privacy,tracking".split(",");
266
- variables = {
267
- actionPage: actionPage,
268
- action: {
269
- actionType: actionType,
270
- fields: [] // added below
271
-
272
- },
273
- contact: {
274
- first_name: data.firstname,
275
- last_name: data.lastname,
276
- email: data.email,
277
- address: {
278
- country: data.country || "",
279
- postcode: data.postcode || ""
280
- }
281
- },
282
- privacy: {
283
- optIn: data.privacy === "opt-in",
284
- leadOptIn: data.privacy === "opt-in"
285
- }
286
- };
287
- if (data.region) variables.contact.address.region = data.region;
288
- if (data.locality) variables.contact.address.locality = data.locality;
289
- if (data.birthdate) variables.contact.birth_date = data.birthdate;
290
-
291
- if (Object.keys(data.tracking).length) {
292
- variables.tracking = data.tracking;
293
- }
294
-
295
- for (_i = 0, _Object$entries = Object.entries(data); _i < _Object$entries.length; _i++) {
296
- _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2), key = _Object$entries$_i[0], value = _Object$entries$_i[1];
297
- if (value && !expected.includes(key)) variables.action.fields.push({
298
- key: key,
299
- value: value
300
- });
301
- }
302
-
303
- _context5.next = 10;
304
- return graphQL("addActionContact", query, {
305
- variables: variables
306
- });
307
-
308
- case 10:
309
- response = _context5.sent;
310
-
311
- if (!response.errors) {
312
- _context5.next = 13;
313
- break;
314
- }
315
-
316
- return _context5.abrupt("return", response);
317
-
318
- case 13:
319
- return _context5.abrupt("return", response.addActionContact);
320
-
321
- case 14:
322
- case "end":
323
- return _context5.stop();
324
- }
325
- }
326
- }, _callee5);
327
- }));
328
- return _addActionContact.apply(this, arguments);
329
- }
330
-
331
- export { addActionContact, addAction, getCount, getCountByUrl };
@@ -1,65 +0,0 @@
1
- import Url from "url-parse";
2
- /*
3
- var urlParams = new URLSearchParams(window.location.search);
4
- params.values = {};
5
- [
6
- "firstname",
7
- "lastname",
8
- "email",
9
- "postcode",
10
- "country",
11
- "comment"
12
- ].forEach(function(name) {
13
- if (urlParams.get(name)) params.values[name] = urlParams.get(name);
14
- });
15
- */
16
-
17
- var filter = function filter(query) {
18
- var whitelist = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
19
- var prefix = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "";
20
- if (!whitelist) return query;
21
- var r = {};
22
- Object.keys(query).filter(function (key) {
23
- return key.startsWith(prefix) && whitelist.includes(key.substr(prefix.length));
24
- }).forEach(function (k) {
25
- return r[k.substr(prefix.length)] = query[k];
26
- });
27
- return r;
28
- };
29
-
30
- var parse = function parse(whitelist, prefix) {
31
- var url = Url(document.location, true);
32
- return filter(url.query, whitelist, prefix) || {};
33
- };
34
-
35
- var data = function data(prefix) {
36
- prefix = prefix || "proca_";
37
- var whitelist = ["firstname", "lastname", "name", "email", "postcode", "address", "locality", "country", "comment"];
38
- return parse(whitelist, prefix);
39
- };
40
-
41
- var config = function config(prefix) {
42
- prefix = prefix || "proca_";
43
- var whitelist = ["comment"];
44
- return parse(whitelist, prefix);
45
- };
46
-
47
- var utm = function utm() {
48
- var whitelist = ["source", "medium", "campaign", "content"];
49
- var utm = parse(whitelist, "utm_");
50
-
51
- if (0 === Object.keys(utm).length && document.referrer) {
52
- utm.medium = "website";
53
- utm.source = "referrer";
54
- utm.campaign = document.referrer;
55
- }
56
-
57
- return utm;
58
- };
59
-
60
- export { utm, data, config };
61
- export default {
62
- utm: utm,
63
- data: data,
64
- config: config
65
- };
package/dist/lib/uuid.js DELETED
@@ -1,30 +0,0 @@
1
- /*
2
- * Sometimes, we need a uniqueid /fingerprint without collecting any personal data or any interaction with the server
3
- *
4
- * we generate a RFC 4122 uuid (v4) https://en.wikipedia.org/wiki/Universally_unique_identifier#Version_4_(random)
5
- * and base64url encode it (a url friendly base64 encoding)
6
- */
7
- import base64url from "base64url";
8
- import { v4 as uuid } from 'uuid';
9
- var id = null;
10
-
11
- function generate() {
12
- var d = [];
13
- uuid(null, d);
14
- id = base64url(d);
15
- return id;
16
- } // @input set null=generate or return previous, false=return if uuid is set or not, string or array = set the uuid
17
-
18
-
19
- export default function (set) {
20
- if (typeof set === "undefined") {
21
- return id ? id : generate();
22
- }
23
-
24
- if (typeof set === "string") {
25
- id = set;
26
- return id;
27
- }
28
-
29
- return id;
30
- }
@@ -1,37 +0,0 @@
1
- trying to use most of the strings from the mozilla plateform
2
-
3
- https://github.com/mozilla-l10n/donate-l10n
4
-
5
- then convert to json using i18next-gettext-converter
6
-
7
- i18next-conv -l fr -s /usr/src/donate-l10n/donate/locale/fr/LC_MESSAGES/django.po -t /tmp/fr.json
8
-
9
-
10
- or better, using code and filter:
11
-
12
- const path = require('path');
13
- const { readFileSync, writeFileSync } = require('fs');
14
- const {
15
- i18nextToPo,
16
- i18nextToPot,
17
- i18nextToMo,
18
- gettextToI18next,
19
- } = require('i18next-conv');
20
-
21
- const source = path.join(__dirname, '../locales/ua-UK/translation.json');
22
- const options = {/* you options here */}
23
-
24
- function save(target) {
25
- return result => {
26
- writeFileSync(target, result);
27
- };
28
- }
29
-
30
- i18nextToPo('ua-UK', readFileSync(source), options).then(save('../locales/ua-UK/translation.po'));
31
- i18nextToPot('ua-UK', readFileSync(source), options).then(save('../locales/ua-UK/translation.pot'));
32
- i18nextToMo('ua-UK', readFileSync(source), options).then(save('../locales/ua-UK/translation.mo'));
33
-
34
- gettextToI18next('ua-UK', readFileSync('../locales/ua-UK/translation.po'), options)
35
- .then(save('../locales/ua-UK/translation.json'));
36
-
37
- ~