@adrianhall/cloudflare-toolkit 0.0.1 → 1.0.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.
package/README.md CHANGED
@@ -54,6 +54,12 @@ use every export in this package:
54
54
  npx skills add adrianhall/cloudflare-toolkit
55
55
  ```
56
56
 
57
+ ## Contributing
58
+
59
+ See [`CONTRIBUTING.md`](./CONTRIBUTING.md) for the PR/changeset process,
60
+ [`RELEASING.md`](./RELEASING.md) for how releases are cut, and [`AGENTS.md`](./AGENTS.md) for
61
+ engineering conventions.
62
+
57
63
  ## License
58
64
 
59
65
  [MIT](./LICENSE)
@@ -169,7 +169,7 @@ async function run(argv, deps) {
169
169
  const commanderArgv = separatorIndex === -1 ? argv : argv.slice(0, separatorIndex);
170
170
  const extraArgs = separatorIndex === -1 ? [] : argv.slice(separatorIndex + 1);
171
171
  const program = new Command();
172
- program.name("generate-wrangler-types").description("Regenerate worker-configuration.d.ts only when wrangler.jsonc has changed").version("0.0.1", "--version", "Print version and exit").option("-c, --config <file>", "Wrangler config file to watch", "wrangler.jsonc").option("-d, --dir <dir>", "Base directory for resolving relative paths", ".").option("-f, --force", "Force regeneration even if types are already fresh").option("-o, --output <file>", "Output .d.ts file path (relative to --dir)", "worker-configuration.d.ts").option("-q, --quiet", "Quiet logging (min level: warn)").option("-v, --verbose", "Verbose logging (min level: debug)").allowUnknownOption(false);
172
+ program.name("generate-wrangler-types").description("Regenerate worker-configuration.d.ts only when wrangler.jsonc has changed").version("1.0.0", "--version", "Print version and exit").option("-c, --config <file>", "Wrangler config file to watch", "wrangler.jsonc").option("-d, --dir <dir>", "Base directory for resolving relative paths", ".").option("-f, --force", "Force regeneration even if types are already fresh").option("-o, --output <file>", "Output .d.ts file path (relative to --dir)", "worker-configuration.d.ts").option("-q, --quiet", "Quiet logging (min level: warn)").option("-v, --verbose", "Verbose logging (min level: debug)").allowUnknownOption(false);
173
173
  program.exitOverride();
174
174
  try {
175
175
  program.parse(commanderArgv);
@@ -1,2 +1,2 @@
1
- import { a as forbidden, c as methodNotAllowed, d as serviceUnavailable, f as unauthorized, i as contentTooLarge, l as notFound, m as unsupportedMediaType, n as InvalidShapeError, o as gone, p as unprocessableContent, r as badRequest, s as internalServerError, t as NullError, u as notImplemented } from "../index-CUICemFw.js";
2
- export { InvalidShapeError, NullError, badRequest, contentTooLarge, forbidden, gone, internalServerError, methodNotAllowed, notFound, notImplemented, serviceUnavailable, unauthorized, unprocessableContent, unsupportedMediaType };
1
+ import { a as contentTooLarge, c as internalServerError, d as notImplemented, f as serviceUnavailable, h as unsupportedMediaType, i as badRequest, l as methodNotAllowed, m as unprocessableContent, n as InvalidShapeError, o as forbidden, p as unauthorized, r as HttpErrorInput, s as gone, t as NullError, u as notFound } from "../index-DSHomPUi.js";
2
+ export { type HttpErrorInput, InvalidShapeError, NullError, badRequest, contentTooLarge, forbidden, gone, internalServerError, methodNotAllowed, notFound, notImplemented, serviceUnavailable, unauthorized, unprocessableContent, unsupportedMediaType };
@@ -343,5 +343,5 @@ declare function cloudflareAccess(options?: CloudflareAccessOptions): Middleware
343
343
  Variables: AuthVariables;
344
344
  }>;
345
345
  //#endregion
346
- export { type AuthVariables, type CloudflareAccessOptions, type CloudflareLoggerOptions, type CloudflareToolkitVariables, type LoggerVariables, type NotFoundHandlerOptions, type ProblemDetailsErrorHandlerOptions, cloudflareAccess, cloudflareLogger, notFoundHandler, problemDetailsErrorHandler };
346
+ export { type AuthVariables, type CloudflareAccessOptions, type CloudflareLoggerOptions, type CloudflareToolkitVariables, type LoggerVariables, type NotFoundHandlerOptions, type PathPolicy, type ProblemDetailsErrorHandlerOptions, cloudflareAccess, cloudflareLogger, notFoundHandler, problemDetailsErrorHandler };
347
347
  //# sourceMappingURL=index.d.ts.map
@@ -18,16 +18,25 @@ import { t as ProblemDetailsError } from "./error-CLYcAvBM.js";
18
18
  declare function problemDetails<T extends Record<string, unknown>>(input: ProblemDetailsInput<T>): ProblemDetailsError;
19
19
  //#endregion
20
20
  //#region src/lib/problem-details/registry.d.ts
21
+ /** The base RFC 9457 definition (type, status, title) registered for a problem type key. */
21
22
  interface ProblemTypeDefinition {
23
+ /** A URI identifying the problem type, per RFC 9457. */
22
24
  readonly type: string;
25
+ /** The HTTP status code for this problem type. */
23
26
  readonly status: number;
27
+ /** A short, human-readable summary of the problem type. */
24
28
  readonly title: string;
25
29
  }
30
+ /** Per-instance overrides accepted by {@link ProblemTypeRegistry}'s `create()` method. */
26
31
  interface CreateOptions<T extends Record<string, unknown> = Record<string, unknown>> {
32
+ /** A human-readable explanation specific to this occurrence of the problem. */
27
33
  detail?: string;
34
+ /** A URI identifying this specific occurrence of the problem. */
28
35
  instance?: string;
36
+ /** Additional problem-specific extension members. */
29
37
  extensions?: T;
30
38
  }
39
+ /** A registry of pre-defined problem types, returned by {@link createProblemTypeRegistry}. */
31
40
  interface ProblemTypeRegistry<K extends string> {
32
41
  /** Create a {@link ProblemDetailsError} from a registered problem type key. */
33
42
  create: <T extends Record<string, unknown>>(key: K, options?: CreateOptions<T>) => ProblemDetailsError;
@@ -77,5 +86,5 @@ declare function statusToPhrase(status: number): string | undefined;
77
86
  */
78
87
  declare function statusToSlug(status: number): string | undefined;
79
88
  //#endregion
80
- export { problemDetails as i, statusToSlug as n, createProblemTypeRegistry as r, statusToPhrase as t };
81
- //# sourceMappingURL=index-DRIhR-Xn.d.ts.map
89
+ export { ProblemTypeRegistry as a, ProblemTypeDefinition as i, statusToSlug as n, createProblemTypeRegistry as o, CreateOptions as r, problemDetails as s, statusToPhrase as t };
90
+ //# sourceMappingURL=index-D5bfk4cR.d.ts.map
@@ -125,5 +125,5 @@ declare class NullError extends ProblemDetailsError {
125
125
  constructor(message: string);
126
126
  }
127
127
  //#endregion
128
- export { forbidden as a, methodNotAllowed as c, serviceUnavailable as d, unauthorized as f, contentTooLarge as i, notFound as l, unsupportedMediaType as m, InvalidShapeError as n, gone as o, unprocessableContent as p, badRequest as r, internalServerError as s, NullError as t, notImplemented as u };
129
- //# sourceMappingURL=index-CUICemFw.d.ts.map
128
+ export { contentTooLarge as a, internalServerError as c, notImplemented as d, serviceUnavailable as f, unsupportedMediaType as h, badRequest as i, methodNotAllowed as l, unprocessableContent as m, InvalidShapeError as n, forbidden as o, unauthorized as p, HttpErrorInput as r, gone as s, NullError as t, notFound as u };
129
+ //# sourceMappingURL=index-DSHomPUi.d.ts.map
package/dist/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import { n as throwIfNull, r as valueOrDefault, t as sqlCount } from "./index-434HN8jN.js";
2
2
  import { n as ProblemDetailsInput, t as ProblemDetails } from "./types-Cx6NNILW.js";
3
3
  import { t as ProblemDetailsError } from "./error-CLYcAvBM.js";
4
- import { a as forbidden, c as methodNotAllowed, d as serviceUnavailable, f as unauthorized, l as notFound, m as unsupportedMediaType, n as InvalidShapeError, o as gone, p as unprocessableContent, r as badRequest, s as internalServerError, t as NullError, u as notImplemented } from "./index-CUICemFw.js";
5
- import { i as problemDetails, n as statusToSlug, r as createProblemTypeRegistry, t as statusToPhrase } from "./index-DRIhR-Xn.js";
4
+ import { c as internalServerError, d as notImplemented, f as serviceUnavailable, h as unsupportedMediaType, i as badRequest, l as methodNotAllowed, m as unprocessableContent, n as InvalidShapeError, o as forbidden, p as unauthorized, s as gone, t as NullError, u as notFound } from "./index-DSHomPUi.js";
5
+ import { n as statusToSlug, o as createProblemTypeRegistry, s as problemDetails, t as statusToPhrase } from "./index-D5bfk4cR.js";
6
6
  import { a as Environment, c as LogRecord, d as Runtime, f as StructuredTransportOptions, i as CreateLoggerOptions, l as Logger, m as TransportErrorHandler, n as CaptureTransport, o as LogContext, p as Transport, r as ConsoleTransportOptions, s as LogLevel, t as BrowserTransportOptions, u as ResolvedLoggerConfig } from "./types-DCSMb1cp.js";
7
7
  import { a as createCaptureTransport, c as resolveLoggerConfig, i as combineTransports, l as createLogger, n as createSilentTransport, o as createBrowserTransport, r as createConsoleTransport, s as serializeError, t as createStructuredTransport } from "./index-Byl-ZrCy.js";
8
8
  export { type BrowserTransportOptions, type CaptureTransport, type ConsoleTransportOptions, type CreateLoggerOptions, type Environment, InvalidShapeError, type LogContext, type LogLevel, type LogRecord, type Logger, NullError, type ProblemDetails, ProblemDetailsError, type ProblemDetailsInput, type ResolvedLoggerConfig, type Runtime, type StructuredTransportOptions, type Transport, type TransportErrorHandler, badRequest, combineTransports, createBrowserTransport, createCaptureTransport, createConsoleTransport, createLogger, createProblemTypeRegistry, createSilentTransport, createStructuredTransport, forbidden, gone, internalServerError, methodNotAllowed, notFound, notImplemented, problemDetails, resolveLoggerConfig, serializeError, serviceUnavailable, sqlCount, statusToPhrase, statusToSlug, throwIfNull, unauthorized, unprocessableContent, unsupportedMediaType, valueOrDefault };
@@ -1,4 +1,4 @@
1
1
  import { n as ProblemDetailsInput, t as ProblemDetails } from "../types-Cx6NNILW.js";
2
2
  import { t as ProblemDetailsError } from "../error-CLYcAvBM.js";
3
- import { i as problemDetails, n as statusToSlug, r as createProblemTypeRegistry, t as statusToPhrase } from "../index-DRIhR-Xn.js";
4
- export { type ProblemDetails, ProblemDetailsError, type ProblemDetailsInput, createProblemTypeRegistry, problemDetails, statusToPhrase, statusToSlug };
3
+ import { a as ProblemTypeRegistry, i as ProblemTypeDefinition, n as statusToSlug, o as createProblemTypeRegistry, r as CreateOptions, s as problemDetails, t as statusToPhrase } from "../index-D5bfk4cR.js";
4
+ export { type CreateOptions, type ProblemDetails, ProblemDetailsError, type ProblemDetailsInput, type ProblemTypeDefinition, type ProblemTypeRegistry, createProblemTypeRegistry, problemDetails, statusToPhrase, statusToSlug };
@@ -1 +1 @@
1
- {"version":3,"file":"problem-details-CuRsLy3Q.js","names":[],"sources":["../src/lib/problem-details/registry.ts"],"sourcesContent":["/**\n * @file A registry for pre-defined, type-safe RFC 9457 problem types.\n */\nimport { ProblemDetailsError } from \"./error.js\";\n\ninterface ProblemTypeDefinition {\n readonly type: string;\n readonly status: number;\n readonly title: string;\n}\n\ninterface CreateOptions<T extends Record<string, unknown> = Record<string, unknown>> {\n detail?: string;\n instance?: string;\n extensions?: T;\n}\n\ninterface ProblemTypeRegistry<K extends string> {\n /** Create a {@link ProblemDetailsError} from a registered problem type key. */\n create: <T extends Record<string, unknown>>(\n key: K,\n options?: CreateOptions<T>\n ) => ProblemDetailsError;\n /**\n * Get the base definition (type, status, title) for a registered key.\n * Returns a defensive shallow copy on every call, so mutating the result never affects the\n * registry's internal definitions.\n */\n get: (key: K) => Readonly<ProblemTypeDefinition>;\n /** List all registered problem type keys. */\n types: () => K[];\n}\n\n/**\n * Create a registry of pre-defined problem types.\n * Provides type-safe error creation from registered definitions.\n *\n * @param definitions - A map of problem type keys to their base definition (type, status, title).\n * @returns A {@link ProblemTypeRegistry} for the given definitions.\n * @example\n * ```ts\n * const problems = createProblemTypeRegistry({\n * ORDER_CONFLICT: {\n * type: \"https://api.example.com/problems/order-conflict\",\n * status: 409,\n * title: \"Order Conflict\",\n * },\n * });\n * throw problems.create(\"ORDER_CONFLICT\", { detail: \"Already exists\" });\n * ```\n */\nexport function createProblemTypeRegistry<K extends string>(\n definitions: Record<K, ProblemTypeDefinition>\n): ProblemTypeRegistry<K> {\n return {\n create: (key, options) => new ProblemDetailsError({ ...definitions[key], ...options }),\n get: (key) => ({ ...definitions[key] }),\n types: () => Object.keys(definitions) as K[]\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAmDA,SAAgB,0BACd,aACwB;CACxB,OAAO;EACL,SAAS,KAAK,YAAY,IAAI,oBAAoB;GAAE,GAAG,YAAY;GAAM,GAAG;EAAQ,CAAC;EACrF,MAAM,SAAS,EAAE,GAAG,YAAY,KAAK;EACrC,aAAa,OAAO,KAAK,WAAW;CACtC;AACF"}
1
+ {"version":3,"file":"problem-details-CuRsLy3Q.js","names":[],"sources":["../src/lib/problem-details/registry.ts"],"sourcesContent":["/**\n * @file A registry for pre-defined, type-safe RFC 9457 problem types.\n */\nimport { ProblemDetailsError } from \"./error.js\";\n\n/** The base RFC 9457 definition (type, status, title) registered for a problem type key. */\nexport interface ProblemTypeDefinition {\n /** A URI identifying the problem type, per RFC 9457. */\n readonly type: string;\n /** The HTTP status code for this problem type. */\n readonly status: number;\n /** A short, human-readable summary of the problem type. */\n readonly title: string;\n}\n\n/** Per-instance overrides accepted by {@link ProblemTypeRegistry}'s `create()` method. */\nexport interface CreateOptions<T extends Record<string, unknown> = Record<string, unknown>> {\n /** A human-readable explanation specific to this occurrence of the problem. */\n detail?: string;\n /** A URI identifying this specific occurrence of the problem. */\n instance?: string;\n /** Additional problem-specific extension members. */\n extensions?: T;\n}\n\n/** A registry of pre-defined problem types, returned by {@link createProblemTypeRegistry}. */\nexport interface ProblemTypeRegistry<K extends string> {\n /** Create a {@link ProblemDetailsError} from a registered problem type key. */\n create: <T extends Record<string, unknown>>(\n key: K,\n options?: CreateOptions<T>\n ) => ProblemDetailsError;\n /**\n * Get the base definition (type, status, title) for a registered key.\n * Returns a defensive shallow copy on every call, so mutating the result never affects the\n * registry's internal definitions.\n */\n get: (key: K) => Readonly<ProblemTypeDefinition>;\n /** List all registered problem type keys. */\n types: () => K[];\n}\n\n/**\n * Create a registry of pre-defined problem types.\n * Provides type-safe error creation from registered definitions.\n *\n * @param definitions - A map of problem type keys to their base definition (type, status, title).\n * @returns A {@link ProblemTypeRegistry} for the given definitions.\n * @example\n * ```ts\n * const problems = createProblemTypeRegistry({\n * ORDER_CONFLICT: {\n * type: \"https://api.example.com/problems/order-conflict\",\n * status: 409,\n * title: \"Order Conflict\",\n * },\n * });\n * throw problems.create(\"ORDER_CONFLICT\", { detail: \"Already exists\" });\n * ```\n */\nexport function createProblemTypeRegistry<K extends string>(\n definitions: Record<K, ProblemTypeDefinition>\n): ProblemTypeRegistry<K> {\n return {\n create: (key, options) => new ProblemDetailsError({ ...definitions[key], ...options }),\n get: (key) => ({ ...definitions[key] }),\n types: () => Object.keys(definitions) as K[]\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AA4DA,SAAgB,0BACd,aACwB;CACxB,OAAO;EACL,SAAS,KAAK,YAAY,IAAI,oBAAoB;GAAE,GAAG,YAAY;GAAM,GAAG;EAAQ,CAAC;EACrF,MAAM,SAAS,EAAE,GAAG,YAAY,KAAK;EACrC,aAAa,OAAO,KAAK,WAAW;CACtC;AACF"}
@@ -75,5 +75,5 @@ interface CloudflareAccessPluginOptions {
75
75
  */
76
76
  declare function cloudflareAccessPlugin(options?: CloudflareAccessPluginOptions): Plugin;
77
77
  //#endregion
78
- export { type CloudflareAccessPluginOptions, cloudflareAccessPlugin };
78
+ export { type CloudflareAccessPluginOptions, type DevLoginUser, type PathPolicy, cloudflareAccessPlugin };
79
79
  //# sourceMappingURL=index.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adrianhall/cloudflare-toolkit",
3
- "version": "0.0.1",
3
+ "version": "1.0.0",
4
4
  "description": "A toolkit of utilities and skills for developing Workers on the Cloudflare Dev Platform",
5
5
  "keywords": [
6
6
  "cloudflare",
@@ -93,6 +93,7 @@
93
93
  "jose": "^6.2.3"
94
94
  },
95
95
  "devDependencies": {
96
+ "@changesets/cli": "^2.31.0",
96
97
  "@cloudflare/vitest-pool-workers": "^0.18.3",
97
98
  "@cloudflare/workers-types": "5.20260708.1",
98
99
  "@types/cross-spawn": "^6.0.6",
@@ -114,6 +115,7 @@
114
115
  },
115
116
  "scripts": {
116
117
  "build": "tsdown",
118
+ "changeset": "changeset",
117
119
  "check": "run-s check:types check:lint check:format check:pack",
118
120
  "check:format": "prettier --check .",
119
121
  "check:lint": "eslint .",
@@ -125,8 +127,10 @@
125
127
  "prepare": "husky",
126
128
  "pretest": "npm run build",
127
129
  "pretest:coverage": "npm run build",
130
+ "release": "npm run build && changeset publish",
128
131
  "test": "vitest run",
129
- "test:coverage": "vitest run --coverage"
132
+ "test:coverage": "vitest run --coverage",
133
+ "version-packages": "changeset version && prettier --write ."
130
134
  },
131
135
  "allowScripts": {
132
136
  "esbuild@0.28.1": true,