@3lineas/groovepack 0.1.4 → 1.2.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 (42) hide show
  1. package/README.md +261 -138
  2. package/dist/action-response.type-XlzII9Lr.d.ts +11 -0
  3. package/dist/api-action/index.d.ts +44 -0
  4. package/dist/api-action/index.js +105 -0
  5. package/dist/api-action/index.js.map +1 -0
  6. package/dist/api-client/index.d.ts +52 -0
  7. package/dist/api-client/index.js +142 -0
  8. package/dist/api-client/index.js.map +1 -0
  9. package/dist/api-toast/index.d.ts +80 -0
  10. package/dist/api-toast/index.js +104 -0
  11. package/dist/api-toast/index.js.map +1 -0
  12. package/dist/batch-capable-db.type-Cyybxkjc.d.ts +8 -0
  13. package/dist/chunk-3FQ5C44Y.js +119 -0
  14. package/dist/chunk-3FQ5C44Y.js.map +1 -0
  15. package/dist/groovepack-locale.type-CaXo9vLj.d.ts +3 -0
  16. package/dist/i18n/index.d.ts +82 -0
  17. package/dist/i18n/index.js +17 -0
  18. package/dist/i18n/index.js.map +1 -0
  19. package/dist/logger/index.d.ts +19 -0
  20. package/dist/logger/index.js +89 -0
  21. package/dist/logger/index.js.map +1 -0
  22. package/dist/pipeline/pipeline.d.ts +41 -0
  23. package/dist/pipeline/pipeline.js +64 -0
  24. package/dist/pipeline/pipeline.js.map +1 -0
  25. package/dist/pipeline/with-d1-transaction.d.ts +16 -0
  26. package/dist/pipeline/with-d1-transaction.js +17 -0
  27. package/dist/pipeline/with-d1-transaction.js.map +1 -0
  28. package/package.json +55 -16
  29. package/dist/index.js +0 -468
  30. package/dist/index.js.map +0 -1
  31. package/registry/common/api-client/files/README.md.template +0 -64
  32. package/registry/common/api-client/files/index.ts.template +0 -296
  33. package/registry/common/logger/files/README.md.template +0 -55
  34. package/registry/common/logger/files/index.ts.template +0 -194
  35. package/registry/react/api-action/files/README.md.template +0 -61
  36. package/registry/react/api-action/files/index.ts.template +0 -291
  37. package/registry/react/api-toast/files/README.md.template +0 -51
  38. package/registry/react/api-toast/files/index.ts.template +0 -169
  39. package/registry/server/pipeline/files/README.md.template +0 -205
  40. package/registry/server/pipeline/files/pipeline.ts.template +0 -134
  41. package/registry/server/pipeline/files/types.ts.template +0 -35
  42. package/registry/server/pipeline/files/with-d1-transaction.ts.template +0 -50
