@usequark/quark-core 2.5.4 → 2.5.5
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/LICENSE +21 -0
- package/README.md +12 -12
- package/package.json +79 -79
- package/src/admin-auth.js +2 -2
- package/src/admin.js +2 -2
- package/src/auth/index.js +1 -1
- package/src/auth/middleware.js +2 -2
- package/src/authorization.js +1 -1
- package/src/core.js +2 -2
- package/src/csrf.js +1 -1
- package/src/db-instrumentation.js +2 -2
- package/src/db-metrics.js +1 -1
- package/src/db.js +2 -2
- package/src/email-templates.js +1 -1
- package/src/email.js +2 -2
- package/src/error-reporter.js +2 -2
- package/src/errors.js +1 -1
- package/src/exports.test.js +19 -19
- package/src/file-validation.js +1 -1
- package/src/index.js +1 -1
- package/src/logger.js +1 -1
- package/src/metrics.js +1 -1
- package/src/multipart.js +1 -1
- package/src/pagination.js +2 -2
- package/src/query-builder.js +1 -1
- package/src/queue/index.js +1 -1
- package/src/rate-limiter.js +1 -1
- package/src/request-logger.js +1 -1
- package/src/sms.js +2 -2
- package/src/storage-s3.js +3 -3
- package/src/storage.js +2 -2
- package/src/stripe.js +3 -3
- package/src/testing/factories.js +1 -1
- package/src/testing/index.js +2 -2
- package/src/types.js +1 -1
- package/src/utils.js +2 -2
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024, Quark Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# @
|
|
1
|
+
# @usequark/quark-core
|
|
2
2
|
|
|
3
3
|
Shared infrastructure for the Quark platform - authentication, job queues, error handling, and utilities.
|
|
4
4
|
|
|
@@ -25,7 +25,7 @@ import {
|
|
|
25
25
|
addJob,
|
|
26
26
|
ValidationError,
|
|
27
27
|
retryAsync,
|
|
28
|
-
} from "@
|
|
28
|
+
} from "@usequark/quark-core";
|
|
29
29
|
```
|
|
30
30
|
|
|
31
31
|
All modules are re-exported from the package root. See JSDoc comments on each function for options and usage details.
|
|
@@ -36,16 +36,16 @@ Prefer a subpath when you want a smaller import graph or the browser-safe logger
|
|
|
36
36
|
|
|
37
37
|
| Subpath | Contents |
|
|
38
38
|
|---|---|
|
|
39
|
-
| `@
|
|
40
|
-
| `@
|
|
41
|
-
| `@
|
|
42
|
-
| `@
|
|
43
|
-
| `@
|
|
44
|
-
| `@
|
|
45
|
-
| `@
|
|
46
|
-
| `@
|
|
47
|
-
| `@
|
|
48
|
-
| `@
|
|
39
|
+
| `@usequark/quark-core/core` | errors, logger, validation, utils, pagination, csrf, rate limiter, file validation, db |
|
|
40
|
+
| `@usequark/quark-core/db` | Prisma singleton, connection string, pool config, `pingDatabase()` |
|
|
41
|
+
| `@usequark/quark-core/admin` | Prisma schema introspection helpers |
|
|
42
|
+
| `@usequark/quark-core/auth` | auth config helpers + session guards |
|
|
43
|
+
| `@usequark/quark-core/auth/middleware` | session guards only |
|
|
44
|
+
| `@usequark/quark-core/storage` | local adapter, storage factory, key/URL helpers, `createS3Storage` |
|
|
45
|
+
| `@usequark/quark-core/storage/s3` | S3 adapter only |
|
|
46
|
+
| `@usequark/quark-core/logger` | browser-safe logger |
|
|
47
|
+
| `@usequark/quark-core/locale` | locale helpers |
|
|
48
|
+
| `@usequark/quark-core/stripe` | Stripe client + webhook helpers |
|
|
49
49
|
|
|
50
50
|
`@aws-sdk/client-s3`, `@aws-sdk/s3-request-presigner`, `pg`, and `stripe` are optional peer dependencies. They are only loaded when the matching feature is used, so apps that do not use S3, `pingDatabase()`, or payments do not need them installed.
|
|
51
51
|
|
package/package.json
CHANGED
|
@@ -1,80 +1,80 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
}
|
|
2
|
+
"name": "@usequark/quark-core",
|
|
3
|
+
"version": "2.5.5",
|
|
4
|
+
"description": "Core utilities for Quark apps: auth, BullMQ queues, Redis, email, storage, rate limiting, logging, and error handling",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "src/index.js",
|
|
7
|
+
"homepage": "https://github.com/usequark/quark#readme",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "https://github.com/usequark/quark.git",
|
|
11
|
+
"directory": "packages/core"
|
|
12
|
+
},
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/usequark/quark/issues"
|
|
15
|
+
},
|
|
16
|
+
"author": "Quark Contributors",
|
|
17
|
+
"exports": {
|
|
18
|
+
".": "./src/index.js",
|
|
19
|
+
"./core": "./src/core.js",
|
|
20
|
+
"./admin": "./src/admin.js",
|
|
21
|
+
"./auth": "./src/auth/index.js",
|
|
22
|
+
"./auth/middleware": "./src/auth/middleware.js",
|
|
23
|
+
"./db": "./src/db.js",
|
|
24
|
+
"./email": "./src/email.js",
|
|
25
|
+
"./errors": "./src/errors.js",
|
|
26
|
+
"./locale": "./src/locale.js",
|
|
27
|
+
"./logger": "./src/logger.js",
|
|
28
|
+
"./metrics": "./src/metrics.js",
|
|
29
|
+
"./queue": "./src/queue/index.js",
|
|
30
|
+
"./sms": "./src/sms.js",
|
|
31
|
+
"./storage": "./src/storage.js",
|
|
32
|
+
"./storage/s3": "./src/storage-s3.js",
|
|
33
|
+
"./stripe": "./src/stripe.js",
|
|
34
|
+
"./testing": "./src/testing/index.js"
|
|
35
|
+
},
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"bcryptjs": "^3.0.3",
|
|
38
|
+
"busboy": "^1.6.0",
|
|
39
|
+
"bullmq": "^6.3.8",
|
|
40
|
+
"ioredis": "^6.0.0",
|
|
41
|
+
"nodemailer": "^10.0.10",
|
|
42
|
+
"zod": "^4.6.5"
|
|
43
|
+
},
|
|
44
|
+
"peerDependencies": {
|
|
45
|
+
"@aws-sdk/client-s3": "^3.1004.0",
|
|
46
|
+
"@aws-sdk/s3-request-presigner": "^3.1004.0",
|
|
47
|
+
"pg": "^8.20.0",
|
|
48
|
+
"stripe": "^17.0.0"
|
|
49
|
+
},
|
|
50
|
+
"peerDependenciesMeta": {
|
|
51
|
+
"@aws-sdk/client-s3": {
|
|
52
|
+
"optional": true
|
|
53
|
+
},
|
|
54
|
+
"@aws-sdk/s3-request-presigner": {
|
|
55
|
+
"optional": true
|
|
56
|
+
},
|
|
57
|
+
"pg": {
|
|
58
|
+
"optional": true
|
|
59
|
+
},
|
|
60
|
+
"stripe": {
|
|
61
|
+
"optional": true
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
"devDependencies": {
|
|
65
|
+
"@types/node": "^26.6.2"
|
|
66
|
+
},
|
|
67
|
+
"files": [
|
|
68
|
+
"src",
|
|
69
|
+
"README.md"
|
|
70
|
+
],
|
|
71
|
+
"publishConfig": {
|
|
72
|
+
"registry": "https://registry.npmjs.org",
|
|
73
|
+
"access": "public"
|
|
74
|
+
},
|
|
75
|
+
"license": "MIT",
|
|
76
|
+
"scripts": {
|
|
77
|
+
"test": "node ../../scripts/run-tests.mjs src",
|
|
78
|
+
"lint": "biome format --write && biome check --write"
|
|
79
|
+
}
|
|
80
|
+
}
|
package/src/admin-auth.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @
|
|
2
|
+
* @usequark/quark-core — Admin Authorization Module
|
|
3
3
|
*
|
|
4
4
|
* Lightweight, stateless admin-token authorization for drop-in internal
|
|
5
5
|
* endpoints (health checks, metrics, admin APIs).
|
|
@@ -72,7 +72,7 @@ export function verifyAdminToken(providedToken) {
|
|
|
72
72
|
*
|
|
73
73
|
* Usage in an API route:
|
|
74
74
|
*
|
|
75
|
-
* import { requireAdminToken } from "@
|
|
75
|
+
* import { requireAdminToken } from "@usequark/quark-core";
|
|
76
76
|
* import { NextResponse } from "next/server";
|
|
77
77
|
*
|
|
78
78
|
* export async function GET(request) {
|
package/src/admin.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @
|
|
2
|
+
* @usequark/quark-core - Prisma Schema Introspection
|
|
3
3
|
*
|
|
4
4
|
* Hand-rolled Prisma schema parser that reads `.prisma` files and
|
|
5
5
|
* extracts model and enum definitions. Used by the admin CRUD layer
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* where those packages are unavailable.
|
|
11
11
|
*
|
|
12
12
|
* Usage:
|
|
13
|
-
* import { parseSchema, getModelByName, detectIdField, coerceId } from "@
|
|
13
|
+
* import { parseSchema, getModelByName, detectIdField, coerceId } from "@usequark/quark-core/admin";
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
16
|
import { existsSync, readFileSync } from "node:fs";
|
package/src/auth/index.js
CHANGED
package/src/auth/middleware.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @
|
|
2
|
+
* @usequark/quark-core - Auth Middleware
|
|
3
3
|
*
|
|
4
4
|
* Lightweight, framework-agnostic authentication middleware for Server
|
|
5
5
|
* Actions and API routes. The caller supplies a `getSession` function
|
|
6
6
|
* (e.g. NextAuth's `auth()`) — this module adds the guard logic.
|
|
7
7
|
*
|
|
8
8
|
* Usage:
|
|
9
|
-
* import { requireSession, requireSessionRole, createAuthMiddleware } from "@
|
|
9
|
+
* import { requireSession, requireSessionRole, createAuthMiddleware } from "@usequark/quark-core/auth/middleware";
|
|
10
10
|
*
|
|
11
11
|
* // In a Server Action:
|
|
12
12
|
* const session = await requireSession(() => auth());
|
package/src/authorization.js
CHANGED
package/src/core.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @
|
|
2
|
+
* @usequark/quark-core - Core Barrel (Lightweight Utilities)
|
|
3
3
|
*
|
|
4
4
|
* A smaller entry-point that exposes only the modules with zero or
|
|
5
5
|
* minimal transitive dependencies: errors, logger, validation, utils,
|
|
6
6
|
* pagination, csrf, rate-limiter, file-validation, and db.
|
|
7
7
|
*
|
|
8
8
|
* Downstream projects that only need these utilities can import from
|
|
9
|
-
* "@
|
|
9
|
+
* "@usequark/quark-core/core" to avoid pulling in heavier modules
|
|
10
10
|
* like email, storage, queue, or metrics.
|
|
11
11
|
*/
|
|
12
12
|
|
package/src/csrf.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @
|
|
2
|
+
* @usequark/quark-core — Database Instrumentation Module
|
|
3
3
|
*
|
|
4
4
|
* Schema-agnostic Prisma $extends middleware that monitors query execution
|
|
5
5
|
* times and logs slow queries. All query arguments are automatically masked
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
*
|
|
11
11
|
* Usage in client.js:
|
|
12
12
|
*
|
|
13
|
-
* import { createDbInstrumentation } from "@
|
|
13
|
+
* import { createDbInstrumentation } from "@usequark/quark-core";
|
|
14
14
|
* const base = new PrismaClient({ ... });
|
|
15
15
|
* const ext = createDbInstrumentation();
|
|
16
16
|
* if (ext) prisma = base.$extends(ext);
|
package/src/db-metrics.js
CHANGED
package/src/db.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @
|
|
2
|
+
* @usequark/quark-core - Database Utilities
|
|
3
3
|
*
|
|
4
4
|
* Shared Prisma client singleton, connection-string builder, pool config,
|
|
5
5
|
* and a lightweight health-check ping. These replace the per-project
|
|
6
6
|
* re-implementations in Regina / Pawdora / Trenchmate.
|
|
7
7
|
*
|
|
8
8
|
* Usage:
|
|
9
|
-
* import { createPrismaClient, getConnectionString, pingDatabase } from "@
|
|
9
|
+
* import { createPrismaClient, getConnectionString, pingDatabase } from "@usequark/quark-core/db";
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
12
|
// ---------------------------------------------------------------------------
|
package/src/email-templates.js
CHANGED
package/src/email.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @
|
|
2
|
+
* @usequark/quark-core - Email Service
|
|
3
3
|
*
|
|
4
4
|
* Providers are defined using a Strategy Pattern - each implements the same
|
|
5
5
|
* interface. Quark ships with three built-in providers (smtp, resend, zeptomail)
|
|
6
6
|
* and exposes a registry so users can plug in any provider they need.
|
|
7
7
|
*
|
|
8
8
|
* @example Custom provider
|
|
9
|
-
* import { EmailProvider, registerEmailProvider } from "@
|
|
9
|
+
* import { EmailProvider, registerEmailProvider } from "@usequark/quark-core";
|
|
10
10
|
*
|
|
11
11
|
* class SendGridProvider extends EmailProvider {
|
|
12
12
|
* async sendEmail(to, subject, html, text) { ... }
|
package/src/error-reporter.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @
|
|
2
|
+
* @usequark/quark-core - Error Reporter Module
|
|
3
3
|
* Adapter/hook system for pluggable error reporting
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -217,7 +217,7 @@ export class ErrorReporter {
|
|
|
217
217
|
* @example
|
|
218
218
|
* ```js
|
|
219
219
|
* import * as Sentry from "@sentry/node";
|
|
220
|
-
* import { errorReporter, createSentryAdapter } from "@
|
|
220
|
+
* import { errorReporter, createSentryAdapter } from "@usequark/quark-core";
|
|
221
221
|
*
|
|
222
222
|
* Sentry.init({ dsn: "https://example@sentry.io/123" });
|
|
223
223
|
* errorReporter.use(createSentryAdapter({ Sentry }));
|
package/src/errors.js
CHANGED
package/src/exports.test.js
CHANGED
|
@@ -2,34 +2,34 @@ import assert from "node:assert/strict";
|
|
|
2
2
|
import { readFileSync } from "node:fs";
|
|
3
3
|
import test from "node:test";
|
|
4
4
|
|
|
5
|
-
import * as core from "@
|
|
6
|
-
import * as admin from "@
|
|
7
|
-
import * as auth from "@
|
|
8
|
-
import * as authMiddleware from "@
|
|
9
|
-
import * as coreLight from "@
|
|
10
|
-
import * as db from "@
|
|
11
|
-
import * as email from "@
|
|
12
|
-
import * as errors from "@
|
|
13
|
-
import * as locale from "@
|
|
14
|
-
import * as logger from "@
|
|
15
|
-
import * as metrics from "@
|
|
16
|
-
import * as queue from "@
|
|
17
|
-
import * as sms from "@
|
|
18
|
-
import * as storage from "@
|
|
19
|
-
import * as storageS3 from "@
|
|
20
|
-
import * as stripe from "@
|
|
21
|
-
import * as testing from "@
|
|
5
|
+
import * as core from "@usequark/quark-core";
|
|
6
|
+
import * as admin from "@usequark/quark-core/admin";
|
|
7
|
+
import * as auth from "@usequark/quark-core/auth";
|
|
8
|
+
import * as authMiddleware from "@usequark/quark-core/auth/middleware";
|
|
9
|
+
import * as coreLight from "@usequark/quark-core/core";
|
|
10
|
+
import * as db from "@usequark/quark-core/db";
|
|
11
|
+
import * as email from "@usequark/quark-core/email";
|
|
12
|
+
import * as errors from "@usequark/quark-core/errors";
|
|
13
|
+
import * as locale from "@usequark/quark-core/locale";
|
|
14
|
+
import * as logger from "@usequark/quark-core/logger";
|
|
15
|
+
import * as metrics from "@usequark/quark-core/metrics";
|
|
16
|
+
import * as queue from "@usequark/quark-core/queue";
|
|
17
|
+
import * as sms from "@usequark/quark-core/sms";
|
|
18
|
+
import * as storage from "@usequark/quark-core/storage";
|
|
19
|
+
import * as storageS3 from "@usequark/quark-core/storage/s3";
|
|
20
|
+
import * as stripe from "@usequark/quark-core/stripe";
|
|
21
|
+
import * as testing from "@usequark/quark-core/testing";
|
|
22
22
|
|
|
23
23
|
const packageJson = JSON.parse(
|
|
24
24
|
readFileSync(new URL("../package.json", import.meta.url), "utf-8"),
|
|
25
25
|
);
|
|
26
26
|
|
|
27
27
|
// Guard against accidental subpath removals: every entry in the exports map
|
|
28
|
-
// must resolve. apps/web imports `@
|
|
28
|
+
// must resolve. apps/web imports `@usequark/quark-core/logger`, and the
|
|
29
29
|
// scaffolded i18n/payment skills document `./locale` and `./stripe`.
|
|
30
30
|
test("every subpath in package.json exports resolves", async () => {
|
|
31
31
|
for (const subpath of Object.keys(packageJson.exports)) {
|
|
32
|
-
const specifier = `@
|
|
32
|
+
const specifier = `@usequark/quark-core${
|
|
33
33
|
subpath === "." ? "" : subpath.slice(1)
|
|
34
34
|
}`;
|
|
35
35
|
await assert.doesNotReject(
|
package/src/file-validation.js
CHANGED
package/src/index.js
CHANGED
|
@@ -54,5 +54,5 @@ export * from "./storage.js";
|
|
|
54
54
|
export * from "./utils.js";
|
|
55
55
|
export * from "./validation.js";
|
|
56
56
|
|
|
57
|
-
// Testing utilities (import from "@
|
|
57
|
+
// Testing utilities (import from "@usequark/quark-core/testing" in test files)
|
|
58
58
|
// Not re-exported from main to avoid polluting production imports
|
package/src/logger.js
CHANGED
package/src/metrics.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @
|
|
2
|
+
* @usequark/quark-core - Metrics Module
|
|
3
3
|
* Lightweight application metrics with zero external dependencies.
|
|
4
4
|
* Supports counters, gauges, and histograms with optional labels.
|
|
5
5
|
* Exports Prometheus-compatible text format.
|
package/src/multipart.js
CHANGED
package/src/pagination.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @
|
|
2
|
+
* @usequark/quark-core - Pagination Utilities
|
|
3
3
|
*
|
|
4
4
|
* Provides offset-based pagination helpers that integrate with Prisma's
|
|
5
5
|
* skip/take API and the project's ValidationError convention.
|
|
6
6
|
*
|
|
7
7
|
* Usage in a route handler:
|
|
8
8
|
*
|
|
9
|
-
* import { parsePaginationQuery } from "@
|
|
9
|
+
* import { parsePaginationQuery } from "@usequark/quark-core";
|
|
10
10
|
*
|
|
11
11
|
* export async function GET(request) {
|
|
12
12
|
* const { searchParams } = new URL(request.url);
|
package/src/query-builder.js
CHANGED
package/src/queue/index.js
CHANGED
package/src/rate-limiter.js
CHANGED
package/src/request-logger.js
CHANGED
|
@@ -70,7 +70,7 @@ function sanitizeObject(obj, fields = SENSITIVE_FIELDS) {
|
|
|
70
70
|
* @returns {Function} Middleware function
|
|
71
71
|
*
|
|
72
72
|
* @example
|
|
73
|
-
* import { createRequestLogger } from "@
|
|
73
|
+
* import { createRequestLogger } from "@usequark/quark-core";
|
|
74
74
|
*
|
|
75
75
|
* const logRequest = createRequestLogger({
|
|
76
76
|
* logRequestBody: true,
|
package/src/sms.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @
|
|
2
|
+
* @usequark/quark-core - SMS Service
|
|
3
3
|
*
|
|
4
4
|
* Providers are defined using a Strategy Pattern - each implements the same
|
|
5
5
|
* interface. Quark ships with one built-in provider (twilio) and exposes a
|
|
6
6
|
* registry so users can plug in any provider they need.
|
|
7
7
|
*
|
|
8
8
|
* @example Custom provider
|
|
9
|
-
* import { SmsProvider, registerSmsProvider } from "@
|
|
9
|
+
* import { SmsProvider, registerSmsProvider } from "@usequark/quark-core";
|
|
10
10
|
*
|
|
11
11
|
* class AmazonSnsProvider extends SmsProvider {
|
|
12
12
|
* async sendSms(to, body) { ... }
|
package/src/storage-s3.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @
|
|
2
|
+
* @usequark/quark-core - S3 Storage Adapter
|
|
3
3
|
*
|
|
4
4
|
* Kept in its own module so `storage.js` (and the main barrel) never pull
|
|
5
5
|
* the AWS SDK onto the import path: `@aws-sdk/client-s3` and
|
|
@@ -32,7 +32,7 @@ async function importS3ClientPackage() {
|
|
|
32
32
|
} catch (error) {
|
|
33
33
|
if (isMissingPackageError(error, S3_CLIENT_PACKAGE)) {
|
|
34
34
|
throw new Error(
|
|
35
|
-
'S3 storage support requires installing "@aws-sdk/client-s3" in the app that uses @
|
|
35
|
+
'S3 storage support requires installing "@aws-sdk/client-s3" in the app that uses @usequark/quark-core/storage/s3.',
|
|
36
36
|
);
|
|
37
37
|
}
|
|
38
38
|
throw error;
|
|
@@ -47,7 +47,7 @@ async function importS3PresignerPackage() {
|
|
|
47
47
|
} catch (error) {
|
|
48
48
|
if (isMissingPackageError(error, S3_PRESIGNER_PACKAGE)) {
|
|
49
49
|
throw new Error(
|
|
50
|
-
'Signed upload URLs require installing "@aws-sdk/s3-request-presigner" in the app that uses @
|
|
50
|
+
'Signed upload URLs require installing "@aws-sdk/s3-request-presigner" in the app that uses @usequark/quark-core/storage/s3.',
|
|
51
51
|
);
|
|
52
52
|
}
|
|
53
53
|
throw error;
|
package/src/storage.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @
|
|
2
|
+
* @usequark/quark-core - File Storage
|
|
3
3
|
*
|
|
4
4
|
* Adapter-based storage abstraction supporting local filesystem and
|
|
5
5
|
* S3-compatible providers (AWS S3, Cloudflare R2, MinIO, etc.).
|
|
@@ -23,7 +23,7 @@ import { dirname, isAbsolute, relative, resolve, sep } from "node:path";
|
|
|
23
23
|
import { pipeline } from "node:stream/promises";
|
|
24
24
|
|
|
25
25
|
// Import + re-export the S3 adapter so existing deep-imports continue
|
|
26
|
-
// to work (`import { createS3Storage } from "@
|
|
26
|
+
// to work (`import { createS3Storage } from "@usequark/quark-core/storage"`).
|
|
27
27
|
// storage-s3.js has no top-level AWS SDK imports, so this stays safe for
|
|
28
28
|
// local-only deployments that never installed the optional peer deps.
|
|
29
29
|
import { createS3Storage } from "./storage-s3.js";
|
package/src/stripe.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @
|
|
2
|
+
* @usequark/quark-core - Stripe Integration
|
|
3
3
|
*
|
|
4
4
|
* Thin wrappers around the Stripe SDK for client creation and webhook
|
|
5
5
|
* verification. Stripe is an optional peer dependency — install it in the
|
|
6
6
|
* app that uses payment features.
|
|
7
7
|
*
|
|
8
8
|
* Usage:
|
|
9
|
-
* import { createStripeClient, getStripeWebhookEvent } from "@
|
|
9
|
+
* import { createStripeClient, getStripeWebhookEvent } from "@usequark/quark-core/stripe";
|
|
10
10
|
*
|
|
11
11
|
* const stripe = await createStripeClient();
|
|
12
12
|
* const session = await stripe.checkout.sessions.create({ ... });
|
|
@@ -30,7 +30,7 @@ async function importStripePackage() {
|
|
|
30
30
|
} catch (error) {
|
|
31
31
|
if (isMissingPackageError(error, "stripe")) {
|
|
32
32
|
throw new Error(
|
|
33
|
-
'Stripe support requires installing "stripe" in the app that uses @
|
|
33
|
+
'Stripe support requires installing "stripe" in the app that uses @usequark/quark-core/stripe.',
|
|
34
34
|
);
|
|
35
35
|
}
|
|
36
36
|
throw error;
|
package/src/testing/factories.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Test data factories for creating realistic test objects with sensible defaults.
|
|
3
3
|
*
|
|
4
4
|
* Usage:
|
|
5
|
-
* import { createTestUser, createTestSession } from "@
|
|
5
|
+
* import { createTestUser, createTestSession } from "@usequark/quark-core/testing";
|
|
6
6
|
* const user = createTestUser({ name: "Custom Name" });
|
|
7
7
|
* const session = createTestSession({ user: { role: "admin" } });
|
|
8
8
|
*
|
package/src/testing/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Quark test utilities - zero-dependency helpers for testing Quark applications.
|
|
3
3
|
*
|
|
4
|
-
* Import from `@
|
|
4
|
+
* Import from `@usequark/quark-core/testing` in your test files:
|
|
5
5
|
*
|
|
6
6
|
* ```js
|
|
7
7
|
* import {
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
* createTestContext,
|
|
18
18
|
* assertThrows,
|
|
19
19
|
* assertApiResponse,
|
|
20
|
-
* } from "@
|
|
20
|
+
* } from "@usequark/quark-core/testing";
|
|
21
21
|
* ```
|
|
22
22
|
*
|
|
23
23
|
* @module testing
|
package/src/types.js
CHANGED
package/src/utils.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import crypto from "node:crypto";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* @
|
|
4
|
+
* @usequark/quark-core - Utility Functions
|
|
5
5
|
* Common utility functions used across the platform
|
|
6
6
|
*/
|
|
7
7
|
|
|
@@ -111,7 +111,7 @@ export const isObject = (item) => {
|
|
|
111
111
|
};
|
|
112
112
|
|
|
113
113
|
/**
|
|
114
|
-
* @deprecated Use `getErrorMessage` from `@
|
|
114
|
+
* @deprecated Use `getErrorMessage` from `@usequark/quark-core/errors` instead.
|
|
115
115
|
* Normalizes error messages for consistency
|
|
116
116
|
* @param {Error|string} error - Error to normalize
|
|
117
117
|
* @returns {string} Normalized error message
|