assembly-kit 0.0.3 → 0.0.4

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/CLAUDE.md CHANGED
@@ -194,12 +194,12 @@ export const getAssemblyKit = cache((apiKey: string, workspaceId: string) =>
194
194
 
195
195
  ## Entry Points
196
196
 
197
- | Import path | Key exports |
198
- | ------------------------ | --------------------------------------------------------------------------------------------------------- |
199
- | `assembly-kit` | `createAssemblyKit`, `AssemblyKit`, errors, schemas, token utils |
200
- | `assembly-kit/schemas` | All Zod schemas and inferred types |
201
- | `assembly-kit/client` | `createAssemblyKit`, `AssemblyKit`, `AssemblyKitOptions` |
202
- | `assembly-kit/errors` | All error classes |
203
- | `assembly-kit/token` | `AssemblyToken`, `createToken` |
204
- | `assembly-kit/logger` | `createLogger`, `logger` (requires pino peer dep) |
205
- | `assembly-kit/bridge-ui` | `usePrimaryCta`, `useSecondaryCta`, `useActionsMenu` (requires react + @assembly-js/app-bridge peer deps) |
197
+ | Import path | Key exports |
198
+ | ------------------------ | -------------------------------------------------------------------------------------------------------------------- |
199
+ | `assembly-kit` | `createAssemblyKit`, `AssemblyKit`, errors, schemas, token utils |
200
+ | `assembly-kit/schemas` | All Zod schemas and inferred types |
201
+ | `assembly-kit/client` | `createAssemblyKit`, `AssemblyKit`, `AssemblyKitOptions` |
202
+ | `assembly-kit/errors` | All error classes |
203
+ | `assembly-kit/token` | `AssemblyToken`, `createToken` |
204
+ | `assembly-kit/logger` | `createLogger`, `createPrettyLogger`, `logger` (requires pino peer dep; `createPrettyLogger` also needs pino-pretty) |
205
+ | `assembly-kit/bridge-ui` | `usePrimaryCta`, `useSecondaryCta`, `useActionsMenu` (requires react + @assembly-js/app-bridge peer deps) |
package/README.md CHANGED
@@ -409,7 +409,15 @@ import { logger } from "assembly-kit/logger";
409
409
  logger.info("starting up");
410
410
  ```
411
411
 
412
- The logger emits plain JSON in all environments (no worker-thread transport, so it works in serverless runtimes like Vercel). Pipe output through the `pino-pretty` CLI locally if you want human-readable logs. The default log level respects the `LOG_LEVEL` environment variable.
412
+ The logger emits plain JSON in all environments (no worker-thread transport, so it works in serverless runtimes like Vercel). `Error` objects are serialized with Pino's `err` serializer so message and stack survive — no more `{}` in Vercel logs. The default log level respects the `LOG_LEVEL` environment variable.
413
+
414
+ For human-readable local output, use `createPrettyLogger`. It runs `pino-pretty` as a **synchronous stream** (no worker thread), so it is serverless-safe, but gate it to local runs to keep production plain JSON. Install `pino-pretty` (optional peer dependency) to use it:
415
+
416
+ ```typescript
417
+ import { createLogger, createPrettyLogger } from "assembly-kit/logger";
418
+
419
+ const log = process.env.NODE_ENV === "development" ? await createPrettyLogger() : createLogger();
420
+ ```
413
421
 
414
422
  ### App Bridge (React Hooks)
415
423
 
@@ -498,7 +506,7 @@ useActionsMenu([{ label: "Archive", onClick: () => archive() }], hasItems);
498
506
  | `assembly-kit/errors` | All error classes |
499
507
  | `assembly-kit/schemas` | All Zod schemas and inferred types (no client dependency) |
500
508
  | `assembly-kit/token` | `AssemblyToken`, `createToken`, `ClientTokenPayload`, `InternalUserTokenPayload` |
501
- | `assembly-kit/logger` | `createLogger`, `logger` |
509
+ | `assembly-kit/logger` | `createLogger`, `createPrettyLogger`, `logger` |
502
510
  | `assembly-kit/bridge-ui` | `usePrimaryCta`, `useSecondaryCta`, `useActionsMenu` |
503
511
 
504
512
  ## Development
@@ -21,6 +21,25 @@ import { Logger, Logger as Logger$1, LoggerOptions, LoggerOptions as LoggerOptio
21
21
  declare const createLogger: (options?: LoggerOptions$1) => Logger$1;
22
22
  /** A default global logger instance for convenience. */
23
23
  declare const logger: Logger$1;
24
+ /**
25
+ * Create a logger with human-readable colorized output for local development.
26
+ *
27
+ * Uses pino-pretty as a **synchronous stream** (`sync: true`) rather than the
28
+ * default worker-thread transport, so it is safe on serverless runtimes that
29
+ * forbid worker threads. Requires `pino-pretty` to be installed (optional peer
30
+ * dependency) — it is imported dynamically so plain-JSON users never bundle it.
31
+ *
32
+ * Gate it to local runs so production stays plain JSON:
33
+ *
34
+ * @example
35
+ * ```ts
36
+ * const log =
37
+ * process.env.NODE_ENV === "development"
38
+ * ? await createPrettyLogger()
39
+ * : createLogger();
40
+ * ```
41
+ */
42
+ declare const createPrettyLogger: (options?: LoggerOptions$1) => Promise<Logger$1>;
24
43
  //#endregion
25
- export { type Logger, type LoggerOptions, createLogger, logger };
44
+ export { type Logger, type LoggerOptions, createLogger, createPrettyLogger, logger };
26
45
  //# sourceMappingURL=index.d.mts.map
@@ -1,7 +1,13 @@
1
1
  import { AsyncLocalStorage } from "node:async_hooks";
2
2
  import pino from "pino";
3
3
  //#region src/logger/index.ts
4
- const DEFAULT_OPTIONS = { level: process.env.LOG_LEVEL ?? "info" };
4
+ const DEFAULT_OPTIONS = {
5
+ level: process.env.LOG_LEVEL ?? "info",
6
+ serializers: {
7
+ err: pino.stdSerializers.err,
8
+ error: pino.stdSerializers.err
9
+ }
10
+ };
5
11
  const buildLogger = (options = {}) => pino({
6
12
  ...DEFAULT_OPTIONS,
7
13
  ...options
@@ -33,7 +39,36 @@ const createLogger = (options = {}) => {
33
39
  };
34
40
  /** A default global logger instance for convenience. */
35
41
  const logger = buildLogger();
42
+ /**
43
+ * Create a logger with human-readable colorized output for local development.
44
+ *
45
+ * Uses pino-pretty as a **synchronous stream** (`sync: true`) rather than the
46
+ * default worker-thread transport, so it is safe on serverless runtimes that
47
+ * forbid worker threads. Requires `pino-pretty` to be installed (optional peer
48
+ * dependency) — it is imported dynamically so plain-JSON users never bundle it.
49
+ *
50
+ * Gate it to local runs so production stays plain JSON:
51
+ *
52
+ * @example
53
+ * ```ts
54
+ * const log =
55
+ * process.env.NODE_ENV === "development"
56
+ * ? await createPrettyLogger()
57
+ * : createLogger();
58
+ * ```
59
+ */
60
+ const createPrettyLogger = async (options = {}) => {
61
+ const { default: pretty } = await import("pino-pretty");
62
+ const stream = pretty({
63
+ colorize: true,
64
+ sync: true
65
+ });
66
+ return pino({
67
+ ...DEFAULT_OPTIONS,
68
+ ...options
69
+ }, stream);
70
+ };
36
71
  //#endregion
37
- export { createLogger, logger };
72
+ export { createLogger, createPrettyLogger, logger };
38
73
 
39
74
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../../src/logger/index.ts"],"sourcesContent":["import { AsyncLocalStorage } from \"node:async_hooks\";\n\nimport pino from \"pino\";\nimport type { Logger, LoggerOptions } from \"pino\";\n\nexport type { Logger, LoggerOptions } from \"pino\";\n\n// pino-pretty uses a worker-thread transport that breaks in serverless\n// runtimes (Vercel, Cloudflare). Emit plain JSON everywhere; pipe through\n// the pino-pretty CLI locally if you want pretty output.\nconst DEFAULT_OPTIONS: LoggerOptions = {\n level: process.env.LOG_LEVEL ?? \"info\",\n};\n\nconst buildLogger = (options: LoggerOptions = {}): Logger =>\n pino({ ...DEFAULT_OPTIONS, ...options });\n\nconst store: AsyncLocalStorage<Logger> = new AsyncLocalStorage<Logger>();\n\n/**\n * Get or create a request-scoped logger via `AsyncLocalStorage`.\n * Returns the existing instance if one exists. Pass options to customize\n * on first call; subsequent calls in the same async context return the\n * same instance.\n *\n * @example\n * ```ts\n * const logger = createLogger({ level: \"debug\" });\n * logger.info(\"hello\");\n * logger.warn(\"careful\");\n * logger.error(\"oops\");\n *\n * // Later in the same async context:\n * const same = createLogger(); // returns the same instance\n * ```\n */\nexport const createLogger = (options: LoggerOptions = {}): Logger => {\n const existing = store.getStore();\n if (existing) {\n return existing;\n }\n const instance = buildLogger(options);\n store.enterWith(instance);\n return instance;\n};\n\n/** A default global logger instance for convenience. */\nexport const logger: Logger = buildLogger();\n"],"mappings":";;;AAUA,MAAM,kBAAiC,EACrC,OAAO,QAAQ,IAAI,aAAa,QACjC;AAED,MAAM,eAAe,UAAyB,EAAE,KAC9C,KAAK;CAAE,GAAG;CAAiB,GAAG;CAAS,CAAC;AAE1C,MAAM,QAAmC,IAAI,mBAA2B;;;;;;;;;;;;;;;;;;AAmBxE,MAAa,gBAAgB,UAAyB,EAAE,KAAa;CACnE,MAAM,WAAW,MAAM,UAAU;AACjC,KAAI,SACF,QAAO;CAET,MAAM,WAAW,YAAY,QAAQ;AACrC,OAAM,UAAU,SAAS;AACzB,QAAO;;;AAIT,MAAa,SAAiB,aAAa"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../../src/logger/index.ts"],"sourcesContent":["import { AsyncLocalStorage } from \"node:async_hooks\";\n\nimport pino from \"pino\";\nimport type { Logger, LoggerOptions } from \"pino\";\n\nexport type { Logger, LoggerOptions } from \"pino\";\n\n// pino-pretty's default transport uses a worker thread that breaks in\n// serverless runtimes (Vercel, Cloudflare). Emit plain JSON everywhere.\n// The `err`/`error` serializers ensure Error objects log message + stack\n// instead of `{}` — the usual serverless footgun. For pretty local output\n// use `createPrettyLogger` below (sync stream, no worker thread).\nconst DEFAULT_OPTIONS: LoggerOptions = {\n level: process.env.LOG_LEVEL ?? \"info\",\n serializers: {\n err: pino.stdSerializers.err,\n error: pino.stdSerializers.err,\n },\n};\n\nconst buildLogger = (options: LoggerOptions = {}): Logger =>\n pino({ ...DEFAULT_OPTIONS, ...options });\n\nconst store: AsyncLocalStorage<Logger> = new AsyncLocalStorage<Logger>();\n\n/**\n * Get or create a request-scoped logger via `AsyncLocalStorage`.\n * Returns the existing instance if one exists. Pass options to customize\n * on first call; subsequent calls in the same async context return the\n * same instance.\n *\n * @example\n * ```ts\n * const logger = createLogger({ level: \"debug\" });\n * logger.info(\"hello\");\n * logger.warn(\"careful\");\n * logger.error(\"oops\");\n *\n * // Later in the same async context:\n * const same = createLogger(); // returns the same instance\n * ```\n */\nexport const createLogger = (options: LoggerOptions = {}): Logger => {\n const existing = store.getStore();\n if (existing) {\n return existing;\n }\n const instance = buildLogger(options);\n store.enterWith(instance);\n return instance;\n};\n\n/** A default global logger instance for convenience. */\nexport const logger: Logger = buildLogger();\n\n/**\n * Create a logger with human-readable colorized output for local development.\n *\n * Uses pino-pretty as a **synchronous stream** (`sync: true`) rather than the\n * default worker-thread transport, so it is safe on serverless runtimes that\n * forbid worker threads. Requires `pino-pretty` to be installed (optional peer\n * dependency) — it is imported dynamically so plain-JSON users never bundle it.\n *\n * Gate it to local runs so production stays plain JSON:\n *\n * @example\n * ```ts\n * const log =\n * process.env.NODE_ENV === \"development\"\n * ? await createPrettyLogger()\n * : createLogger();\n * ```\n */\nexport const createPrettyLogger = async (options: LoggerOptions = {}): Promise<Logger> => {\n const { default: pretty } = await import(\"pino-pretty\");\n const stream = pretty({ colorize: true, sync: true });\n return pino({ ...DEFAULT_OPTIONS, ...options }, stream);\n};\n"],"mappings":";;;AAYA,MAAM,kBAAiC;CACrC,OAAO,QAAQ,IAAI,aAAa;CAChC,aAAa;EACX,KAAK,KAAK,eAAe;EACzB,OAAO,KAAK,eAAe;EAC5B;CACF;AAED,MAAM,eAAe,UAAyB,EAAE,KAC9C,KAAK;CAAE,GAAG;CAAiB,GAAG;CAAS,CAAC;AAE1C,MAAM,QAAmC,IAAI,mBAA2B;;;;;;;;;;;;;;;;;;AAmBxE,MAAa,gBAAgB,UAAyB,EAAE,KAAa;CACnE,MAAM,WAAW,MAAM,UAAU;AACjC,KAAI,SACF,QAAO;CAET,MAAM,WAAW,YAAY,QAAQ;AACrC,OAAM,UAAU,SAAS;AACzB,QAAO;;;AAIT,MAAa,SAAiB,aAAa;;;;;;;;;;;;;;;;;;;AAoB3C,MAAa,qBAAqB,OAAO,UAAyB,EAAE,KAAsB;CACxF,MAAM,EAAE,SAAS,WAAW,MAAM,OAAO;CACzC,MAAM,SAAS,OAAO;EAAE,UAAU;EAAM,MAAM;EAAM,CAAC;AACrD,QAAO,KAAK;EAAE,GAAG;EAAiB,GAAG;EAAS,EAAE,OAAO"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "assembly-kit",
3
- "version": "0.0.3",
3
+ "version": "0.0.4",
4
4
  "description": "TypeScript SDK for the Assembly platform",
5
5
  "homepage": "https://github.com/madebyoutside/assembly-kit#readme",
6
6
  "bugs": {
@@ -49,6 +49,7 @@
49
49
  "@typescript/native-preview": "7.0.0-dev.20260505.1",
50
50
  "bumpp": "^11.0.1",
51
51
  "pino": "^10.3.1",
52
+ "pino-pretty": "^13.1.2",
52
53
  "react": "^19.2.5",
53
54
  "typescript": "^6.0.3",
54
55
  "vite-plus": "^0.1.20",
@@ -57,6 +58,7 @@
57
58
  "peerDependencies": {
58
59
  "@assembly-js/app-bridge": "^1.1.1",
59
60
  "pino": ">=9",
61
+ "pino-pretty": ">=11",
60
62
  "react": ">=18",
61
63
  "typescript": ">=5",
62
64
  "zod": ">=4"
@@ -68,6 +70,9 @@
68
70
  "pino": {
69
71
  "optional": true
70
72
  },
73
+ "pino-pretty": {
74
+ "optional": true
75
+ },
71
76
  "react": {
72
77
  "optional": true
73
78
  },