@reykjavik/webtools 0.0.0 → 0.1.1
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/CHANGELOG.md +6 -3
- package/README.md +0 -6
- package/esm/http.d.ts +2 -2
- package/esm/next/http.d.ts +4 -4
- package/http.d.ts +2 -2
- package/next/http.d.ts +4 -4
- package/package.json +10 -10
package/CHANGELOG.md
CHANGED
|
@@ -4,8 +4,11 @@
|
|
|
4
4
|
|
|
5
5
|
- ... <!-- Add new lines here. -->
|
|
6
6
|
|
|
7
|
-
## 0.0.
|
|
7
|
+
## 0.1.0 – 0.1.1
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
_2023-03-24_
|
|
10
10
|
|
|
11
|
-
- feat: Initial release
|
|
11
|
+
- feat: Initial release with:
|
|
12
|
+
- HTTP helpers — both generic and Next.js specific
|
|
13
|
+
- React component + hook to make CookieHub consent easier to use.
|
|
14
|
+
- React component + custom-ping function for SiteImprove analytics.
|
package/README.md
CHANGED
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
# @reykjavik/webtools
|
|
2
2
|
|
|
3
|
-
> **Warning** This repo is still very much WIP. The npm package has **NOT**
|
|
4
|
-
> been published yet.
|
|
5
|
-
>
|
|
6
|
-
> See [Project Prep TODO](https://github.com/reykjavikcity/webtools/issues/1)
|
|
7
|
-
> for what's planned
|
|
8
|
-
|
|
9
3
|
Miscellaneous JavaScript/TypeScript helpers used by Reykjavík City's web dev
|
|
10
4
|
teams.
|
|
11
5
|
|
package/esm/http.d.ts
CHANGED
|
@@ -44,12 +44,12 @@ export declare const HTTP_500_InternalServerError = 500;
|
|
|
44
44
|
export type HTTP_SUCCESS = typeof HTTP_200_OK | typeof HTTP_201_Created | typeof HTTP_202_Accepted;
|
|
45
45
|
export type HTTP_REDIRECTION = typeof HTTP_301_MovedPermanently | typeof HTTP_302_Found | typeof HTTP_303_SeeOther | typeof HTTP_304_NotModified | typeof HTTP_307_TemporaryRedirect | typeof HTTP_308_PermanentRedirect;
|
|
46
46
|
export type HTTP_NOTMODIFIED = typeof HTTP_304_NotModified;
|
|
47
|
-
export type HTTP_CLIENT_ERROR = typeof HTTP_400_BadRequest | typeof HTTP_401_Unauthorized | typeof HTTP_403_Forbidden | typeof HTTP_404_NotFound | typeof HTTP_410_Gone
|
|
47
|
+
export type HTTP_CLIENT_ERROR = typeof HTTP_400_BadRequest | typeof HTTP_401_Unauthorized | typeof HTTP_403_Forbidden | typeof HTTP_404_NotFound | typeof HTTP_410_Gone;
|
|
48
48
|
export type HTTP_NOT_FOUND = typeof HTTP_400_BadRequest | typeof HTTP_404_NotFound | typeof HTTP_410_Gone;
|
|
49
49
|
export type HTTP_BANNED = typeof HTTP_401_Unauthorized | typeof HTTP_403_Forbidden;
|
|
50
50
|
export type HTTP_SERVER_ERROR = typeof HTTP_500_InternalServerError;
|
|
51
51
|
export type HTTP_ERROR = HTTP_CLIENT_ERROR | HTTP_SERVER_ERROR;
|
|
52
|
-
export type HTTP_STATUS = HTTP_SUCCESS | HTTP_REDIRECTION | HTTP_CLIENT_ERROR | HTTP_SERVER_ERROR;
|
|
52
|
+
export type HTTP_STATUS = HTTP_SUCCESS | HTTP_REDIRECTION | HTTP_CLIENT_ERROR | typeof HTTP_418_ImATeapot | HTTP_SERVER_ERROR;
|
|
53
53
|
type TimeUnit = 's' | 'm' | 'h' | 'd' | 'w';
|
|
54
54
|
type TTL = number | `${number}${TimeUnit}`;
|
|
55
55
|
type TTLKeywords = 'permanent' | 'unset' | 'no-cache';
|
package/esm/next/http.d.ts
CHANGED
|
@@ -3,20 +3,20 @@ import React, { FunctionComponent } from 'react';
|
|
|
3
3
|
import { Cleanup } from '@reykjavik/hanna-utils';
|
|
4
4
|
import { ServerResponse } from 'http';
|
|
5
5
|
import type { AppType } from 'next/app';
|
|
6
|
-
import type { HTTP_ERROR, TTLConfig } from '../http';
|
|
6
|
+
import type { HTTP_418_ImATeapot, HTTP_ERROR, TTLConfig } from '../http';
|
|
7
|
+
type HTTP_ERROR_all = HTTP_ERROR | typeof HTTP_418_ImATeapot;
|
|
7
8
|
export * from '../http';
|
|
8
9
|
type NextContextLike = {
|
|
9
10
|
res: ServerResponse;
|
|
10
11
|
};
|
|
11
12
|
export type ErrorProps = {
|
|
12
|
-
statusCode:
|
|
13
|
-
/** If a HTTP_ERROR code is passed, a default error message is displayed */
|
|
13
|
+
statusCode: HTTP_ERROR_all;
|
|
14
14
|
message?: string;
|
|
15
15
|
};
|
|
16
16
|
type ErrorizedPageProps<EP extends ErrorProps = ErrorProps> = {
|
|
17
17
|
__error: ErrorProps;
|
|
18
18
|
} & Omit<EP, keyof ErrorProps>;
|
|
19
|
-
type ShowErrorPageFn<EP extends ErrorProps = ErrorProps> = (response: ServerResponse | NextContextLike, error: (ErrorProps extends EP ?
|
|
19
|
+
type ShowErrorPageFn<EP extends ErrorProps = ErrorProps> = (response: ServerResponse | NextContextLike, error: (ErrorProps extends EP ? HTTP_ERROR_all : never) | EP,
|
|
20
20
|
/** Defaults to `"2s"`. Gets forwarded on to the `cacheControl` helper from `@reykjavik/webtools/http` */
|
|
21
21
|
ttl?: TTLConfig) => {
|
|
22
22
|
props: ErrorizedPageProps<EP>;
|
package/http.d.ts
CHANGED
|
@@ -44,12 +44,12 @@ export declare const HTTP_500_InternalServerError = 500;
|
|
|
44
44
|
export type HTTP_SUCCESS = typeof HTTP_200_OK | typeof HTTP_201_Created | typeof HTTP_202_Accepted;
|
|
45
45
|
export type HTTP_REDIRECTION = typeof HTTP_301_MovedPermanently | typeof HTTP_302_Found | typeof HTTP_303_SeeOther | typeof HTTP_304_NotModified | typeof HTTP_307_TemporaryRedirect | typeof HTTP_308_PermanentRedirect;
|
|
46
46
|
export type HTTP_NOTMODIFIED = typeof HTTP_304_NotModified;
|
|
47
|
-
export type HTTP_CLIENT_ERROR = typeof HTTP_400_BadRequest | typeof HTTP_401_Unauthorized | typeof HTTP_403_Forbidden | typeof HTTP_404_NotFound | typeof HTTP_410_Gone
|
|
47
|
+
export type HTTP_CLIENT_ERROR = typeof HTTP_400_BadRequest | typeof HTTP_401_Unauthorized | typeof HTTP_403_Forbidden | typeof HTTP_404_NotFound | typeof HTTP_410_Gone;
|
|
48
48
|
export type HTTP_NOT_FOUND = typeof HTTP_400_BadRequest | typeof HTTP_404_NotFound | typeof HTTP_410_Gone;
|
|
49
49
|
export type HTTP_BANNED = typeof HTTP_401_Unauthorized | typeof HTTP_403_Forbidden;
|
|
50
50
|
export type HTTP_SERVER_ERROR = typeof HTTP_500_InternalServerError;
|
|
51
51
|
export type HTTP_ERROR = HTTP_CLIENT_ERROR | HTTP_SERVER_ERROR;
|
|
52
|
-
export type HTTP_STATUS = HTTP_SUCCESS | HTTP_REDIRECTION | HTTP_CLIENT_ERROR | HTTP_SERVER_ERROR;
|
|
52
|
+
export type HTTP_STATUS = HTTP_SUCCESS | HTTP_REDIRECTION | HTTP_CLIENT_ERROR | typeof HTTP_418_ImATeapot | HTTP_SERVER_ERROR;
|
|
53
53
|
type TimeUnit = 's' | 'm' | 'h' | 'd' | 'w';
|
|
54
54
|
type TTL = number | `${number}${TimeUnit}`;
|
|
55
55
|
type TTLKeywords = 'permanent' | 'unset' | 'no-cache';
|
package/next/http.d.ts
CHANGED
|
@@ -3,20 +3,20 @@ import React, { FunctionComponent } from 'react';
|
|
|
3
3
|
import { Cleanup } from '@reykjavik/hanna-utils';
|
|
4
4
|
import { ServerResponse } from 'http';
|
|
5
5
|
import type { AppType } from 'next/app';
|
|
6
|
-
import type { HTTP_ERROR, TTLConfig } from '../http';
|
|
6
|
+
import type { HTTP_418_ImATeapot, HTTP_ERROR, TTLConfig } from '../http';
|
|
7
|
+
type HTTP_ERROR_all = HTTP_ERROR | typeof HTTP_418_ImATeapot;
|
|
7
8
|
export * from '../http';
|
|
8
9
|
type NextContextLike = {
|
|
9
10
|
res: ServerResponse;
|
|
10
11
|
};
|
|
11
12
|
export type ErrorProps = {
|
|
12
|
-
statusCode:
|
|
13
|
-
/** If a HTTP_ERROR code is passed, a default error message is displayed */
|
|
13
|
+
statusCode: HTTP_ERROR_all;
|
|
14
14
|
message?: string;
|
|
15
15
|
};
|
|
16
16
|
type ErrorizedPageProps<EP extends ErrorProps = ErrorProps> = {
|
|
17
17
|
__error: ErrorProps;
|
|
18
18
|
} & Omit<EP, keyof ErrorProps>;
|
|
19
|
-
type ShowErrorPageFn<EP extends ErrorProps = ErrorProps> = (response: ServerResponse | NextContextLike, error: (ErrorProps extends EP ?
|
|
19
|
+
type ShowErrorPageFn<EP extends ErrorProps = ErrorProps> = (response: ServerResponse | NextContextLike, error: (ErrorProps extends EP ? HTTP_ERROR_all : never) | EP,
|
|
20
20
|
/** Defaults to `"2s"`. Gets forwarded on to the `cacheControl` helper from `@reykjavik/webtools/http` */
|
|
21
21
|
ttl?: TTLConfig) => {
|
|
22
22
|
props: ErrorizedPageProps<EP>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reykjavik/webtools",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Misc. JS/TS helpers used by Reykjavík City's web dev teams.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"repository": "ssh://git@github.com:reykjavikcity/webtools.git",
|
|
@@ -23,9 +23,9 @@
|
|
|
23
23
|
},
|
|
24
24
|
"sideEffects": false,
|
|
25
25
|
"exports": {
|
|
26
|
-
"./CookieHubConsent
|
|
27
|
-
"import": "./esm/CookieHubConsent.
|
|
28
|
-
"require": "./CookieHubConsent.
|
|
26
|
+
"./CookieHubConsent": {
|
|
27
|
+
"import": "./esm/CookieHubConsent.js",
|
|
28
|
+
"require": "./CookieHubConsent.js"
|
|
29
29
|
},
|
|
30
30
|
"./http": {
|
|
31
31
|
"import": "./esm/http.js",
|
|
@@ -35,13 +35,13 @@
|
|
|
35
35
|
"import": "./esm/index.js",
|
|
36
36
|
"require": "./index.js"
|
|
37
37
|
},
|
|
38
|
-
"./next/http
|
|
39
|
-
"import": "./esm/next/http.
|
|
40
|
-
"require": "./next/http.
|
|
38
|
+
"./next/http": {
|
|
39
|
+
"import": "./esm/next/http.js",
|
|
40
|
+
"require": "./next/http.js"
|
|
41
41
|
},
|
|
42
|
-
"./next/SiteImprove
|
|
43
|
-
"import": "./esm/next/SiteImprove.
|
|
44
|
-
"require": "./next/SiteImprove.
|
|
42
|
+
"./next/SiteImprove": {
|
|
43
|
+
"import": "./esm/next/SiteImprove.js",
|
|
44
|
+
"require": "./next/SiteImprove.js"
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
}
|