@deltablab/next 0.1.0 → 0.1.1

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/dist/index.d.ts CHANGED
@@ -3,7 +3,8 @@ import { PaygatePipelineConnectOptions } from '@deltablab/publisher-core';
3
3
  export { GatewayPipelineOptions, PaygatePipelineConnectOptions } from '@deltablab/publisher-core';
4
4
 
5
5
  interface PaygateNextCloudOptions {
6
- baseUrl: string;
6
+ /** Optional. Defaults to https://paygate.deltab.ai */
7
+ baseUrl?: string;
7
8
  apiKey: string;
8
9
  }
9
10
  /**
package/dist/index.js CHANGED
@@ -6,9 +6,15 @@ import {
6
6
  paygateResultToWebResponse
7
7
  } from "@deltablab/publisher-core";
8
8
  import { PublisherCloudClient } from "@deltablab/publisher-cloud";
9
+ var DEFAULT_PAYGATE_BASE_URL = "https://paygate.deltab.ai";
10
+ function resolveBaseUrl(baseUrl) {
11
+ const normalized = baseUrl?.trim().replace(/\/+$/, "");
12
+ return normalized && normalized.length > 0 ? normalized : DEFAULT_PAYGATE_BASE_URL;
13
+ }
9
14
  function createAppRouterHandler(options) {
15
+ const baseUrl = resolveBaseUrl(options.baseUrl);
10
16
  const publisherCloud = new PublisherCloudClient({
11
- baseUrl: options.baseUrl,
17
+ baseUrl,
12
18
  apiKey: options.apiKey
13
19
  });
14
20
  const pipeline = createGatewayPipelineForPaidRoute(options, options.endpointId, publisherCloud);
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { NextRequest, NextResponse } from \"next/server\";\nimport type {\n GatewayPipelineOptions,\n PaygatePipelineConnectOptions,\n} from \"@deltablab/publisher-core\";\nimport {\n createGatewayPipelineForPaidRoute,\n incomingFromWebRequest,\n paygateResultToWebResponse,\n} from \"@deltablab/publisher-core\";\nimport { PublisherCloudClient } from \"@deltablab/publisher-cloud\";\n\nexport interface PaygateNextCloudOptions {\n baseUrl: string;\n apiKey: string;\n}\n\n/**\n * Connection options used by `createPaygateNextAppRouter`.\n * Declared as interface (not type alias) to preserve declaration-merging compatibility.\n */\nexport interface CreatePaygateNextOptions\n extends PaygateNextCloudOptions,\n PaygatePipelineConnectOptions {}\n\n/** Route-local options used by `createPaygateNextAppRouter(...)(route)`. */\nexport interface PaygateNextRouteOptions {\n endpointId: string;\n}\n\n/**\n * Options for one paid route.\n * Declared as interface (not type alias) to preserve declaration-merging compatibility.\n */\nexport interface PaygateNextOptions\n extends CreatePaygateNextOptions,\n PaygateNextRouteOptions {}\n\n/** Use in App Router `route.ts`: if `proceed` is false, return `response` immediately. */\nexport type PaygateAppRouterResult =\n | { proceed: true }\n | { proceed: false; response: NextResponse };\n\nexport type PaygateAppRouterHandler = (\n req: NextRequest\n) => Promise<PaygateAppRouterResult>;\n\nfunction createAppRouterHandler(options: PaygateNextOptions): PaygateAppRouterHandler {\n const publisherCloud = new PublisherCloudClient({\n baseUrl: options.baseUrl,\n apiKey: options.apiKey,\n });\n\n const pipeline = createGatewayPipelineForPaidRoute(options, options.endpointId, publisherCloud);\n\n return async function handlePaygate(req: NextRequest): Promise<PaygateAppRouterResult> {\n const result = await pipeline.handle(incomingFromWebRequest(req));\n\n if (result.kind === \"next\") {\n return { proceed: true };\n }\n\n const wr = paygateResultToWebResponse(result);\n return {\n proceed: false,\n response: new NextResponse(wr.body, { status: wr.status, headers: wr.headers }),\n };\n };\n}\n\n/**\n * Build a reusable App Router handler (same lifecycle as `paygateExpress()` — one\n * `GatewayPipeline` per factory call).\n *\n * On `proceed: true`, continue your route logic without consuming the request body,\n * so `req.json()` still works afterward on POST routes.\n */\nexport function paygateNextAppRouter(options: PaygateNextOptions): PaygateAppRouterHandler {\n return createAppRouterHandler(options);\n}\n\nexport function createPaygateNextAppRouter(\n options: CreatePaygateNextOptions,\n): (route: PaygateNextRouteOptions) => PaygateAppRouterHandler {\n return ({ endpointId }: PaygateNextRouteOptions) =>\n createAppRouterHandler({ ...options, endpointId });\n}\n\nexport type { GatewayPipelineOptions, PaygatePipelineConnectOptions };\n"],"mappings":";AAAA,SAAsB,oBAAoB;AAK1C;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,4BAA4B;AAqCrC,SAAS,uBAAuB,SAAsD;AACpF,QAAM,iBAAiB,IAAI,qBAAqB;AAAA,IAC9C,SAAS,QAAQ;AAAA,IACjB,QAAQ,QAAQ;AAAA,EAClB,CAAC;AAED,QAAM,WAAW,kCAAkC,SAAS,QAAQ,YAAY,cAAc;AAE9F,SAAO,eAAe,cAAc,KAAmD;AACrF,UAAM,SAAS,MAAM,SAAS,OAAO,uBAAuB,GAAG,CAAC;AAEhE,QAAI,OAAO,SAAS,QAAQ;AAC1B,aAAO,EAAE,SAAS,KAAK;AAAA,IACzB;AAEA,UAAM,KAAK,2BAA2B,MAAM;AAC5C,WAAO;AAAA,MACL,SAAS;AAAA,MACT,UAAU,IAAI,aAAa,GAAG,MAAM,EAAE,QAAQ,GAAG,QAAQ,SAAS,GAAG,QAAQ,CAAC;AAAA,IAChF;AAAA,EACF;AACF;AASO,SAAS,qBAAqB,SAAsD;AACzF,SAAO,uBAAuB,OAAO;AACvC;AAEO,SAAS,2BACd,SAC6D;AAC7D,SAAO,CAAC,EAAE,WAAW,MACnB,uBAAuB,EAAE,GAAG,SAAS,WAAW,CAAC;AACrD;","names":[]}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { NextRequest, NextResponse } from \"next/server\";\nimport type {\n GatewayPipelineOptions,\n PaygatePipelineConnectOptions,\n} from \"@deltablab/publisher-core\";\nimport {\n createGatewayPipelineForPaidRoute,\n incomingFromWebRequest,\n paygateResultToWebResponse,\n} from \"@deltablab/publisher-core\";\nimport { PublisherCloudClient } from \"@deltablab/publisher-cloud\";\n\nconst DEFAULT_PAYGATE_BASE_URL = \"https://paygate.deltab.ai\";\n\nexport interface PaygateNextCloudOptions {\n /** Optional. Defaults to https://paygate.deltab.ai */\n baseUrl?: string;\n apiKey: string;\n}\n\n/**\n * Connection options used by `createPaygateNextAppRouter`.\n * Declared as interface (not type alias) to preserve declaration-merging compatibility.\n */\nexport interface CreatePaygateNextOptions\n extends PaygateNextCloudOptions,\n PaygatePipelineConnectOptions {}\n\n/** Route-local options used by `createPaygateNextAppRouter(...)(route)`. */\nexport interface PaygateNextRouteOptions {\n endpointId: string;\n}\n\n/**\n * Options for one paid route.\n * Declared as interface (not type alias) to preserve declaration-merging compatibility.\n */\nexport interface PaygateNextOptions\n extends CreatePaygateNextOptions,\n PaygateNextRouteOptions {}\n\n/** Use in App Router `route.ts`: if `proceed` is false, return `response` immediately. */\nexport type PaygateAppRouterResult =\n | { proceed: true }\n | { proceed: false; response: NextResponse };\n\nexport type PaygateAppRouterHandler = (\n req: NextRequest\n) => Promise<PaygateAppRouterResult>;\n\nfunction resolveBaseUrl(baseUrl?: string): string {\n const normalized = baseUrl?.trim().replace(/\\/+$/, \"\");\n return normalized && normalized.length > 0 ? normalized : DEFAULT_PAYGATE_BASE_URL;\n}\n\nfunction createAppRouterHandler(options: PaygateNextOptions): PaygateAppRouterHandler {\n const baseUrl = resolveBaseUrl(options.baseUrl);\n const publisherCloud = new PublisherCloudClient({\n baseUrl,\n apiKey: options.apiKey,\n });\n\n const pipeline = createGatewayPipelineForPaidRoute(options, options.endpointId, publisherCloud);\n\n return async function handlePaygate(req: NextRequest): Promise<PaygateAppRouterResult> {\n const result = await pipeline.handle(incomingFromWebRequest(req));\n\n if (result.kind === \"next\") {\n return { proceed: true };\n }\n\n const wr = paygateResultToWebResponse(result);\n return {\n proceed: false,\n response: new NextResponse(wr.body, { status: wr.status, headers: wr.headers }),\n };\n };\n}\n\n/**\n * Build a reusable App Router handler (same lifecycle as `paygateExpress()` — one\n * `GatewayPipeline` per factory call).\n *\n * On `proceed: true`, continue your route logic without consuming the request body,\n * so `req.json()` still works afterward on POST routes.\n */\nexport function paygateNextAppRouter(options: PaygateNextOptions): PaygateAppRouterHandler {\n return createAppRouterHandler(options);\n}\n\nexport function createPaygateNextAppRouter(\n options: CreatePaygateNextOptions,\n): (route: PaygateNextRouteOptions) => PaygateAppRouterHandler {\n return ({ endpointId }: PaygateNextRouteOptions) =>\n createAppRouterHandler({ ...options, endpointId });\n}\n\nexport type { GatewayPipelineOptions, PaygatePipelineConnectOptions };\n"],"mappings":";AAAA,SAAsB,oBAAoB;AAK1C;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,4BAA4B;AAErC,IAAM,2BAA2B;AAsCjC,SAAS,eAAe,SAA0B;AAChD,QAAM,aAAa,SAAS,KAAK,EAAE,QAAQ,QAAQ,EAAE;AACrD,SAAO,cAAc,WAAW,SAAS,IAAI,aAAa;AAC5D;AAEA,SAAS,uBAAuB,SAAsD;AACpF,QAAM,UAAU,eAAe,QAAQ,OAAO;AAC9C,QAAM,iBAAiB,IAAI,qBAAqB;AAAA,IAC9C;AAAA,IACA,QAAQ,QAAQ;AAAA,EAClB,CAAC;AAED,QAAM,WAAW,kCAAkC,SAAS,QAAQ,YAAY,cAAc;AAE9F,SAAO,eAAe,cAAc,KAAmD;AACrF,UAAM,SAAS,MAAM,SAAS,OAAO,uBAAuB,GAAG,CAAC;AAEhE,QAAI,OAAO,SAAS,QAAQ;AAC1B,aAAO,EAAE,SAAS,KAAK;AAAA,IACzB;AAEA,UAAM,KAAK,2BAA2B,MAAM;AAC5C,WAAO;AAAA,MACL,SAAS;AAAA,MACT,UAAU,IAAI,aAAa,GAAG,MAAM,EAAE,QAAQ,GAAG,QAAQ,SAAS,GAAG,QAAQ,CAAC;AAAA,IAChF;AAAA,EACF;AACF;AASO,SAAS,qBAAqB,SAAsD;AACzF,SAAO,uBAAuB,OAAO;AACvC;AAEO,SAAS,2BACd,SAC6D;AAC7D,SAAO,CAAC,EAAE,WAAW,MACnB,uBAAuB,EAAE,GAAG,SAAS,WAAW,CAAC;AACrD;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deltablab/next",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Next.js App Router helper wiring PayGate GatewayPipeline to route handlers.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -28,10 +28,16 @@
28
28
  },
29
29
  "main": "./dist/index.js",
30
30
  "types": "./dist/index.d.ts",
31
+ "scripts": {
32
+ "build": "tsup",
33
+ "prepublishOnly": "pnpm run build",
34
+ "test": "vitest run",
35
+ "test:watch": "vitest"
36
+ },
31
37
  "dependencies": {
32
- "@deltablab/protocol": "0.1.0",
33
- "@deltablab/publisher-cloud": "0.1.0",
34
- "@deltablab/publisher-core": "0.1.0"
38
+ "@deltablab/protocol": "workspace:*",
39
+ "@deltablab/publisher-core": "workspace:*",
40
+ "@deltablab/publisher-cloud": "workspace:*"
35
41
  },
36
42
  "peerDependencies": {
37
43
  "next": "^14.0.0 || ^15.0.0"
@@ -41,10 +47,5 @@
41
47
  "tsup": "^8.4.0",
42
48
  "typescript": "^5.7.0",
43
49
  "vitest": "^3.1.0"
44
- },
45
- "scripts": {
46
- "build": "tsup",
47
- "test": "vitest run",
48
- "test:watch": "vitest"
49
50
  }
50
- }
51
+ }
package/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 PayGate 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.