@dev-crew-berlin/enter-js-utils 0.99.2 → 0.99.3
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.
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Handlebars from 'handlebars';
|
|
2
|
-
import { makeGoogleWalletLink, makeQrCodeLink, makeRegistrationLink, makeTrackingLink, makeUnsubscribeLink, makeWalletLink } from './email-links';
|
|
2
|
+
import { makeFileLink, makeGoogleWalletLink, makeQrCodeLink, makeRegistrationLink, makeTrackingLink, makeUnsubscribeLink, makeWalletLink } from './email-links';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* A from-scratch TS port of the pybars helper set registered in
|
|
@@ -389,6 +389,9 @@ function registerLinkHelpers(hb, linkOptions, ctx) {
|
|
|
389
389
|
hb.registerHelper('google_wallet_link', function (id) {
|
|
390
390
|
return safe(makeGoogleWalletLink(linkOptions, id ?? ctx.attendeeId));
|
|
391
391
|
});
|
|
392
|
+
hb.registerHelper('file', function (path) {
|
|
393
|
+
return safe(makeFileLink(linkOptions, path));
|
|
394
|
+
});
|
|
392
395
|
hb.registerHelper('qr_code_link', function (...args) {
|
|
393
396
|
const {
|
|
394
397
|
explicit
|
|
@@ -336,4 +336,8 @@ describe('link helpers', () => {
|
|
|
336
336
|
});
|
|
337
337
|
expect(html).toBe('https://test.frontend.example/home');
|
|
338
338
|
});
|
|
339
|
+
it('file builds an unsigned /files/{path} link', async () => {
|
|
340
|
+
const html = await renderEn('{{file "attachments/agenda.pdf"}}', {});
|
|
341
|
+
expect(html).toBe('https://test.frontend.example/files/attachments/agenda.pdf');
|
|
342
|
+
});
|
|
339
343
|
});
|
|
@@ -36,6 +36,7 @@ export declare function makeRegistrationLink(options: LinkBuilderOptions, args:
|
|
|
36
36
|
}): string;
|
|
37
37
|
export declare function makeWalletLink(options: LinkBuilderOptions, attendeeId: string): string;
|
|
38
38
|
export declare function makeGoogleWalletLink(options: LinkBuilderOptions, attendeeId: string): string;
|
|
39
|
+
export declare function makeFileLink(options: LinkBuilderOptions, path: string): string;
|
|
39
40
|
export declare function makeQrCodeLink(options: LinkBuilderOptions, args: {
|
|
40
41
|
content: string;
|
|
41
42
|
size?: number;
|
package/dist/lib/email-links.js
CHANGED
|
@@ -55,6 +55,9 @@ export function makeWalletLink(options, attendeeId) {
|
|
|
55
55
|
export function makeGoogleWalletLink(options, attendeeId) {
|
|
56
56
|
return `https://${options.domain}/google-wallet/${attendeeId}`;
|
|
57
57
|
}
|
|
58
|
+
export function makeFileLink(options, path) {
|
|
59
|
+
return `https://${options.domain}/files/${path}`;
|
|
60
|
+
}
|
|
58
61
|
export function makeQrCodeLink(options, args) {
|
|
59
62
|
const params = new URLSearchParams({
|
|
60
63
|
content: args.content,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { describe, it, expect } from 'vitest';
|
|
2
2
|
import jws from 'jws';
|
|
3
|
-
import { makeGoogleWalletLink, makeQrCodeLink, makeRegistrationLink, makeTrackingLink, makeUnsubscribeLink, makeWalletLink } from './email-links';
|
|
3
|
+
import { makeFileLink, makeGoogleWalletLink, makeQrCodeLink, makeRegistrationLink, makeTrackingLink, makeUnsubscribeLink, makeWalletLink } from './email-links';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Mirrors FrontendConfig's link builders
|
|
@@ -277,6 +277,11 @@ describe('makeGoogleWalletLink', () => {
|
|
|
277
277
|
expect(makeGoogleWalletLink(options, 'att-1')).toBe('https://example.com/google-wallet/att-1');
|
|
278
278
|
});
|
|
279
279
|
});
|
|
280
|
+
describe('makeFileLink', () => {
|
|
281
|
+
it('builds an unsigned /files/{path} link', () => {
|
|
282
|
+
expect(makeFileLink(options, 'attachments/agenda.pdf')).toBe('https://example.com/files/attachments/agenda.pdf');
|
|
283
|
+
});
|
|
284
|
+
});
|
|
280
285
|
describe('makeQrCodeLink', () => {
|
|
281
286
|
it('builds a link under /qr/', () => {
|
|
282
287
|
const link = makeQrCodeLink(options, {
|