@serwist/build 10.0.0-preview.1 → 10.0.0-preview.10

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 (111) hide show
  1. package/dist/chunks/constants.js +59 -0
  2. package/dist/chunks/get-manifest.js +11 -0
  3. package/dist/chunks/glob.js +45 -28
  4. package/dist/chunks/inject-manifest.js +29 -0
  5. package/dist/get-manifest.d.ts.map +1 -1
  6. package/dist/index.d.ts +3 -11
  7. package/dist/index.d.ts.map +1 -1
  8. package/dist/index.js +16 -151
  9. package/dist/index.schema.d.ts +9 -9
  10. package/dist/index.schema.d.ts.map +1 -1
  11. package/dist/index.schema.js +4 -4
  12. package/dist/inject-manifest.d.ts.map +1 -1
  13. package/dist/lib/additional-precache-entries-transform.d.ts.map +1 -1
  14. package/dist/lib/constants.d.ts +2 -0
  15. package/dist/lib/constants.d.ts.map +1 -0
  16. package/dist/lib/escape-regexp.d.ts.map +1 -1
  17. package/dist/lib/get-file-details.d.ts +2 -1
  18. package/dist/lib/get-file-details.d.ts.map +1 -1
  19. package/dist/lib/get-file-manifest-entries.d.ts.map +1 -1
  20. package/dist/lib/modify-url-prefix-transform.d.ts.map +1 -1
  21. package/dist/lib/no-revision-for-urls-matching-transform.d.ts.map +1 -1
  22. package/dist/lib/transform-manifest.d.ts +2 -1
  23. package/dist/lib/transform-manifest.d.ts.map +1 -1
  24. package/dist/lib/validate-options.d.ts.map +1 -1
  25. package/dist/schema/{assertType.d.ts → assert-type.d.ts} +1 -1
  26. package/dist/schema/assert-type.d.ts.map +1 -0
  27. package/dist/schema/base.d.ts +45 -151
  28. package/dist/schema/base.d.ts.map +1 -1
  29. package/dist/schema/{serwistConfigError.d.ts → error.d.ts} +3 -1
  30. package/dist/schema/error.d.ts.map +1 -0
  31. package/dist/schema/get-manifest.d.ts +72 -0
  32. package/dist/schema/get-manifest.d.ts.map +1 -0
  33. package/dist/schema/glob.d.ts +6 -26
  34. package/dist/schema/glob.d.ts.map +1 -1
  35. package/dist/schema/inject-manifest.d.ts +79 -0
  36. package/dist/schema/inject-manifest.d.ts.map +1 -0
  37. package/dist/schema/manifest-entry.d.ts +7 -0
  38. package/dist/schema/manifest-entry.d.ts.map +1 -0
  39. package/dist/schema/manifest-transform.d.ts +64 -0
  40. package/dist/schema/manifest-transform.d.ts.map +1 -0
  41. package/dist/schema/sw-dest.d.ts +8 -0
  42. package/dist/schema/sw-dest.d.ts.map +1 -0
  43. package/dist/schema/utils.d.ts +10 -0
  44. package/dist/schema/utils.d.ts.map +1 -0
  45. package/dist/types.d.ts +12 -13
  46. package/dist/types.d.ts.map +1 -1
  47. package/package.json +14 -12
  48. package/src/index.schema.ts +10 -8
  49. package/src/index.ts +5 -11
  50. package/src/inject-manifest.ts +2 -1
  51. package/src/lib/additional-precache-entries-transform.ts +1 -2
  52. package/src/lib/constants.ts +1 -0
  53. package/src/lib/get-file-details.ts +3 -4
  54. package/src/lib/get-file-manifest-entries.ts +3 -4
  55. package/src/lib/modify-url-prefix-transform.ts +1 -1
  56. package/src/lib/no-revision-for-urls-matching-transform.ts +1 -1
  57. package/src/lib/rebase-path.ts +1 -1
  58. package/src/lib/transform-manifest.ts +3 -3
  59. package/src/lib/translate-url-to-sourcemap-paths.ts +4 -4
  60. package/src/lib/validate-options.ts +12 -6
  61. package/src/schema/base.ts +11 -13
  62. package/src/schema/error.ts +53 -0
  63. package/src/schema/{getManifest.ts → get-manifest.ts} +7 -6
  64. package/src/schema/glob.ts +15 -20
  65. package/src/schema/inject-manifest.ts +24 -0
  66. package/src/schema/manifest-entry.ts +7 -0
  67. package/src/schema/manifest-transform.ts +17 -0
  68. package/src/schema/{swDest.ts → sw-dest.ts} +7 -11
  69. package/src/schema/utils.ts +27 -0
  70. package/src/types.ts +11 -14
  71. package/dist/chunks/getManifest.js +0 -6
  72. package/dist/chunks/injectManifest.js +0 -23
  73. package/dist/chunks/validationErrorMap.js +0 -54
  74. package/dist/lib/errors.d.ts +0 -47
  75. package/dist/lib/errors.d.ts.map +0 -1
  76. package/dist/lib/get-composite-details.d.ts +0 -3
  77. package/dist/lib/get-composite-details.d.ts.map +0 -1
  78. package/dist/lib/get-file-hash.d.ts +0 -2
  79. package/dist/lib/get-file-hash.d.ts.map +0 -1
  80. package/dist/lib/get-file-size.d.ts +0 -2
  81. package/dist/lib/get-file-size.d.ts.map +0 -1
  82. package/dist/lib/get-string-details.d.ts +0 -3
  83. package/dist/lib/get-string-details.d.ts.map +0 -1
  84. package/dist/lib/get-string-hash.d.ts +0 -3
  85. package/dist/lib/get-string-hash.d.ts.map +0 -1
  86. package/dist/schema/assertType.d.ts.map +0 -1
  87. package/dist/schema/getManifest.d.ts +0 -192
  88. package/dist/schema/getManifest.d.ts.map +0 -1
  89. package/dist/schema/injectManifest.d.ts +0 -213
  90. package/dist/schema/injectManifest.d.ts.map +0 -1
  91. package/dist/schema/manifestEntry.d.ts +0 -15
  92. package/dist/schema/manifestEntry.d.ts.map +0 -1
  93. package/dist/schema/manifestTransform.d.ts +0 -125
  94. package/dist/schema/manifestTransform.d.ts.map +0 -1
  95. package/dist/schema/serwistConfigError.d.ts.map +0 -1
  96. package/dist/schema/swDest.d.ts +0 -16
  97. package/dist/schema/swDest.d.ts.map +0 -1
  98. package/dist/schema/validationErrorMap.d.ts +0 -3
  99. package/dist/schema/validationErrorMap.d.ts.map +0 -1
  100. package/src/lib/errors.ts +0 -93
  101. package/src/lib/get-composite-details.ts +0 -31
  102. package/src/lib/get-file-hash.ts +0 -21
  103. package/src/lib/get-file-size.ts +0 -22
  104. package/src/lib/get-string-details.ts +0 -16
  105. package/src/lib/get-string-hash.ts +0 -15
  106. package/src/schema/injectManifest.ts +0 -25
  107. package/src/schema/manifestEntry.ts +0 -9
  108. package/src/schema/manifestTransform.ts +0 -15
  109. package/src/schema/serwistConfigError.ts +0 -6
  110. package/src/schema/validationErrorMap.ts +0 -36
  111. /package/src/schema/{assertType.ts → assert-type.ts} +0 -0
