@dev-crew-berlin/enter-js-utils 0.44.0 → 0.46.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.
@@ -8,6 +8,7 @@ import { Instance } from '../models/instance';
8
8
  import { User } from '../models/user';
9
9
  import { Variable } from '../models/variable';
10
10
  import { components } from '../generated/api-schema';
11
+ import { Email } from '../models/email';
11
12
  export type { APICredentials } from './api-base';
12
13
  export default class API extends APIBase {
13
14
  getInstanceList(): Promise<APIResult<Instance[]>>;
@@ -65,5 +66,10 @@ export default class API extends APIBase {
65
66
  attendeeId: string;
66
67
  emailName: string;
67
68
  }): Promise<APIResult<null>>;
69
+ getRenderedEmail(args: {
70
+ instanceName: string;
71
+ attendeeId: string;
72
+ emailName: string;
73
+ }): Promise<APIResult<Email>>;
68
74
  createEvents(args: Event[]): Promise<APIResult<null>>;
69
75
  }
@@ -99,6 +99,12 @@ export default class API extends APIBase {
99
99
  const emailName = args.emailName;
100
100
  return this.post(`/instances/${instanceName}/attendees/${attendeeId}/emails/${emailName}/send`, null);
101
101
  }
102
+ async getRenderedEmail(args) {
103
+ const instanceName = args.instanceName;
104
+ const attendeeId = args.attendeeId;
105
+ const emailName = args.emailName;
106
+ return this.get(`/instances/${instanceName}/attendees/${attendeeId}/emails/${emailName}/render`);
107
+ }
102
108
  async createEvents(args) {
103
109
  return this.post(`/events`, args);
104
110
  }
@@ -47,6 +47,9 @@ export declare type paths = {
47
47
  "/instances/{instance_name}/attendees/{attendee_id}/emails/{email_name}/send": {
48
48
  post: operations["send_email_instances__instance_name__attendees__attendee_id__emails__email_name__send_post"];
49
49
  };
50
+ "/instances/{instance_name}/attendees/{attendee_id}/emails/{email_name}/render": {
51
+ get: operations["rendered_email_content_instances__instance_name__attendees__attendee_id__emails__email_name__render_get"];
52
+ };
50
53
  "/instances/{instance_name}/variables": {
51
54
  get: operations["variable_list_instances__instance_name__variables_get"];
52
55
  post: operations["create_variable_instances__instance_name__variables_post"];
@@ -657,8 +660,6 @@ export declare type components = {
657
660
  instanceName: string;
658
661
  /** Emailaddress */
659
662
  emailAddress: string;
660
- /** Signature */
661
- signature: string;
662
663
  };
663
664
  /** EventList */
664
665
  EventList: (components["schemas"]["AttendeeCreatedEvent"] | components["schemas"]["AttendeeUpdatedEvent"] | components["schemas"]["AttendeeRespondedEvent"] | components["schemas"]["EmailUnsubscribedEvent"] | components["schemas"]["AttendeeDeletedEvent"] | components["schemas"]["CheckinCreatedEvent"] | components["schemas"]["CheckinDeletedEvent"] | components["schemas"]["PaymentPaidEvent"])[];
@@ -1031,6 +1032,15 @@ export declare type components = {
1031
1032
  */
1032
1033
  deleted: boolean;
1033
1034
  };
1035
+ /** PublicEmail */
1036
+ PublicEmail: {
1037
+ /** Subject */
1038
+ subject: string;
1039
+ /** Htmlcontent */
1040
+ htmlContent?: string;
1041
+ /** Plaintextcontent */
1042
+ plaintextContent: string;
1043
+ };
1034
1044
  /** PublicInstance */
1035
1045
  PublicInstance: {
1036
1046
  /** Name */
@@ -1624,6 +1634,29 @@ export declare type operations = {
1624
1634
  };
1625
1635
  };
1626
1636
  };
1637
+ rendered_email_content_instances__instance_name__attendees__attendee_id__emails__email_name__render_get: {
1638
+ parameters: {
1639
+ path: {
1640
+ instance_name: string;
1641
+ attendee_id: string;
1642
+ email_name: string;
1643
+ };
1644
+ };
1645
+ responses: {
1646
+ /** Successful Response */
1647
+ 200: {
1648
+ content: {
1649
+ "application/json": components["schemas"]["PublicEmail"];
1650
+ };
1651
+ };
1652
+ /** Validation Error */
1653
+ 422: {
1654
+ content: {
1655
+ "application/json": components["schemas"]["HTTPValidationError"];
1656
+ };
1657
+ };
1658
+ };
1659
+ };
1627
1660
  variable_list_instances__instance_name__variables_get: {
1628
1661
  parameters: {
1629
1662
  path: {
@@ -0,0 +1,2 @@
1
+ import { components } from '../generated/api-schema';
2
+ export declare type Email = components['schemas']['PublicEmail'];
@@ -0,0 +1 @@
1
+ export {};
@@ -1,10 +1,15 @@
1
1
  import { components } from '../generated/api-schema';
2
+ import { Field } from './field';
2
3
  export declare type Dictionary<T> = Record<string, T>;
3
4
  export declare type FieldGroup = components['schemas']['FieldGroup'];
4
5
  export declare type FieldLabels = Record<string, FieldTitle | undefined>;
5
6
  declare type FieldTitle = string | Dictionary<string>;
6
7
  export declare class FieldGroups {
7
8
  groups: FieldGroup[];
9
+ get groupNames(): string[];
10
+ get fields(): Map<string, Field & {
11
+ group: string;
12
+ }>;
8
13
  constructor(json: FieldGroup[]);
9
14
  toJSON(): FieldGroup[];
10
15
  getFieldLabels(): FieldLabels;
@@ -1,4 +1,19 @@
1
1
  export class FieldGroups {
2
+ get groupNames() {
3
+ return this.groups.map((_, index) => index.toString());
4
+ }
5
+ get fields() {
6
+ const fields = new Map();
7
+ for (const [groupIndex, group] of this.groups.entries()) {
8
+ for (const field of group.questions) {
9
+ fields.set(field.name, {
10
+ ...field,
11
+ group: groupIndex.toString()
12
+ });
13
+ }
14
+ }
15
+ return fields;
16
+ }
2
17
  constructor(json) {
3
18
  this.groups = json;
4
19
  }
@@ -6,12 +21,11 @@ export class FieldGroups {
6
21
  return this.groups;
7
22
  }
8
23
  getFieldLabels() {
9
- return this.groups.reduce((labels, group) => {
10
- return group.questions.reduce((labels, question) => {
11
- labels[question.name] = question.title ?? question.name;
12
- return labels;
13
- }, labels);
14
- }, {});
24
+ const labels = {};
25
+ for (const [fieldKey, field] of this.fields.entries()) {
26
+ labels[fieldKey] = field.title ?? field.name;
27
+ }
28
+ return labels;
15
29
  }
16
30
  getLabelForField(fieldKey, language) {
17
31
  const fieldLabel = this.getFieldLabels()[fieldKey];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dev-crew-berlin/enter-js-utils",
3
- "version": "0.44.0",
3
+ "version": "0.46.0",
4
4
  "description": "utils such as vaildation and other helpers to work with data from the enter app",
5
5
  "files": [
6
6
  "dist",