@dev-crew-berlin/enter-js-utils 0.23.0 → 0.30.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.
Files changed (46) hide show
  1. package/README.md +2 -7
  2. package/dist/api-client/api-base.d.ts +22 -7
  3. package/dist/api-client/api-base.js +30 -32
  4. package/dist/api-client/index.d.ts +27 -45
  5. package/dist/api-client/index.js +58 -46
  6. package/dist/generated/api-schema.d.ts +1665 -0
  7. package/dist/generated/api-schema.js +1 -0
  8. package/dist/lib/api-result.d.ts +1 -8
  9. package/dist/lib/api-result.js +1 -12
  10. package/dist/models/access-token.d.ts +2 -11
  11. package/dist/models/access-token.js +1 -11
  12. package/dist/models/attendee.d.ts +13 -60
  13. package/dist/models/attendee.js +41 -87
  14. package/dist/models/checkin-counts.d.ts +4 -10
  15. package/dist/models/checkin-counts.js +1 -10
  16. package/dist/models/checkin.d.ts +9 -0
  17. package/dist/models/checkin.js +16 -0
  18. package/dist/models/checkins.d.ts +4 -32
  19. package/dist/models/checkins.js +14 -42
  20. package/dist/models/event.d.ts +2 -40
  21. package/dist/models/field-group.d.ts +5 -448
  22. package/dist/models/field-group.js +4 -31
  23. package/dist/models/field-value.d.ts +0 -1
  24. package/dist/models/field-value.js +1 -3
  25. package/dist/models/field.d.ts +11 -297
  26. package/dist/models/field.js +1 -89
  27. package/dist/models/index.d.ts +2 -3
  28. package/dist/models/instance.d.ts +10 -53
  29. package/dist/models/instance.js +23 -65
  30. package/dist/models/user.d.ts +2 -20
  31. package/dist/models/user.js +1 -13
  32. package/dist/models/variable.d.ts +2 -27
  33. package/dist/models/variable.js +1 -16
  34. package/dist/ui/companion-info.stories.js +1 -3
  35. package/dist/ui/guest-card.stories.js +2 -6
  36. package/dist/ui/icons/caret.d.ts +7 -0
  37. package/dist/ui/icons/caret.js +20 -0
  38. package/dist/ui/icons/caret.stories.d.ts +15 -0
  39. package/dist/ui/icons/caret.stories.js +20 -0
  40. package/package.json +10 -8
  41. package/dist/models/_helpers.d.ts +0 -23
  42. package/dist/models/_helpers.js +0 -89
  43. package/dist/models/invite.d.ts +0 -33
  44. package/dist/models/invite.js +0 -21
  45. package/dist/models/meta-field.d.ts +0 -7
  46. package/dist/models/meta-field.js +0 -9