@@ -1,125 +0,0 @@
1
- import { z } from "zod";
2
- export declare const manifestTransformResult: z.ZodObject<{
3
- manifest: z.ZodArray<z.ZodObject<z.objectUtil.extendShape<{
4
- integrity: z.ZodOptional<z.ZodString>;
5
- revision: z.ZodOptional<z.ZodNullable<z.ZodString>>;
6
- url: z.ZodString;
7
- }, {
8
- size: z.ZodNumber;
9
- }>, "strip", z.ZodTypeAny, {
10
- url: string;
11
- size: number;
12
- integrity?: string | undefined;
13
- revision?: string | null | undefined;
14
- }, {
15
- url: string;
16
- size: number;
17
- integrity?: string | undefined;
18
- revision?: string | null | undefined;
19
- }>, "many">;
20
- warnings: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
21
- }, "strict", z.ZodTypeAny, {
22
- manifest: {
23
- url: string;
24
- size: number;
25
- integrity?: string | undefined;
26
- revision?: string | null | undefined;
27
- }[];
28
- warnings?: string[] | undefined;
29
- }, {
30
- manifest: {
31
- url: string;
32
- size: number;
33
- integrity?: string | undefined;
34
- revision?: string | null | undefined;
35
- }[];
36
- warnings?: string[] | undefined;
37
- }>;
38
- export declare const manifestTransform: z.ZodFunction<z.ZodTuple<[z.ZodArray<z.ZodObject<z.objectUtil.extendShape<{
39
- integrity: z.ZodOptional<z.ZodString>;
40
- revision: z.ZodOptional<z.ZodNullable<z.ZodString>>;
41
- url: z.ZodString;
42
- }, {
43
- size: z.ZodNumber;
44
- }>, "strip", z.ZodTypeAny, {
45
- url: string;
46
- size: number;
47
- integrity?: string | undefined;
48
- revision?: string | null | undefined;
49
- }, {
50
- url: string;
51
- size: number;
52
- integrity?: string | undefined;
53
- revision?: string | null | undefined;
54
- }>, "many">, z.ZodOptional<z.ZodUnknown>], null>, z.ZodUnion<[z.ZodPromise<z.ZodObject<{
55
- manifest: z.ZodArray<z.ZodObject<z.objectUtil.extendShape<{
56
- integrity: z.ZodOptional<z.ZodString>;
57
- revision: z.ZodOptional<z.ZodNullable<z.ZodString>>;
58
- url: z.ZodString;
59
- }, {
60
- size: z.ZodNumber;
61
- }>, "strip", z.ZodTypeAny, {
62
- url: string;
63
- size: number;
64
- integrity?: string | undefined;
65
- revision?: string | null | undefined;
66
- }, {
67
- url: string;
68
- size: number;
69
- integrity?: string | undefined;
70
- revision?: string | null | undefined;
71
- }>, "many">;
72
- warnings: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
73
- }, "strict", z.ZodTypeAny, {
74
- manifest: {
75
- url: string;
76
- size: number;
77
- integrity?: string | undefined;
78
- revision?: string | null | undefined;
79
- }[];
80
- warnings?: string[] | undefined;
81
- }, {
82
- manifest: {
83
- url: string;
84
- size: number;
85
- integrity?: string | undefined;
86
- revision?: string | null | undefined;
87
- }[];
88
- warnings?: string[] | undefined;
89
- }>>, z.ZodObject<{
90
- manifest: z.ZodArray<z.ZodObject<z.objectUtil.extendShape<{
91
- integrity: z.ZodOptional<z.ZodString>;
92
- revision: z.ZodOptional<z.ZodNullable<z.ZodString>>;
93
- url: z.ZodString;
94
- }, {
95
- size: z.ZodNumber;
96
- }>, "strip", z.ZodTypeAny, {
97
- url: string;
98
- size: number;
99
- integrity?: string | undefined;
100
- revision?: string | null | undefined;
101
- }, {
102
- url: string;
103
- size: number;
104
- integrity?: string | undefined;
105
- revision?: string | null | undefined;
106
- }>, "many">;
107
- warnings: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
108
- }, "strict", z.ZodTypeAny, {
109
- manifest: {
110
- url: string;
111
- size: number;
112
- integrity?: string | undefined;
113
- revision?: string | null | undefined;
114
- }[];
115
- warnings?: string[] | undefined;
116
- }, {
117
- manifest: {
118
- url: string;
119
- size: number;
120
- integrity?: string | undefined;
121
- revision?: string | null | undefined;
122
- }[];
123
- warnings?: string[] | undefined;
124
- }>]>>;
125
- //# sourceMappingURL=manifestTransform.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"manifestTransform.d.ts","sourceRoot":"","sources":["../../src/schema/manifestTransform.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAKmC,CAAC;AAExE,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAG7B,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"serwistConfigError.d.ts","sourceRoot":"","sources":["../../src/schema/serwistConfigError.ts"],"names":[],"mappings":"AAAA,qBAAa,kBAAmB,SAAQ,KAAK;gBAC/B,EAAE,UAAU,EAAE,OAAO,EAAE,EAAE;QAAE,UAAU,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE;CAI/E"}
@@ -1,16 +0,0 @@
1
- import { z } from "zod";
2
- export declare const optionalSwDestPartial: z.ZodObject<{
3
- swDest: z.ZodOptional<z.ZodString>;
4
- }, "strict", z.ZodTypeAny, {
5
- swDest?: string | undefined;
6
- }, {
7
- swDest?: string | undefined;
8
- }>;
9
- export declare const requiredSwDestPartial: z.ZodObject<{
10
- swDest: z.ZodString;
11
- }, "strict", z.ZodTypeAny, {
12
- swDest: string;
13
- }, {
14
- swDest: string;
15
- }>;
16
- //# sourceMappingURL=swDest.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"swDest.d.ts","sourceRoot":"","sources":["../../src/schema/swDest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,eAAO,MAAM,qBAAqB;;;;;;EAI4B,CAAC;AAE/D,eAAO,MAAM,qBAAqB;;;;;;EAI4B,CAAC"}
@@ -1,3 +0,0 @@
1
- import { z } from "zod";
2
- export declare const validationErrorMap: z.ZodErrorMap;
3
- //# sourceMappingURL=validationErrorMap.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"validationErrorMap.d.ts","sourceRoot":"","sources":["../../src/schema/validationErrorMap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,kBAAkB,EAAE,CAAC,CAAC,WAiClC,CAAC"}
package/src/lib/errors.ts DELETED
@@ -1,93 +0,0 @@
1
- /*
2
- Copyright 2018 Google LLC
3
-
4
- Use of this source code is governed by an MIT-style
5
- license that can be found in the LICENSE file or at
6
- https://opensource.org/licenses/MIT.
7
- */
8
-
9
- import { oneLine as ol } from "common-tags";
10
-
11
- export const errors = {
12
- "unable-to-get-rootdir": "Unable to get the root directory of your web app.",
13
- "no-extension": ol`Unable to detect a usable extension for a file in your web
14
- app directory.`,
15
- "invalid-file-manifest-name": ol`The File Manifest Name must have at least one
16
- character.`,
17
- "unable-to-get-file-manifest-name": "Unable to get a file manifest name.",
18
- "invalid-sw-dest": `The 'swDest' value must be a valid path.`,
19
- "unable-to-get-sw-name": "Unable to get a service worker file name.",
20
- "unable-to-get-save-config": ol`An error occurred when asking to save details
21
- in a config file.`,
22
- "unable-to-get-file-hash": ol`An error occurred when attempting to create a
23
- file hash.`,
24
- "unable-to-get-file-size": ol`An error occurred when attempting to get a file
25
- size.`,
26
- "unable-to-glob-files": "An error occurred when globbing for files.",
27
- "unable-to-make-manifest-directory": ol`Unable to make output directory for
28
- file manifest.`,
29
- "read-manifest-template-failure": "Unable to read template for file manifest",
30
- "populating-manifest-tmpl-failed": ol`An error occurred when populating the
31
- file manifest template.`,
32
- "manifest-file-write-failure": "Unable to write the file manifest.",
33
- "unable-to-make-sw-directory": ol`Unable to make the directories to output
34
- the service worker path.`,
35
- "sw-write-failure": "Unable to write the service worker file.",
36
- "sw-write-failure-directory": ol`Unable to write the service worker file;
37
- 'swDest' should be a full path to the file, not a path to a directory.`,
38
- "unable-to-copy-serwist-libraries": ol`One or more of the Serwist libraries
39
- could not be copied over to the destination directory: `,
40
- "invalid-glob-directory": ol`The supplied globDirectory must be a path as a
41
- string.`,
42
- "invalid-dont-cache-bust": ol`The supplied 'dontCacheBustURLsMatching'
43
- parameter must be a RegExp.`,
44
- "invalid-exclude-files": "The excluded files should be an array of strings.",
45
- "invalid-get-manifest-entries-input": ol`The input to
46
- 'getFileManifestEntries()' must be an object.`,
47
- "invalid-manifest-path": ol`The supplied manifest path is not a string with
48
- at least one character.`,
49
- "invalid-manifest-entries": ol`The manifest entries must be an array of
50
- strings or JavaScript objects containing a url parameter.`,
51
- "invalid-manifest-format": ol`The value of the 'format' option passed to
52
- generateFileManifest() must be either 'iife' (the default) or 'es'.`,
53
- "invalid-static-file-globs": ol`The 'globPatterns' value must be an array
54
- of strings.`,
55
- "invalid-templated-urls": ol`The 'templatedURLs' value should be an object
56
- that maps URLs to either a string, or to an array of glob patterns.`,
57
- "templated-url-matches-glob": ol`One of the 'templatedURLs' URLs is already
58
- being tracked via 'globPatterns': `,
59
- "invalid-glob-ignores": ol`The 'globIgnores' parameter must be an array of
60
- glob pattern strings.`,
61
- "manifest-entry-bad-url": ol`The generated manifest contains an entry without
62
- a URL string. This is likely an error with @serwist/build.`,
63
- "modify-url-prefix-bad-prefixes": ol`The 'modifyURLPrefix' parameter must be
64
- an object with string key value pairs.`,
65
- "invalid-inject-manifest-arg": ol`The input to 'injectManifest()' must be an
66
- object.`,
67
- "injection-point-not-found": ol`Unable to find a place to inject the manifest.
68
- Please ensure that your service worker file contains the following: `,
69
- "multiple-injection-points": ol`Please ensure that your 'swSrc' file contains
70
- only one match for the following: `,
71
- "useless-glob-pattern": ol`One of the glob patterns doesn't match any files.
72
- Please remove or fix the following: `,
73
- "bad-template-urls-asset": ol`There was an issue using one of the provided
74
- 'templatedURLs'.`,
75
- "invalid-generate-file-manifest-arg": ol`The input to generateFileManifest()
76
- must be an Object.`,
77
- "invalid-sw-src": `The 'swSrc' file can't be read.`,
78
- "same-src-and-dest": ol`Unable to find a place to inject the manifest. This is
79
- likely because swSrc and swDest are configured to the same file.
80
- Please ensure that your swSrc file contains the following:`,
81
- "no-module-name": ol`You must provide a moduleName parameter when calling
82
- getModuleURL().`,
83
- "bad-manifest-transforms-return-value": ol`The return value from a
84
- manifestTransform should be an object with 'manifest' and optionally
85
- 'warnings' properties.`,
86
- "string-entry-warning": ol`Some items were passed to additionalPrecacheEntries
87
- without revisioning info. This is generally NOT safe. Learn more at
88
- https://bit.ly/wb-precache.`,
89
- "cant-find-sourcemap": ol`The swSrc file refers to a sourcemap that can't be
90
- opened:`,
91
- "manifest-transforms": ol`When using manifestTransforms, you must provide
92
- an array of functions.`,
93
- };
@@ -1,31 +0,0 @@
1
- /*
2
- Copyright 2018 Google LLC
3
-
4
- Use of this source code is governed by an MIT-style
5
- license that can be found in the LICENSE file or at
6
- https://opensource.org/licenses/MIT.
7
- */
8
-
9
- import crypto from "node:crypto";
10
-
11
- import type { FileDetails } from "../types.js";
12
-
13
- export const getCompositeDetails = (compositeURL: string, dependencyDetails: FileDetails[]): FileDetails => {
14
- let totalSize = 0;
15
- let compositeHash = "";
16
-
17
- for (const fileDetails of dependencyDetails) {
18
- totalSize += fileDetails.size;
19
- compositeHash += fileDetails.hash === null ? "" : fileDetails.hash;
20
- }
21
-
22
- const md5 = crypto.createHash("md5");
23
- md5.update(compositeHash);
24
- const hashOfHashes = md5.digest("hex");
25
-
26
- return {
27
- file: compositeURL,
28
- hash: hashOfHashes,
29
- size: totalSize,
30
- };
31
- };
@@ -1,21 +0,0 @@
1
- /*
2
- Copyright 2018 Google LLC
3
-
4
- Use of this source code is governed by an MIT-style
5
- license that can be found in the LICENSE file or at
6
- https://opensource.org/licenses/MIT.
7
- */
8
-
9
- import { readFileSync } from "node:fs";
10
-
11
- import { errors } from "./errors.js";
12
- import { getStringHash } from "./get-string-hash.js";
13
-
14
- export const getFileHash = (file: string): string => {
15
- try {
16
- const buffer = readFileSync(file);
17
- return getStringHash(buffer);
18
- } catch (err) {
19
- throw new Error(`${errors["unable-to-get-file-hash"]} '${err instanceof Error && err.message ? err.message : ""}'`);
20
- }
21
- };
@@ -1,22 +0,0 @@
1
- /*
2
- Copyright 2018 Google LLC
3
-
4
- Use of this source code is governed by an MIT-style
5
- license that can be found in the LICENSE file or at
6
- https://opensource.org/licenses/MIT.
7
- */
8
-
9
- import fs from "node:fs";
10
- import { errors } from "./errors.js";
11
-
12
- export const getFileSize = (file: string): number | null => {
13
- try {
14
- const stat = fs.statSync(file);
15
- if (!stat.isFile()) {
16
- return null;
17
- }
18
- return stat.size;
19
- } catch (err) {
20
- throw new Error(`${errors["unable-to-get-file-size"]} '${err instanceof Error && err.message ? err.message : ""}'`);
21
- }
22
- };
@@ -1,16 +0,0 @@
1
- /*
2
- Copyright 2018 Google LLC
3
-
4
- Use of this source code is governed by an MIT-style
5
- license that can be found in the LICENSE file or at
6
- https://opensource.org/licenses/MIT.
7
- */
8
-
9
- import type { FileDetails } from "../types.js";
10
- import { getStringHash } from "./get-string-hash.js";
11
-
12
- export const getStringDetails = (url: string, str: string): FileDetails => ({
13
- file: url,
14
- hash: getStringHash(str),
15
- size: str.length,
16
- });
@@ -1,15 +0,0 @@
1
- /*
2
- Copyright 2018 Google LLC
3
-
4
- Use of this source code is governed by an MIT-style
5
- license that can be found in the LICENSE file or at
6
- https://opensource.org/licenses/MIT.
7
- */
8
-
9
- import crypto from "node:crypto";
10
-
11
- export function getStringHash(input: crypto.BinaryLike): string {
12
- const md5 = crypto.createHash("md5");
13
- md5.update(input);
14
- return md5.digest("hex");
15
- }
@@ -1,25 +0,0 @@
1
- import { z } from "zod";
2
- import type { InjectManifestOptions, InjectManifestOptionsComplete, InjectPartial, InjectResolved } from "../types.js";
3
- import { type Equals, assertType } from "./assertType.js";
4
- import { basePartial } from "./base.js";
5
- import { globPartial, requiredGlobDirectoryPartial } from "./glob.js";
6
- import { requiredSwDestPartial } from "./swDest.js";
7
-
8
- export const baseInjectPartial = z
9
- .object({
10
- injectionPoint: z.string().min(1, "`injectionPoint` must not be empty!").default("self.__SW_MANIFEST"),
11
- swSrc: z.string().min(1, "`swSrc` must not be empty!"),
12
- })
13
- .strict("Do not pass invalid properties to InjectPartial!");
14
-
15
- export const injectManifestOptions = basePartial
16
- .merge(globPartial)
17
- .merge(baseInjectPartial)
18
- .merge(requiredSwDestPartial)
19
- .merge(requiredGlobDirectoryPartial)
20
- .strict("Do not pass invalid properties to InjectManifestOptions!");
21
-
22
- assertType<Equals<InjectPartial, z.input<typeof baseInjectPartial>>>();
23
- assertType<Equals<InjectResolved, z.output<typeof baseInjectPartial>>>();
24
- assertType<Equals<InjectManifestOptions, z.input<typeof injectManifestOptions>>>();
25
- assertType<Equals<InjectManifestOptionsComplete, z.output<typeof injectManifestOptions>>>();
@@ -1,9 +0,0 @@
1
- import { z } from "zod";
2
-
3
- export const manifestEntry = z
4
- .object({
5
- integrity: z.string().optional(),
6
- revision: z.string().nullable().optional(),
7
- url: z.string(),
8
- })
9
- .strict("Do not pass invalid properties to ManifestEntry!");
@@ -1,15 +0,0 @@
1
- import { z } from "zod";
2
-
3
- import { manifestEntry } from "./manifestEntry.js";
4
-
5
- export const manifestTransformResult = z
6
- .object({
7
- manifest: z.array(manifestEntry.merge(z.object({ size: z.number() }))),
8
- warnings: z.array(z.string()).optional(),
9
- })
10
- .strict("Do not pass invalid properties to ManifestTransformResult!");
11
-
12
- export const manifestTransform = z.function(
13
- z.tuple([z.array(manifestEntry.merge(z.object({ size: z.number() }))), z.unknown().optional()]),
14
- z.union([z.promise(manifestTransformResult), manifestTransformResult]),
15
- );
@@ -1,6 +0,0 @@
1
- export class SerwistConfigError extends Error {
2
- constructor({ moduleName, message }: { moduleName?: string; message?: string }) {
3
- super(`Received an invalid ${moduleName ?? "Serwist"} configuration: ${message}`);
4
- Object.setPrototypeOf(this, new.target.prototype);
5
- }
6
- }
@@ -1,36 +0,0 @@
1
- import { z } from "zod";
2
-
3
- export const validationErrorMap: z.ZodErrorMap = (error, ctx) => {
4
- /*
5
- This is where you override the various error codes
6
- */
7
- switch (error.code) {
8
- case z.ZodIssueCode.invalid_type: {
9
- return { message: `${error.message ?? "Received invalid type"}: expected ${error.expected}, received ${error.received}.` };
10
- }
11
- case z.ZodIssueCode.invalid_literal: {
12
- return { message: `${error.message ?? "Received invalid literal"}: expected ${error.expected}, received ${error.received}.` };
13
- }
14
- case z.ZodIssueCode.unrecognized_keys: {
15
- return { message: `${error.message ?? "Received unrecognized keys"}: ${error.keys.join(",")}` };
16
- }
17
- case z.ZodIssueCode.invalid_arguments: {
18
- return {
19
- message: `${error.message ?? "Received invalid arguments"}: ${error.argumentsError.errors.map((e) => validationErrorMap(e, ctx)).join(",")}.`,
20
- };
21
- }
22
- case z.ZodIssueCode.invalid_return_type: {
23
- return {
24
- message: `${error.message ?? "Received invalid return type"}: ${error.returnTypeError.errors
25
- .map((e) => validationErrorMap(e, ctx))
26
- .join(",")}.`,
27
- };
28
- }
29
- case z.ZodIssueCode.custom: {
30
- return { message: error.message ?? ctx.defaultError };
31
- }
32
- }
33
-
34
- // Fallback to the default message.
35
- return { message: ctx.defaultError };
36
- };
File without changes