@drawbridge/drawbridge-utils 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/dist/encrypt.cjs +68 -0
- package/dist/{encrypt.d.mts → encrypt.d.cts} +2 -5
- package/dist/encrypt.d.ts +2 -5
- package/dist/encrypt.js +2 -2
- package/dist/index.cjs +411 -0
- package/dist/{index.d.mts → index.d.cts} +181 -24
- package/dist/index.d.ts +181 -24
- package/dist/index.js +176 -180
- package/package.json +9 -7
- package/dist/chunk-EBO3CZXG.mjs +0 -15
- package/dist/encrypt.mjs +0 -43
- package/dist/index.mjs +0 -376
package/dist/index.mjs
DELETED
|
@@ -1,376 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
__commonJS,
|
|
3
|
-
__require
|
|
4
|
-
} from "./chunk-EBO3CZXG.mjs";
|
|
5
|
-
|
|
6
|
-
// lib/constants.js
|
|
7
|
-
var require_constants = __commonJS({
|
|
8
|
-
"lib/constants.js"(exports, module) {
|
|
9
|
-
var font = {
|
|
10
|
-
family: "Roboto Flex",
|
|
11
|
-
transform: "none",
|
|
12
|
-
weight: "regular"
|
|
13
|
-
};
|
|
14
|
-
module.exports = {
|
|
15
|
-
action: {
|
|
16
|
-
usage: {
|
|
17
|
-
actions: 0
|
|
18
|
-
}
|
|
19
|
-
},
|
|
20
|
-
brand: {
|
|
21
|
-
style: {
|
|
22
|
-
body: font,
|
|
23
|
-
heading: font
|
|
24
|
-
},
|
|
25
|
-
totals: {
|
|
26
|
-
campaigns: 0
|
|
27
|
-
}
|
|
28
|
-
},
|
|
29
|
-
campaign: {
|
|
30
|
-
agreements: {
|
|
31
|
-
marketing: {
|
|
32
|
-
enabled: false,
|
|
33
|
-
label: "I agree to the marketing terms and conditions",
|
|
34
|
-
link: null
|
|
35
|
-
},
|
|
36
|
-
terms: {
|
|
37
|
-
enabled: false,
|
|
38
|
-
label: "I agree to the terms and conditions",
|
|
39
|
-
link: null
|
|
40
|
-
}
|
|
41
|
-
},
|
|
42
|
-
defaults: {
|
|
43
|
-
active: "Enter",
|
|
44
|
-
confirmation: "Submission was successful",
|
|
45
|
-
inactive: "Submissions are closed",
|
|
46
|
-
email: "You were selected"
|
|
47
|
-
},
|
|
48
|
-
notifications: {
|
|
49
|
-
draw: {
|
|
50
|
-
subject: "You have been selected",
|
|
51
|
-
body: "Thanks for being part of our giveaway"
|
|
52
|
-
}
|
|
53
|
-
},
|
|
54
|
-
settings: {
|
|
55
|
-
submissionLeadPrimaryKey: "email",
|
|
56
|
-
submissionEntryMaximum: 1,
|
|
57
|
-
submissionEntryFilter: "campaign",
|
|
58
|
-
submissionEntryHighscore: false,
|
|
59
|
-
submissionEntryLimit: 1
|
|
60
|
-
},
|
|
61
|
-
status: "drafted",
|
|
62
|
-
totals: {
|
|
63
|
-
advertisements: 0,
|
|
64
|
-
affiliates: 0,
|
|
65
|
-
draws: 0,
|
|
66
|
-
exports: 0,
|
|
67
|
-
entries: 0,
|
|
68
|
-
fields: 2,
|
|
69
|
-
integrations: 1,
|
|
70
|
-
leads: 0,
|
|
71
|
-
links: 0,
|
|
72
|
-
pages: 0,
|
|
73
|
-
prizes: 0,
|
|
74
|
-
ranges: 0,
|
|
75
|
-
submissions: 0
|
|
76
|
-
},
|
|
77
|
-
type: "giveaway"
|
|
78
|
-
},
|
|
79
|
-
draw: {
|
|
80
|
-
status: "qualified",
|
|
81
|
-
totals: {
|
|
82
|
-
notifications: 0
|
|
83
|
-
}
|
|
84
|
-
},
|
|
85
|
-
member: {
|
|
86
|
-
status: "pending"
|
|
87
|
-
},
|
|
88
|
-
organization: {
|
|
89
|
-
errors: [],
|
|
90
|
-
totals: {
|
|
91
|
-
affiliates: 0,
|
|
92
|
-
brands: 0,
|
|
93
|
-
campaigns: 0,
|
|
94
|
-
leads: 0,
|
|
95
|
-
draws: 0,
|
|
96
|
-
entries: 0,
|
|
97
|
-
invitations: 0,
|
|
98
|
-
invoices: 0,
|
|
99
|
-
members: 0,
|
|
100
|
-
ranges: 0,
|
|
101
|
-
pages: 0,
|
|
102
|
-
prizes: 0,
|
|
103
|
-
storage: 0,
|
|
104
|
-
submissions: 0,
|
|
105
|
-
subscriptions: 0,
|
|
106
|
-
usage: 0
|
|
107
|
-
}
|
|
108
|
-
},
|
|
109
|
-
page: {
|
|
110
|
-
domains: [],
|
|
111
|
-
status: "drafted",
|
|
112
|
-
totals: {
|
|
113
|
-
leads: 0,
|
|
114
|
-
entries: 0,
|
|
115
|
-
submissions: 0
|
|
116
|
-
}
|
|
117
|
-
},
|
|
118
|
-
prize: {
|
|
119
|
-
inventory: 0,
|
|
120
|
-
remaining: 0,
|
|
121
|
-
shipping: false,
|
|
122
|
-
status: "drafted",
|
|
123
|
-
totals: {
|
|
124
|
-
draws: 0
|
|
125
|
-
}
|
|
126
|
-
},
|
|
127
|
-
range: {
|
|
128
|
-
totals: {
|
|
129
|
-
leads: 0,
|
|
130
|
-
entries: 0,
|
|
131
|
-
submissions: 0
|
|
132
|
-
}
|
|
133
|
-
},
|
|
134
|
-
referrer: {
|
|
135
|
-
totals: {
|
|
136
|
-
originizations: 0,
|
|
137
|
-
subscriptions: 0,
|
|
138
|
-
users: 0
|
|
139
|
-
}
|
|
140
|
-
},
|
|
141
|
-
template: {
|
|
142
|
-
page: {
|
|
143
|
-
style: {
|
|
144
|
-
body: font,
|
|
145
|
-
heading: font
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
},
|
|
149
|
-
usage: {
|
|
150
|
-
totals: {
|
|
151
|
-
actions: 0,
|
|
152
|
-
affiliates: 0,
|
|
153
|
-
brands: 0,
|
|
154
|
-
campaigns: 0,
|
|
155
|
-
connections: 0,
|
|
156
|
-
entries: 0,
|
|
157
|
-
files: 0,
|
|
158
|
-
members: 0,
|
|
159
|
-
orders: 0,
|
|
160
|
-
pages: 0,
|
|
161
|
-
revenue: 0,
|
|
162
|
-
storage: 0,
|
|
163
|
-
submissions: 0,
|
|
164
|
-
workflows: 0
|
|
165
|
-
}
|
|
166
|
-
},
|
|
167
|
-
user: {
|
|
168
|
-
access: {
|
|
169
|
-
ai: false
|
|
170
|
-
},
|
|
171
|
-
image: null,
|
|
172
|
-
totals: {
|
|
173
|
-
inbox: 0,
|
|
174
|
-
invitations: 0,
|
|
175
|
-
messages: 0,
|
|
176
|
-
methods: 0,
|
|
177
|
-
organizations: 1,
|
|
178
|
-
teams: 0
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
};
|
|
182
|
-
}
|
|
183
|
-
});
|
|
184
|
-
|
|
185
|
-
// index.js
|
|
186
|
-
var require_index = __commonJS({
|
|
187
|
-
"index.js"(exports, module) {
|
|
188
|
-
var { code, data } = __require("currency-codes");
|
|
189
|
-
var constants = require_constants();
|
|
190
|
-
var infinite = 1e300;
|
|
191
|
-
var isInfinite = (value) => value === infinite;
|
|
192
|
-
var megabyte = 1024 * 1024;
|
|
193
|
-
var gigabyte = megabyte * 1024;
|
|
194
|
-
var urlRoot = (string) => (string == null ? void 0 : string.includes("https")) ? "https://" : "http://";
|
|
195
|
-
var bytesToGB = (bytes) => {
|
|
196
|
-
const divide = 1024 * 1024 * 1024;
|
|
197
|
-
return bytes ? Number(bytes) / divide : 0;
|
|
198
|
-
};
|
|
199
|
-
var bytesToMB = (bytes) => {
|
|
200
|
-
const divide = 1024 * 1024;
|
|
201
|
-
return bytes ? Number(bytes) / divide : 0;
|
|
202
|
-
};
|
|
203
|
-
var capitalize = (string) => {
|
|
204
|
-
var _a;
|
|
205
|
-
return ((_a = string == null ? void 0 : string.charAt(0)) == null ? void 0 : _a.toUpperCase()) + (string == null ? void 0 : string.slice(1));
|
|
206
|
-
};
|
|
207
|
-
var expiredPaymentMethod = (card) => {
|
|
208
|
-
const currentDate = /* @__PURE__ */ new Date();
|
|
209
|
-
const year = currentDate.getFullYear();
|
|
210
|
-
const month = (/* @__PURE__ */ new Date()).getMonth();
|
|
211
|
-
const expired = [
|
|
212
|
-
(card == null ? void 0 : card.year) < year,
|
|
213
|
-
(card == null ? void 0 : card.year) === year && (card == null ? void 0 : card.month) <= month
|
|
214
|
-
].filter(Boolean);
|
|
215
|
-
return Boolean(expired == null ? void 0 : expired.length);
|
|
216
|
-
};
|
|
217
|
-
var formatCurrency = ({
|
|
218
|
-
code: code2 = "USD",
|
|
219
|
-
digits = 2,
|
|
220
|
-
display = "standard",
|
|
221
|
-
locale,
|
|
222
|
-
value = 0
|
|
223
|
-
}) => {
|
|
224
|
-
var _a;
|
|
225
|
-
const resolvedLocale = locale || (typeof navigator !== "undefined" ? navigator == null ? void 0 : navigator.language : null) || "en-US";
|
|
226
|
-
const options = {
|
|
227
|
-
currency: code2,
|
|
228
|
-
minimumFractionDigits: digits,
|
|
229
|
-
maximumFractionDigits: digits,
|
|
230
|
-
style: "currency"
|
|
231
|
-
};
|
|
232
|
-
if (display === "parts") {
|
|
233
|
-
options.currencyDisplay = "narrowSymbol";
|
|
234
|
-
const parts = new Intl.NumberFormat(resolvedLocale, options).formatToParts(value);
|
|
235
|
-
const symbol = ((_a = parts.find((p) => p.type === "currency")) == null ? void 0 : _a.value) || "";
|
|
236
|
-
const number = parts.filter((p) => p.type !== "currency" && p.type !== "literal").map((p) => p.value).join("");
|
|
237
|
-
return symbol + number + " " + code2;
|
|
238
|
-
}
|
|
239
|
-
;
|
|
240
|
-
return new Intl.NumberFormat(resolvedLocale, options).format(value);
|
|
241
|
-
};
|
|
242
|
-
var formatDateString = ({
|
|
243
|
-
date,
|
|
244
|
-
locale,
|
|
245
|
-
time = false,
|
|
246
|
-
options = {
|
|
247
|
-
day: "numeric",
|
|
248
|
-
month: "long",
|
|
249
|
-
weekday: "long",
|
|
250
|
-
year: "numeric"
|
|
251
|
-
}
|
|
252
|
-
}) => {
|
|
253
|
-
const resolved = time ? { ...options, hour: "numeric", minute: "2-digit" } : options;
|
|
254
|
-
return new Date(date).toLocaleString(
|
|
255
|
-
locale,
|
|
256
|
-
resolved
|
|
257
|
-
);
|
|
258
|
-
};
|
|
259
|
-
var formatNumber = (number, digits = 0) => {
|
|
260
|
-
return Number(number).toLocaleString("en", {
|
|
261
|
-
minimumFractionDigits: digits,
|
|
262
|
-
maximumFractionDigits: digits
|
|
263
|
-
});
|
|
264
|
-
};
|
|
265
|
-
var getPlanFeature = (plan, key) => {
|
|
266
|
-
var _a, _b, _c, _d;
|
|
267
|
-
const error = (_b = ((_a = plan == null ? void 0 : plan.features) == null ? void 0 : _a.denied) || {}) == null ? void 0 : _b[key];
|
|
268
|
-
const feature = (_d = ((_c = plan == null ? void 0 : plan.features) == null ? void 0 : _c.granted) || {}) == null ? void 0 : _d[key];
|
|
269
|
-
const granted = Boolean(feature);
|
|
270
|
-
return {
|
|
271
|
-
granted,
|
|
272
|
-
message: granted ? feature : error
|
|
273
|
-
};
|
|
274
|
-
};
|
|
275
|
-
var percentage = (value1, value2, decimals = 1) => ((value1 || 0) / (value2 || 0) * 100 || 0).toFixed(decimals);
|
|
276
|
-
var reducers = {
|
|
277
|
-
fields: (data2 = [], callback = () => ({})) => data2.reduce(
|
|
278
|
-
(accumulator, field) => {
|
|
279
|
-
const type = field == null ? void 0 : field.type;
|
|
280
|
-
if (!accumulator[type]) return accumulator;
|
|
281
|
-
accumulator[type].items.push({
|
|
282
|
-
...field,
|
|
283
|
-
...callback(field)
|
|
284
|
-
});
|
|
285
|
-
accumulator[type].keys.push(field == null ? void 0 : field.slug);
|
|
286
|
-
return accumulator;
|
|
287
|
-
},
|
|
288
|
-
{
|
|
289
|
-
additional: {
|
|
290
|
-
items: [],
|
|
291
|
-
keys: []
|
|
292
|
-
},
|
|
293
|
-
lead: {
|
|
294
|
-
items: [],
|
|
295
|
-
keys: []
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
)
|
|
299
|
-
};
|
|
300
|
-
var regex = {
|
|
301
|
-
domain: /^([a-zA-Z0-9-]+\.)+[a-zA-Z]{2,}$/,
|
|
302
|
-
protocols: /^(https?:\/\/)?(www\.)?/,
|
|
303
|
-
url: /^(https:\/\/)/
|
|
304
|
-
};
|
|
305
|
-
var shareUrls = ({
|
|
306
|
-
formUri,
|
|
307
|
-
organization,
|
|
308
|
-
page
|
|
309
|
-
}) => {
|
|
310
|
-
var _a;
|
|
311
|
-
const resolvedFormUri = formUri || (typeof process !== "undefined" ? (_a = process.env) == null ? void 0 : _a.APP_CLIENT_FORM_URI : void 0);
|
|
312
|
-
const preface = urlRoot(resolvedFormUri);
|
|
313
|
-
const base = resolvedFormUri;
|
|
314
|
-
const qr = preface + (base == null ? void 0 : base.replace(preface, "")) + "/" + (page == null ? void 0 : page.shortId) + "?qr=1";
|
|
315
|
-
const short = preface + (base == null ? void 0 : base.replace(preface, "")) + "/" + (page == null ? void 0 : page.shortId);
|
|
316
|
-
const url = preface + (organization == null ? void 0 : organization.subdomain) + "." + (base == null ? void 0 : base.replace(preface, "")) + "/" + (page == null ? void 0 : page.slug);
|
|
317
|
-
const clients = [
|
|
318
|
-
base,
|
|
319
|
-
qr,
|
|
320
|
-
short,
|
|
321
|
-
url
|
|
322
|
-
];
|
|
323
|
-
const urls = {
|
|
324
|
-
qr,
|
|
325
|
-
short,
|
|
326
|
-
url
|
|
327
|
-
};
|
|
328
|
-
if ((organization == null ? void 0 : organization.subdomain) && (page == null ? void 0 : page.shortId)) {
|
|
329
|
-
clients.push(preface + (base == null ? void 0 : base.replace(preface, "")) + "/" + (page == null ? void 0 : page.shortId));
|
|
330
|
-
clients.push(preface + (base == null ? void 0 : base.replace(preface, "")) + "/" + (page == null ? void 0 : page.shortId) + "?qr=1");
|
|
331
|
-
clients.push(preface + organization.subdomain + "." + (base == null ? void 0 : base.replace(preface, "")));
|
|
332
|
-
clients.push(preface + organization.subdomain + "." + (base == null ? void 0 : base.replace(preface, "")) + "/" + (page == null ? void 0 : page.shortId));
|
|
333
|
-
}
|
|
334
|
-
;
|
|
335
|
-
if ((organization == null ? void 0 : organization.shortId) && (page == null ? void 0 : page.slug) && (page == null ? void 0 : page.shortId)) {
|
|
336
|
-
clients.push(preface + organization.shortId + "." + (base == null ? void 0 : base.replace(preface, "")));
|
|
337
|
-
clients.push(preface + organization.shortId + "." + (base == null ? void 0 : base.replace(preface, "")) + "/" + (page == null ? void 0 : page.slug));
|
|
338
|
-
clients.push(preface + organization.shortId + "." + (base == null ? void 0 : base.replace(preface, "")) + "/" + (page == null ? void 0 : page.shortId));
|
|
339
|
-
}
|
|
340
|
-
;
|
|
341
|
-
return {
|
|
342
|
-
clients,
|
|
343
|
-
urls
|
|
344
|
-
};
|
|
345
|
-
};
|
|
346
|
-
var currencies = data.map((item) => ({
|
|
347
|
-
...item,
|
|
348
|
-
key: item.currency,
|
|
349
|
-
value: item.code
|
|
350
|
-
}));
|
|
351
|
-
var currency = (val) => code(val);
|
|
352
|
-
module.exports = {
|
|
353
|
-
bytesToGB,
|
|
354
|
-
bytesToMB,
|
|
355
|
-
capitalize,
|
|
356
|
-
constants,
|
|
357
|
-
currencies,
|
|
358
|
-
currency,
|
|
359
|
-
expiredPaymentMethod,
|
|
360
|
-
formatCurrency,
|
|
361
|
-
formatDateString,
|
|
362
|
-
formatNumber,
|
|
363
|
-
getPlanFeature,
|
|
364
|
-
gigabyte,
|
|
365
|
-
infinite,
|
|
366
|
-
isInfinite,
|
|
367
|
-
megabyte,
|
|
368
|
-
percentage,
|
|
369
|
-
reducers,
|
|
370
|
-
regex,
|
|
371
|
-
shareUrls,
|
|
372
|
-
urlRoot
|
|
373
|
-
};
|
|
374
|
-
}
|
|
375
|
-
});
|
|
376
|
-
export default require_index();
|