@@ -0,0 +1,17 @@
1
+ import {
2
+ GROOVEPACK_MESSAGES,
3
+ getGroovepackLocale,
4
+ normalizeSupportedLocale,
5
+ readEnvLocale,
6
+ resolveLocaleMessages,
7
+ setGroovepackLocale
8
+ } from "../chunk-3FQ5C44Y.js";
9
+ export {
10
+ GROOVEPACK_MESSAGES,
11
+ getGroovepackLocale,
12
+ normalizeSupportedLocale,
13
+ readEnvLocale,
14
+ resolveLocaleMessages,
15
+ setGroovepackLocale
16
+ };
17
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,19 @@
1
+ type LogContext = Record<string, unknown>;
2
+
3
+ type LogLevel = "INFO" | "WARN" | "ERROR" | "DEBUG";
4
+
5
+ /**
6
+ * Universal structured logger.
7
+ * Outputs ANSI-colored lines in development/test and structured JSON in production.
8
+ */
9
+ declare class Logger {
10
+ private write;
11
+ private emitToConsole;
12
+ info(message: string, context?: LogContext): void;
13
+ warn(message: string, context?: LogContext): void;
14
+ error(message: string, context?: LogContext): void;
15
+ debug(message: string, context?: LogContext): void;
16
+ }
17
+ declare const logger: Logger;
18
+
19
+ export { type LogContext, type LogLevel, logger };
@@ -0,0 +1,89 @@
1
+ // src/logger/check-is-development.ts
2
+ function checkIsDevelopment() {
3
+ const globalRecord = globalThis;
4
+ const processValue = globalRecord["process"];
5
+ if (typeof processValue === "object" && processValue !== null) {
6
+ const envValue = processValue["env"];
7
+ if (typeof envValue === "object" && envValue !== null) {
8
+ const nodeEnv = envValue["NODE_ENV"];
9
+ if (nodeEnv === "development" || nodeEnv === "test") {
10
+ return true;
11
+ }
12
+ if (nodeEnv === "production") {
13
+ return false;
14
+ }
15
+ }
16
+ }
17
+ try {
18
+ return Boolean(import.meta.env?.DEV);
19
+ } catch {
20
+ return false;
21
+ }
22
+ }
23
+
24
+ // src/logger/format-dev-log.ts
25
+ var LEVEL_COLORS = {
26
+ INFO: "\x1B[32m",
27
+ WARN: "\x1B[33m",
28
+ ERROR: "\x1B[31m",
29
+ DEBUG: "\x1B[36m"
30
+ };
31
+ var RESET_COLOR = "\x1B[0m";
32
+ var DIM_COLOR = "\x1B[2m";
33
+ function formatDevLog(level, message, context, timestamp) {
34
+ const color = LEVEL_COLORS[level];
35
+ const resolvedTimestamp = timestamp ?? (/* @__PURE__ */ new Date()).toISOString();
36
+ const baseLine = `${DIM_COLOR}${resolvedTimestamp}${RESET_COLOR} ${color}[${level}]${RESET_COLOR} ${message}`;
37
+ if (!context || Object.keys(context).length === 0) {
38
+ return baseLine;
39
+ }
40
+ return `${baseLine} ${DIM_COLOR}${JSON.stringify(context)}${RESET_COLOR}`;
41
+ }
42
+
43
+ // src/logger/index.ts
44
+ var Logger = class {
45
+ write(level, message, context) {
46
+ const timestamp = (/* @__PURE__ */ new Date()).toISOString();
47
+ const isDev = checkIsDevelopment();
48
+ if (isDev) {
49
+ const formatted = formatDevLog(level, message, context, timestamp);
50
+ this.emitToConsole(level, formatted);
51
+ return;
52
+ }
53
+ const payload = JSON.stringify({
54
+ timestamp,
55
+ level,
56
+ message,
57
+ ...context ? { context } : {}
58
+ });
59
+ this.emitToConsole(level, payload);
60
+ }
61
+ emitToConsole(level, line) {
62
+ if (level === "ERROR") {
63
+ console.error(line);
64
+ return;
65
+ }
66
+ if (level === "WARN") {
67
+ console.warn(line);
68
+ return;
69
+ }
70
+ console.log(line);
71
+ }
72
+ info(message, context) {
73
+ this.write("INFO", message, context);
74
+ }
75
+ warn(message, context) {
76
+ this.write("WARN", message, context);
77
+ }
78
+ error(message, context) {
79
+ this.write("ERROR", message, context);
80
+ }
81
+ debug(message, context) {
82
+ this.write("DEBUG", message, context);
83
+ }
84
+ };
85
+ var logger = new Logger();
86
+ export {
87
+ logger
88
+ };
89
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/logger/check-is-development.ts","../../src/logger/format-dev-log.ts","../../src/logger/index.ts"],"sourcesContent":["/**\n * Safely checks whether the current Vinext / Cloudflare Workers runtime is in\n * development or test mode using static `import.meta.env.DEV` access compatible\n * with Vite 8's `ModuleRunner`.\n */\nexport function checkIsDevelopment(): boolean {\n const globalRecord = globalThis as Record<string, unknown>;\n const processValue = globalRecord[\"process\"];\n if (typeof processValue === \"object\" && processValue !== null) {\n const envValue = (processValue as Record<string, unknown>)[\"env\"];\n if (typeof envValue === \"object\" && envValue !== null) {\n const nodeEnv = (envValue as Record<string, unknown>)[\"NODE_ENV\"];\n if (nodeEnv === \"development\" || nodeEnv === \"test\") {\n return true;\n }\n if (nodeEnv === \"production\") {\n return false;\n }\n }\n }\n\n try {\n return Boolean(import.meta.env?.DEV);\n } catch {\n return false;\n }\n}\n","import type { LogContext } from \"@/types/logger/log-context.type\";\nimport type { LogLevel } from \"@/types/logger/log-level.type\";\n\nconst LEVEL_COLORS: Record<LogLevel, string> = {\n INFO: \"\\x1b[32m\",\n WARN: \"\\x1b[33m\",\n ERROR: \"\\x1b[31m\",\n DEBUG: \"\\x1b[36m\",\n};\n\nconst RESET_COLOR = \"\\x1b[0m\";\nconst DIM_COLOR = \"\\x1b[2m\";\n\n/**\n * Formats a log entry with ANSI colors for human-readable development output.\n */\nexport function formatDevLog(\n level: LogLevel,\n message: string,\n context?: LogContext,\n timestamp?: string,\n): string {\n const color = LEVEL_COLORS[level];\n const resolvedTimestamp = timestamp ?? new Date().toISOString();\n const baseLine = `${DIM_COLOR}${resolvedTimestamp}${RESET_COLOR} ${color}[${level}]${RESET_COLOR} ${message}`;\n\n if (!context || Object.keys(context).length === 0) {\n return baseLine;\n }\n\n return `${baseLine} ${DIM_COLOR}${JSON.stringify(context)}${RESET_COLOR}`;\n}\n","import type { LogContext } from \"@/types/logger/log-context.type\";\nimport type { LogLevel } from \"@/types/logger/log-level.type\";\nimport { checkIsDevelopment } from \"@/logger/check-is-development\";\nimport { formatDevLog } from \"@/logger/format-dev-log\";\n\nexport type { LogLevel } from \"@/types/logger/log-level.type\";\nexport type { LogContext } from \"@/types/logger/log-context.type\";\n\n/**\n * Universal structured logger.\n * Outputs ANSI-colored lines in development/test and structured JSON in production.\n */\nclass Logger {\n private write(level: LogLevel, message: string, context?: LogContext): void {\n const timestamp = new Date().toISOString();\n const isDev = checkIsDevelopment();\n\n if (isDev) {\n const formatted = formatDevLog(level, message, context, timestamp);\n this.emitToConsole(level, formatted);\n return;\n }\n\n const payload = JSON.stringify({\n timestamp,\n level,\n message,\n ...(context ? { context } : {}),\n });\n this.emitToConsole(level, payload);\n }\n\n private emitToConsole(level: LogLevel, line: string): void {\n if (level === \"ERROR\") {\n console.error(line);\n return;\n }\n if (level === \"WARN\") {\n console.warn(line);\n return;\n }\n console.log(line);\n }\n\n public info(message: string, context?: LogContext): void {\n this.write(\"INFO\", message, context);\n }\n\n public warn(message: string, context?: LogContext): void {\n this.write(\"WARN\", message, context);\n }\n\n public error(message: string, context?: LogContext): void {\n this.write(\"ERROR\", message, context);\n }\n\n public debug(message: string, context?: LogContext): void {\n this.write(\"DEBUG\", message, context);\n }\n}\n\nexport const logger = new Logger();\n"],"mappings":";AAKO,SAAS,qBAA8B;AAC5C,QAAM,eAAe;AACrB,QAAM,eAAe,aAAa,SAAS;AAC3C,MAAI,OAAO,iBAAiB,YAAY,iBAAiB,MAAM;AAC7D,UAAM,WAAY,aAAyC,KAAK;AAChE,QAAI,OAAO,aAAa,YAAY,aAAa,MAAM;AACrD,YAAM,UAAW,SAAqC,UAAU;AAChE,UAAI,YAAY,iBAAiB,YAAY,QAAQ;AACnD,eAAO;AAAA,MACT;AACA,UAAI,YAAY,cAAc;AAC5B,eAAO;AAAA,MACT;AAAA,IACF;AAAA,EACF;AAEA,MAAI;AACF,WAAO,QAAQ,YAAY,KAAK,GAAG;AAAA,EACrC,QAAQ;AACN,WAAO;AAAA,EACT;AACF;;;ACvBA,IAAM,eAAyC;AAAA,EAC7C,MAAM;AAAA,EACN,MAAM;AAAA,EACN,OAAO;AAAA,EACP,OAAO;AACT;AAEA,IAAM,cAAc;AACpB,IAAM,YAAY;AAKX,SAAS,aACd,OACA,SACA,SACA,WACQ;AACR,QAAM,QAAQ,aAAa,KAAK;AAChC,QAAM,oBAAoB,cAAa,oBAAI,KAAK,GAAE,YAAY;AAC9D,QAAM,WAAW,GAAG,SAAS,GAAG,iBAAiB,GAAG,WAAW,IAAI,KAAK,IAAI,KAAK,IAAI,WAAW,IAAI,OAAO;AAE3G,MAAI,CAAC,WAAW,OAAO,KAAK,OAAO,EAAE,WAAW,GAAG;AACjD,WAAO;AAAA,EACT;AAEA,SAAO,GAAG,QAAQ,IAAI,SAAS,GAAG,KAAK,UAAU,OAAO,CAAC,GAAG,WAAW;AACzE;;;ACnBA,IAAM,SAAN,MAAa;AAAA,EACH,MAAM,OAAiB,SAAiB,SAA4B;AAC1E,UAAM,aAAY,oBAAI,KAAK,GAAE,YAAY;AACzC,UAAM,QAAQ,mBAAmB;AAEjC,QAAI,OAAO;AACT,YAAM,YAAY,aAAa,OAAO,SAAS,SAAS,SAAS;AACjE,WAAK,cAAc,OAAO,SAAS;AACnC;AAAA,IACF;AAEA,UAAM,UAAU,KAAK,UAAU;AAAA,MAC7B;AAAA,MACA;AAAA,MACA;AAAA,MACA,GAAI,UAAU,EAAE,QAAQ,IAAI,CAAC;AAAA,IAC/B,CAAC;AACD,SAAK,cAAc,OAAO,OAAO;AAAA,EACnC;AAAA,EAEQ,cAAc,OAAiB,MAAoB;AACzD,QAAI,UAAU,SAAS;AACrB,cAAQ,MAAM,IAAI;AAClB;AAAA,IACF;AACA,QAAI,UAAU,QAAQ;AACpB,cAAQ,KAAK,IAAI;AACjB;AAAA,IACF;AACA,YAAQ,IAAI,IAAI;AAAA,EAClB;AAAA,EAEO,KAAK,SAAiB,SAA4B;AACvD,SAAK,MAAM,QAAQ,SAAS,OAAO;AAAA,EACrC;AAAA,EAEO,KAAK,SAAiB,SAA4B;AACvD,SAAK,MAAM,QAAQ,SAAS,OAAO;AAAA,EACrC;AAAA,EAEO,MAAM,SAAiB,SAA4B;AACxD,SAAK,MAAM,SAAS,SAAS,OAAO;AAAA,EACtC;AAAA,EAEO,MAAM,SAAiB,SAA4B;AACxD,SAAK,MAAM,SAAS,SAAS,OAAO;AAAA,EACtC;AACF;AAEO,IAAM,SAAS,IAAI,OAAO;","names":[]}
@@ -0,0 +1,41 @@
1
+ import { B as BatchCapableDb } from '../batch-capable-db.type-Cyybxkjc.js';
2
+
3
+ /**
4
+ * Minimal pipe contract: receives the current context and returns the next context.
5
+ */
6
+ type PipeAction<TIn, TOut = TIn> = (context: TIn) => Promise<TOut> | TOut;
7
+
8
+ /**
9
+ * Pipeline orchestrator inspired by Laravel's Pipeline pattern.
10
+ * Supports sequential pipe execution and optional atomic Cloudflare D1 batching
11
+ * via `.transactional(db)`.
12
+ */
13
+ declare class Pipeline<TContext> {
14
+ private readonly context;
15
+ private pipes;
16
+ private dbInstance;
17
+ private isTransactional;
18
+ private constructor();
19
+ /**
20
+ * Initializes a new pipeline with the given initial context.
21
+ */
22
+ static send<TInitial>(context: TInitial): Pipeline<TInitial>;
23
+ /**
24
+ * Enables transactional mode using Cloudflare D1 `db.batch()`.
25
+ * Pipes must push statements onto `context.stagedStatements` instead of
26
+ * executing them immediately.
27
+ */
28
+ transactional(db: BatchCapableDb): this;
29
+ /**
30
+ * Registers the ordered list of pipe actions to execute.
31
+ */
32
+ through(pipes: PipeAction<TContext, TContext>[]): this;
33
+ /**
34
+ * Executes all registered pipes sequentially and optionally passes the final
35
+ * context to a destination closure.
36
+ */
37
+ then<TResult = TContext>(destination?: (context: TContext) => Promise<TResult> | TResult): Promise<TResult>;
38
+ private hasStagedStatements;
39
+ }
40
+
41
+ export { BatchCapableDb, type PipeAction, Pipeline };
@@ -0,0 +1,64 @@
1
+ // src/pipeline/pipeline.ts
2
+ var Pipeline = class _Pipeline {
3
+ context;
4
+ pipes = [];
5
+ dbInstance = null;
6
+ isTransactional = false;
7
+ constructor(context) {
8
+ this.context = context;
9
+ }
10
+ /**
11
+ * Initializes a new pipeline with the given initial context.
12
+ */
13
+ static send(context) {
14
+ return new _Pipeline(context);
15
+ }
16
+ /**
17
+ * Enables transactional mode using Cloudflare D1 `db.batch()`.
18
+ * Pipes must push statements onto `context.stagedStatements` instead of
19
+ * executing them immediately.
20
+ */
21
+ transactional(db) {
22
+ this.dbInstance = db;
23
+ this.isTransactional = true;
24
+ return this;
25
+ }
26
+ /**
27
+ * Registers the ordered list of pipe actions to execute.
28
+ */
29
+ through(pipes) {
30
+ this.pipes = pipes;
31
+ return this;
32
+ }
33
+ /**
34
+ * Executes all registered pipes sequentially and optionally passes the final
35
+ * context to a destination closure.
36
+ */
37
+ async then(destination) {
38
+ let currentContext = this.context;
39
+ try {
40
+ for (const pipe of this.pipes) {
41
+ currentContext = await pipe(currentContext);
42
+ }
43
+ if (this.isTransactional && this.dbInstance && this.hasStagedStatements(currentContext) && currentContext.stagedStatements.length > 0) {
44
+ await this.dbInstance.batch(currentContext.stagedStatements);
45
+ }
46
+ if (destination) {
47
+ return await destination(currentContext);
48
+ }
49
+ return currentContext;
50
+ } catch (caughtError) {
51
+ if (this.isTransactional && this.hasStagedStatements(currentContext)) {
52
+ currentContext.stagedStatements = [];
53
+ }
54
+ throw caughtError;
55
+ }
56
+ }
57
+ hasStagedStatements(candidate) {
58
+ return typeof candidate === "object" && candidate !== null && "stagedStatements" in candidate && Array.isArray(candidate.stagedStatements);
59
+ }
60
+ };
61
+ export {
62
+ Pipeline
63
+ };
64
+ //# sourceMappingURL=pipeline.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/pipeline/pipeline.ts"],"sourcesContent":["import type { PipeAction } from \"@/types/pipeline/pipe-action.type\";\nimport type { BatchCapableDb } from \"@/types/pipeline/batch-capable-db.type\";\n\nexport type { PipeAction } from \"@/types/pipeline/pipe-action.type\";\nexport type { BatchCapableDb } from \"@/types/pipeline/batch-capable-db.type\";\n\n/**\n * Pipeline orchestrator inspired by Laravel's Pipeline pattern.\n * Supports sequential pipe execution and optional atomic Cloudflare D1 batching\n * via `.transactional(db)`.\n */\nexport class Pipeline<TContext> {\n private readonly context: TContext;\n private pipes: PipeAction<TContext, TContext>[] = [];\n private dbInstance: BatchCapableDb | null = null;\n private isTransactional = false;\n\n private constructor(context: TContext) {\n this.context = context;\n }\n\n /**\n * Initializes a new pipeline with the given initial context.\n */\n public static send<TInitial>(context: TInitial): Pipeline<TInitial> {\n return new Pipeline(context);\n }\n\n /**\n * Enables transactional mode using Cloudflare D1 `db.batch()`.\n * Pipes must push statements onto `context.stagedStatements` instead of\n * executing them immediately.\n */\n public transactional(db: BatchCapableDb): this {\n this.dbInstance = db;\n this.isTransactional = true;\n return this;\n }\n\n /**\n * Registers the ordered list of pipe actions to execute.\n */\n public through(pipes: PipeAction<TContext, TContext>[]): this {\n this.pipes = pipes;\n return this;\n }\n\n /**\n * Executes all registered pipes sequentially and optionally passes the final\n * context to a destination closure.\n */\n public async then<TResult = TContext>(\n destination?: (context: TContext) => Promise<TResult> | TResult,\n ): Promise<TResult> {\n let currentContext = this.context;\n\n try {\n for (const pipe of this.pipes) {\n currentContext = await pipe(currentContext);\n }\n\n if (\n this.isTransactional &&\n this.dbInstance &&\n this.hasStagedStatements(currentContext) &&\n currentContext.stagedStatements.length > 0\n ) {\n await this.dbInstance.batch(currentContext.stagedStatements);\n }\n\n if (destination) {\n return await destination(currentContext);\n }\n\n return currentContext as unknown as TResult;\n } catch (caughtError) {\n if (this.isTransactional && this.hasStagedStatements(currentContext)) {\n currentContext.stagedStatements = [];\n }\n throw caughtError;\n }\n }\n\n private hasStagedStatements(\n candidate: unknown,\n ): candidate is { stagedStatements: unknown[] } {\n return (\n typeof candidate === \"object\" &&\n candidate !== null &&\n \"stagedStatements\" in candidate &&\n Array.isArray((candidate as { stagedStatements: unknown }).stagedStatements)\n );\n }\n}\n"],"mappings":";AAWO,IAAM,WAAN,MAAM,UAAmB;AAAA,EACb;AAAA,EACT,QAA0C,CAAC;AAAA,EAC3C,aAAoC;AAAA,EACpC,kBAAkB;AAAA,EAElB,YAAY,SAAmB;AACrC,SAAK,UAAU;AAAA,EACjB;AAAA;AAAA;AAAA;AAAA,EAKA,OAAc,KAAe,SAAuC;AAClE,WAAO,IAAI,UAAS,OAAO;AAAA,EAC7B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOO,cAAc,IAA0B;AAC7C,SAAK,aAAa;AAClB,SAAK,kBAAkB;AACvB,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA,EAKO,QAAQ,OAA+C;AAC5D,SAAK,QAAQ;AACb,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAa,KACX,aACkB;AAClB,QAAI,iBAAiB,KAAK;AAE1B,QAAI;AACF,iBAAW,QAAQ,KAAK,OAAO;AAC7B,yBAAiB,MAAM,KAAK,cAAc;AAAA,MAC5C;AAEA,UACE,KAAK,mBACL,KAAK,cACL,KAAK,oBAAoB,cAAc,KACvC,eAAe,iBAAiB,SAAS,GACzC;AACA,cAAM,KAAK,WAAW,MAAM,eAAe,gBAAgB;AAAA,MAC7D;AAEA,UAAI,aAAa;AACf,eAAO,MAAM,YAAY,cAAc;AAAA,MACzC;AAEA,aAAO;AAAA,IACT,SAAS,aAAa;AACpB,UAAI,KAAK,mBAAmB,KAAK,oBAAoB,cAAc,GAAG;AACpE,uBAAe,mBAAmB,CAAC;AAAA,MACrC;AACA,YAAM;AAAA,IACR;AAAA,EACF;AAAA,EAEQ,oBACN,WAC8C;AAC9C,WACE,OAAO,cAAc,YACrB,cAAc,QACd,sBAAsB,aACtB,MAAM,QAAS,UAA4C,gBAAgB;AAAA,EAE/E;AACF;","names":[]}
@@ -0,0 +1,16 @@
1
+ import { B as BatchCapableDb } from '../batch-capable-db.type-Cyybxkjc.js';
2
+
3
+ /**
4
+ * Context contract required by `withD1Transaction`.
5
+ */
6
+ interface D1TransactionContext<TStatement = unknown> {
7
+ stagedStatements: TStatement[];
8
+ }
9
+
10
+ /**
11
+ * Standalone helper to execute staged D1 statements atomically via `db.batch()`,
12
+ * clearing staged statements on error as a preventive in-memory rollback.
13
+ */
14
+ declare function withD1Transaction<TContext extends D1TransactionContext<TStatement>, TStatement = unknown>(db: BatchCapableDb<TStatement>, context: TContext, work: (transactionContext: TContext) => Promise<void> | void): Promise<TContext>;
15
+
16
+ export { type D1TransactionContext, withD1Transaction };
@@ -0,0 +1,17 @@
1
+ // src/pipeline/with-d1-transaction.ts
2
+ async function withD1Transaction(db, context, work) {
3
+ try {
4
+ await work(context);
5
+ if (context.stagedStatements.length > 0) {
6
+ await db.batch(context.stagedStatements);
7
+ }
8
+ return context;
9
+ } catch (caughtError) {
10
+ context.stagedStatements = [];
11
+ throw caughtError;
12
+ }
13
+ }
14
+ export {
15
+ withD1Transaction
16
+ };
17
+ //# sourceMappingURL=with-d1-transaction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/pipeline/with-d1-transaction.ts"],"sourcesContent":["import type { BatchCapableDb } from \"@/types/pipeline/batch-capable-db.type\";\nimport type { D1TransactionContext } from \"@/types/pipeline/d1-transaction-context.type\";\n\nexport type { D1TransactionContext } from \"@/types/pipeline/d1-transaction-context.type\";\n\n/**\n * Standalone helper to execute staged D1 statements atomically via `db.batch()`,\n * clearing staged statements on error as a preventive in-memory rollback.\n */\nexport async function withD1Transaction<\n TContext extends D1TransactionContext<TStatement>,\n TStatement = unknown,\n>(\n db: BatchCapableDb<TStatement>,\n context: TContext,\n work: (transactionContext: TContext) => Promise<void> | void,\n): Promise<TContext> {\n try {\n await work(context);\n\n if (context.stagedStatements.length > 0) {\n await db.batch(context.stagedStatements);\n }\n\n return context;\n } catch (caughtError) {\n context.stagedStatements = [];\n throw caughtError;\n }\n}\n"],"mappings":";AASA,eAAsB,kBAIpB,IACA,SACA,MACmB;AACnB,MAAI;AACF,UAAM,KAAK,OAAO;AAElB,QAAI,QAAQ,iBAAiB,SAAS,GAAG;AACvC,YAAM,GAAG,MAAM,QAAQ,gBAAgB;AAAA,IACzC;AAEA,WAAO;AAAA,EACT,SAAS,aAAa;AACpB,YAAQ,mBAAmB,CAAC;AAC5B,UAAM;AAAA,EACR;AACF;","names":[]}
package/package.json CHANGED
@@ -1,16 +1,43 @@
1
1
  {
2
2
  "name": "@3lineas/groovepack",
3
- "version": "0.1.4",
4
- "description": "Interactive CLI for sharing reusable library templates across projects without npm package clutter",
3
+ "version": "1.2.0",
4
+ "description": "Zero-dependency & modular infrastructure primitives for TypeScript, Cloudflare Workers (D1, Hono), React, and Astro.",
5
5
  "type": "module",
6
- "bin": {
7
- "groovepack": "dist/index.js"
8
- },
6
+ "sideEffects": false,
9
7
  "files": [
10
8
  "dist",
11
- "registry",
12
9
  "README.md"
13
10
  ],
11
+ "exports": {
12
+ "./logger": {
13
+ "types": "./dist/logger/index.d.ts",
14
+ "import": "./dist/logger/index.js"
15
+ },
16
+ "./pipeline": {
17
+ "types": "./dist/pipeline/pipeline.d.ts",
18
+ "import": "./dist/pipeline/pipeline.js"
19
+ },
20
+ "./pipeline/with-d1-transaction": {
21
+ "types": "./dist/pipeline/with-d1-transaction.d.ts",
22
+ "import": "./dist/pipeline/with-d1-transaction.js"
23
+ },
24
+ "./api-client": {
25
+ "types": "./dist/api-client/index.d.ts",
26
+ "import": "./dist/api-client/index.js"
27
+ },
28
+ "./api-action": {
29
+ "types": "./dist/api-action/index.d.ts",
30
+ "import": "./dist/api-action/index.js"
31
+ },
32
+ "./api-toast": {
33
+ "types": "./dist/api-toast/index.d.ts",
34
+ "import": "./dist/api-toast/index.js"
35
+ },
36
+ "./i18n": {
37
+ "types": "./dist/i18n/index.d.ts",
38
+ "import": "./dist/i18n/index.js"
39
+ }
40
+ },
14
41
  "publishConfig": {
15
42
  "access": "public"
16
43
  },
@@ -23,28 +50,40 @@
23
50
  "url": "https://github.com/3-Lineas/GroovePack/issues"
24
51
  },