@@ -1,20 +1,2 @@
1
- import { ValidatorReturnType } from 'fefe';
2
- export declare const user: import("fefe").Validator<import("fefe").ObjectResult<{
3
- name: import("fefe").Validator<string, import("fefe").LeafError>;
4
- admin: import("fefe").Validator<boolean, import("fefe").FefeError>;
5
- timeout: import("fefe").Validator<number, import("fefe").LeafError>;
6
- userdata: (value: unknown) => import("fefe").Result<import("./_helpers").Dictionary<unknown>, import("fefe").FefeError>;
7
- permissions: import("fefe").Validator<import("./_helpers").Dictionary<string[]>, import("fefe").FefeError> & {
8
- optional: true;
9
- };
10
- }>, import("fefe").FefeError>;
11
- export declare type User = ValidatorReturnType<typeof user>;
12
- export declare const parseUser: import("../lib").APIValidator<import("fefe").ObjectResult<{
13
- name: import("fefe").Validator<string, import("fefe").LeafError>;
14
- admin: import("fefe").Validator<boolean, import("fefe").FefeError>;
15
- timeout: import("fefe").Validator<number, import("fefe").LeafError>;
16
- userdata: (value: unknown) => import("fefe").Result<import("./_helpers").Dictionary<unknown>, import("fefe").FefeError>;
17
- permissions: import("fefe").Validator<import("./_helpers").Dictionary<string[]>, import("fefe").FefeError> & {
18
- optional: true;
19
- };
20
- }>>;
1
+ import { components } from '../generated/api-schema';
2
+ export declare type User = components['schemas']['PublicUser'];
@@ -1,13 +1 @@
1
- import { array, number, object, string, optional, boolean, defaultTo } from 'fefe';
2
- import { apiValidator } from '../lib';
3
- import { unknown, dictionary } from './_helpers';
4
- export const user = object({
5
- name: string(),
6
- admin: defaultTo(boolean(), false),
7
- timeout: number(),
8
- userdata: dictionary(unknown()),
9
- permissions: optional(dictionary(array(string())))
10
- }, {
11
- allowExcessProperties: true
12
- });
13
- export const parseUser = apiValidator(user);
1
+ export {};
@@ -1,27 +1,2 @@
1
- import { ValidatorReturnType } from 'fefe';
2
- declare const variable: import("fefe").Validator<{
3
- name: string;
4
- title: string;
5
- value: string;
6
- isPrivate: boolean;
7
- } & {} & {
8
- variableType: "text";
9
- }, import("fefe").FefeError>;
10
- export declare type Variable = ValidatorReturnType<typeof variable>;
11
- export declare const parseVariable: import("../lib").APIValidator<{
12
- name: string;
13
- title: string;
14
- value: string;
15
- isPrivate: boolean;
16
- } & {} & {
17
- variableType: "text";
18
- }>;
19
- export declare const parseVariableList: import("../lib").APIValidator<({
20
- name: string;
21
- title: string;
22
- value: string;
23
- isPrivate: boolean;
24
- } & {} & {
25
- variableType: "text";
26
- })[]>;
27
- export {};
1
+ import { components } from '../generated/api-schema';
2
+ export declare type Variable = components['schemas']['Variable'];
@@ -1,16 +1 @@
1
- import { array, boolean, discriminatedUnion, string } from 'fefe';
2
- import { apiValidator } from '../lib';
3
- const variable = discriminatedUnion('variableType', {
4
- text: {
5
- name: string(),
6
- title: string(),
7
- value: string(),
8
- isPrivate: boolean()
9
- } // number: { name: string(), title: string(), value: number() },
10
-
11
- }, {
12
- allowExcessProperties: true
13
- });
14
- const variableList = array(variable);
15
- export const parseVariable = apiValidator(variable);
16
- export const parseVariableList = apiValidator(variableList);
1
+ export {};
@@ -13,14 +13,12 @@ export default {
13
13
  const mainGuest = new Attendee({
14
14
  id: 'my-attendee',
15
15
  language: 'de',
16
- auth: null,
17
16
  tags: ['VIP', 'Import-200-02-10'],
18
- time: new Date('2022-01-01'),
17
+ time: new Date('2022-01-01').toISOString(),
19
18
  rsvp: {
20
19
  default: 1
21
20
  },
22
21
  checkin: {},
23
- payment: null,
24
22
  companions: {
25
23
  isCompanion: false
26
24
  },
@@ -14,14 +14,12 @@ export default {
14
14
  const attendee = new Attendee({
15
15
  id: 'my-attendee',
16
16
  language: 'de',
17
- auth: null,
18
17
  tags: ['VIP', 'Import-200-02-10'],
19
- time: new Date('2022-01-01'),
18
+ time: new Date('2022-01-01').toISOString(),
20
19
  rsvp: {
21
20
  default: 1
22
21
  },
23
22
  checkin: {},
24
- payment: null,
25
23
  companions: {
26
24
  isCompanion: false
27
25
  },
@@ -33,14 +31,12 @@ const attendee = new Attendee({
33
31
  const companion = new Attendee({
34
32
  id: 'my-companion',
35
33
  language: 'de',
36
- auth: null,
37
34
  tags: ['VIP', 'Import-200-02-10'],
38
- time: new Date('2022-01-01'),
35
+ time: new Date('2022-01-01').toISOString(),
39
36
  rsvp: {
40
37
  default: 1
41
38
  },
42
39
  checkin: {},
43
- payment: null,
44
40
  companions: {
45
41
  isCompanion: true,
46
42
  mainGuestId: 'my-attendee'
@@ -0,0 +1,7 @@
1
+ import { FunctionComponent } from 'react';
2
+ declare type Props = {
3
+ color?: string;
4
+ rotateDeg: number;
5
+ };
6
+ export declare const Caret: FunctionComponent<Props>;
7
+ export {};
@@ -0,0 +1,20 @@
1
+ import React from 'react';
2
+ import { colors } from '../../lib/theme';
3
+ export const Caret = ({
4
+ color = colors.enterDarkGrey,
5
+ rotateDeg = 0
6
+ }) => {
7
+ return /*#__PURE__*/React.createElement("svg", {
8
+ xmlns: "http://www.w3.org/2000/svg",
9
+ width: "100%",
10
+ height: "auto",
11
+ viewBox: "0 0 16 16",
12
+ transform: `rotate(${rotateDeg})`,
13
+ fill: color
14
+ }, /*#__PURE__*/React.createElement("path", {
15
+ color: color,
16
+ fillRule: "evenodd",
17
+ transform: "translate(0,0)",
18
+ d: "M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z"
19
+ }));
20
+ };
@@ -0,0 +1,15 @@
1
+ import React from 'react';
2
+ import { ComponentStory, ComponentMeta } from '@storybook/react';
3
+ declare const _default: ComponentMeta<React.FunctionComponent<{
4
+ color?: string | undefined;
5
+ rotateDeg: number;
6
+ }>>;
7
+ export default _default;
8
+ export declare const Basic: ComponentStory<React.FunctionComponent<{
9
+ color?: string | undefined;
10
+ rotateDeg: number;
11
+ }>>;
12
+ export declare const White: ComponentStory<React.FunctionComponent<{
13
+ color?: string | undefined;
14
+ rotateDeg: number;
15
+ }>>;
@@ -0,0 +1,20 @@
1
+ import React from 'react';
2
+ import { Caret } from './caret';
3
+ export default {
4
+ title: 'Icons/Caret',
5
+ component: Caret
6
+ };
7
+
8
+ const Template = args => /*#__PURE__*/React.createElement(Caret, args);
9
+
10
+ export const Basic = Template.bind({});
11
+ Basic.args = {};
12
+ export const White = Template.bind({});
13
+ White.parameters = {
14
+ backgrounds: {
15
+ default: 'dark'
16
+ }
17
+ };
18
+ White.args = {
19
+ color: '#fff'
20
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dev-crew-berlin/enter-js-utils",
3
- "version": "0.23.0",
3
+ "version": "0.30.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",
@@ -21,7 +21,8 @@
21
21
  "lint": "eslint src/ --ext .ts",
22
22
  "test": "echo \"Error: no test specified\" && exit 1",
23
23
  "storybook": "start-storybook -p 6006",
24
- "build-storybook": "build-storybook"
24
+ "build-storybook": "build-storybook",
25
+ "generate-client": "openapi-typescript https://api.dev.enter.events/openapi.json --output src/generated/api-schema.ts --default-non-nullable --export-type"
25
26
  },
26
27
  "lint-staged": {
27
28
  "**/*": "prettier --write --ignore-unknown"
@@ -42,13 +43,14 @@
42
43
  "@babel/preset-env": "^7.18.2",
43
44
  "@babel/preset-react": "^7.17.12",
44
45
  "@babel/preset-typescript": "^7.17.12",
45
- "@storybook/addon-actions": "^6.5.8",
46
- "@storybook/addon-essentials": "^6.5.8",
47
- "@storybook/addon-interactions": "^6.5.8",
48
- "@storybook/addon-links": "^6.5.8",
46
+ "@liangskyli/openapi-typescript": "^5.4.1",
47
+ "@storybook/addon-actions": "^6.5.13",
48
+ "@storybook/addon-essentials": "^6.5.13",
49
+ "@storybook/addon-interactions": "^6.5.13",
50
+ "@storybook/addon-links": "^6.5.13",
49
51
  "@storybook/builder-webpack4": "^6.5.8",
50
52
  "@storybook/manager-webpack4": "^6.5.8",
51
- "@storybook/react": "^6.5.8",
53
+ "@storybook/react": "^6.5.13",
52
54
  "@storybook/testing-library": "^0.0.11",
53
55
  "@types/node": "^17.0.38",
54
56
  "@types/react": "^18.0.10",
@@ -61,7 +63,7 @@
61
63
  "prettier": "^2.6.2",
62
64
  "react": "^18.1.0",
63
65
  "react-dom": "^18.1.0",
64
- "typescript": "^4.7.3"
66
+ "typescript": "^4.8.4"
65
67
  },
66
68
  "peerDependencies": {
67
69
  "react": "^17.0.0 || ^18.1.0",
@@ -1,23 +0,0 @@
1
- import { Result, Validator } from 'fefe';
2
- export declare type Dictionary<T> = Record<string, T>;
3
- /**
4
- * creates a validator that tries to parse a unkown value to
5
- * a Dictionary.
6
- * We define a Dictionary as a js object with strings as a key.
7
- * e.g: `{ key: 'value' }
8
- * The value then is whatever the validator returns
9
- * So `const numDict = dictionary(number())` would make shure a object
10
- * has stings as a key and numbers as values.
11
- * A valid object could look like this: `{ key: 1 }`
12
- * @param validator the validator for the value of the record
13
- */
14
- export declare function dictionary<T>(validator: Validator<T>): (value: unknown) => Result<Dictionary<T>>;
15
- export declare function constant<T extends string | number | symbol | boolean>(constant: T): Validator<T>;
16
- export declare function toString(value: unknown): Result<string>;
17
- export declare function parseTimestamp(value: number): Result<Date>;
18
- export declare function maybe<T>(validator: Validator<T>): Validator<T | null>;
19
- export declare function maybe<T>(validator: Validator<T>, defaultValue: T): Validator<T>;
20
- export declare function noContent(value: unknown): Result<null>;
21
- export declare function unknown(): Validator<unknown>;
22
- export declare const parseNoContent: import("../lib").APIValidator<null>;
23
- export declare const positiveInteger: Validator<number, import("fefe").LeafError>;
@@ -1,89 +0,0 @@
1
- import { branchError, failure, isFailure, leafError, number, success } from 'fefe';
2
- import { apiValidator } from '../lib';
3
-
4
- /**
5
- * creates a validator that tries to parse a unkown value to
6
- * a Dictionary.
7
- * We define a Dictionary as a js object with strings as a key.
8
- * e.g: `{ key: 'value' }
9
- * The value then is whatever the validator returns
10
- * So `const numDict = dictionary(number())` would make shure a object
11
- * has stings as a key and numbers as values.
12
- * A valid object could look like this: `{ key: 1 }`
13
- * @param validator the validator for the value of the record
14
- */
15
- export function dictionary(validator) {
16
- return value => {
17
- // make shure value is an js object
18
- // keep in mind lots of things in js are objects arrays, Sets…
19
- // so this does not tell us too much
20
- if (typeof value !== 'object' || value === null) {
21
- return failure(leafError(value, 'expected value to be an object'));
22
- }
23
-
24
- const validatedProperties = Object.entries(value).map(([key, raw]) => {
25
- // make shure the key is of type string
26
- if (typeof key !== 'string') {
27
- return {
28
- key,
29
- result: failure(leafError([key, raw], 'expected key to be of type string'))
30
- };
31
- } // make shure the value is valid by passing it to the supplied validator
32
-
33
-
34
- return {
35
- key,
36
- result: validator(raw)
37
- };
38
- }); // collect possible errors
39
-
40
- const errors = validatedProperties.filter(property => isFailure(property.result)).map(property => {
41
- return {
42
- key: property.key,
43
- error: property.result.left
44
- };
45
- });
46
- if (errors.length !== 0) return failure(branchError(value, errors)); // flatten list of successfull results into single result
47
-
48
- return success(validatedProperties.reduce((a, b) => {
49
- a[b.key] = b.result.right;
50
- return a;
51
- }, {}));
52
- };
53
- }
54
- export function constant(constant) {
55
- return value => {
56
- if (value !== constant) {
57
- return failure(leafError(value, `expect value to be ${String(constant)}`));
58
- }
59
-
60
- return success(constant);
61
- };
62
- }
63
- export function toString(value) {
64
- return success('' + value);
65
- }
66
- export function parseTimestamp(value) {
67
- // js Date expects timestamp in mili seconds but we expect to parse a timestamp in seconds
68
- return success(new Date(value * 1000));
69
- }
70
- export function maybe(validator, defaultValue = null) {
71
- return value => {
72
- if (value === null || value === undefined) return success(defaultValue);
73
- return validator(value);
74
- };
75
- }
76
- export function noContent(value) {
77
- if (value === null || value === undefined) return success(null);
78
- return failure(leafError(value, 'expected value to be empty'));
79
- }
80
- export function unknown() {
81
- return value => success(value);
82
- }
83
- export const parseNoContent = apiValidator(noContent);
84
- export const positiveInteger = number({
85
- integer: true,
86
- min: 0,
87
- allowNaN: false,
88
- allowInfinity: false
89
- });
@@ -1,33 +0,0 @@
1
- import { ValidatorReturnType } from 'fefe';
2
- declare const invite: import("fefe").Validator<import("fefe").ObjectResult<{
3
- auth: import("fefe").Validator<string, import("fefe").LeafError>;
4
- count: import("fefe").Validator<number, import("fefe").LeafError>;
5
- limit: import("fefe").Validator<number, import("fefe").LeafError>;
6
- tags: import("fefe").Validator<string[], import("fefe").FefeError>;
7
- userdata: (value: unknown) => import("fefe").Result<import("./_helpers").Dictionary<string | number | string[] | null>, import("fefe").FefeError>;
8
- metadata: (value: unknown) => import("fefe").Result<import("./_helpers").Dictionary<string>, import("fefe").FefeError>;
9
- expires: import("fefe").Validator<Date | null, import("fefe").FefeError>;
10
- language: import("fefe").Validator<string | null, import("fefe").FefeError>;
11
- }>, import("fefe").FefeError>;
12
- export declare const parseInvite: import("../lib").APIValidator<import("fefe").ObjectResult<{
13
- auth: import("fefe").Validator<string, import("fefe").LeafError>;
14
- count: import("fefe").Validator<number, import("fefe").LeafError>;
15
- limit: import("fefe").Validator<number, import("fefe").LeafError>;
16
- tags: import("fefe").Validator<string[], import("fefe").FefeError>;
17
- userdata: (value: unknown) => import("fefe").Result<import("./_helpers").Dictionary<string | number | string[] | null>, import("fefe").FefeError>;
18
- metadata: (value: unknown) => import("fefe").Result<import("./_helpers").Dictionary<string>, import("fefe").FefeError>;
19
- expires: import("fefe").Validator<Date | null, import("fefe").FefeError>;
20
- language: import("fefe").Validator<string | null, import("fefe").FefeError>;
21
- }>>;
22
- export declare const parseInviteList: import("../lib").APIValidator<import("fefe").ObjectResult<{
23
- auth: import("fefe").Validator<string, import("fefe").LeafError>;
24
- count: import("fefe").Validator<number, import("fefe").LeafError>;
25
- limit: import("fefe").Validator<number, import("fefe").LeafError>;
26
- tags: import("fefe").Validator<string[], import("fefe").FefeError>;
27
- userdata: (value: unknown) => import("fefe").Result<import("./_helpers").Dictionary<string | number | string[] | null>, import("fefe").FefeError>;
28
- metadata: (value: unknown) => import("fefe").Result<import("./_helpers").Dictionary<string>, import("fefe").FefeError>;
29
- expires: import("fefe").Validator<Date | null, import("fefe").FefeError>;
30
- language: import("fefe").Validator<string | null, import("fefe").FefeError>;
31
- }>[]>;
32
- export declare type Invite = ValidatorReturnType<typeof invite>;
33
- export {};
@@ -1,21 +0,0 @@
1
- import { array, number, object, parseDate, pipe, string } from 'fefe';
2
- import { apiValidator } from '../lib';
3
- import { rawFieldValue } from './field-value';
4
- import { dictionary, maybe, toString } from './_helpers';
5
- const invite = object({
6
- auth: string(),
7
- count: number(),
8
- limit: number(),
9
- tags: array(string()),
10
- userdata: dictionary(rawFieldValue),
11
- metadata: dictionary(toString),
12
- expires: maybe(pipe(string()).pipe(parseDate({
13
- iso: true
14
- }))),
15
- language: maybe(string())
16
- }, {
17
- allowExcessProperties: true
18
- });
19
- const inviteList = array(invite);
20
- export const parseInvite = apiValidator(invite);
21
- export const parseInviteList = apiValidator(inviteList);
@@ -1,7 +0,0 @@
1
- import { ValidatorReturnType } from 'fefe';
2
- export declare const metaField: import("fefe").Validator<import("fefe").ObjectResult<{
3
- type: import("fefe").Validator<"text" | "checkbox" | "list" | "textfield", import("fefe").LeafError>;
4
- values: import("fefe").Validator<string[] | null, import("fefe").FefeError>;
5
- default: import("fefe").Validator<string | null, import("fefe").FefeError>;
6
- }>, import("fefe").FefeError>;
7
- export declare type MetaField = ValidatorReturnType<typeof metaField>;
@@ -1,9 +0,0 @@
1
- import { array, enumerate, object, optional, string } from 'fefe';
2
- import { maybe } from './_helpers';
3
- export const metaField = object({
4
- type: enumerate('checkbox', 'list', 'text', 'textfield'),
5
- values: maybe(optional(array(string()))),
6
- default: maybe(optional(string()))
7
- }, {
8
- allowExcessProperties: true
9
- });