25
52
  "scripts": {
26
- "dev": "tsx src/index.ts",
27
53
  "build": "tsup",
28
54
  "prepublishOnly": "pnpm run check-types && pnpm run build",
29
55
  "check-types": "tsc --noEmit",
30
- "test": "tsx test/rollback-and-install.test.ts"
56
+ "test": "tsx --test test/*.test.ts"
57
+ },
58
+ "peerDependencies": {
59
+ "@base-ui/react": ">=1.0.0",
60
+ "hono": ">=4.0.0"
31
61
  },
32
- "dependencies": {
33
- "@clack/prompts": "^0.8.2",
34
- "picocolors": "^1.1.1"
62
+ "peerDependenciesMeta": {
63
+ "@base-ui/react": {
64
+ "optional": true
65
+ },
66
+ "hono": {
67
+ "optional": true
68
+ }
35
69
  },
36
70
  "devDependencies": {
37
71
  "@types/node": "^22.10.1",
72
+ "hono": "^4.7.0",
38
73
  "tsup": "^8.3.5",
39
74
  "tsx": "^4.19.2",
40
75
  "typescript": "^5.7.2"
41
76
  },
42
77
  "keywords": [
43
- "cli",
44
- "scaffold",
45
- "code-sharing",
46
- "shadcn-style",
47
- "groovepack"
78
+ "groovepack",
79
+ "hono",
80
+ "cloudflare-d1",
81
+ "pipeline",
82
+ "logger",
83
+ "api-client",
84
+ "api-action",
85
+ "base-ui",
86
+ "shadcn"
48
87
  ],
49
88
  "author": "3lineas",
50
89
  "license": "MIT"