@owlmeans/payment 0.1.18-rc.14 → 0.1.18-rc.16
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 +5 -82
- package/agent-meta/manifest.json +2 -2
- package/agent-meta/skills/payment/SKILL.md +15 -11
- package/build/entitlement.d.ts +4 -3
- package/build/entitlement.d.ts.map +1 -1
- package/build/entitlement.js +6 -3
- package/build/entitlement.js.map +1 -1
- package/build/entrypoints.d.ts +6 -2
- package/build/entrypoints.d.ts.map +1 -1
- package/build/entrypoints.js +9 -9
- package/build/entrypoints.js.map +1 -1
- package/build/index.d.ts +0 -1
- package/build/index.d.ts.map +1 -1
- package/build/index.js +0 -1
- package/build/index.js.map +1 -1
- package/package.json +11 -11
- package/src/entitlement.ts +8 -5
- package/src/entrypoints.ts +13 -13
- package/src/index.ts +0 -1
- package/src/advertise.ts +0 -15
package/README.md
CHANGED
|
@@ -1,87 +1,10 @@
|
|
|
1
1
|
# @owlmeans/payment
|
|
2
2
|
|
|
3
|
-
Payment
|
|
3
|
+
Payment-domain services, schemas and shared checkout/subscription protocol declarations.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
- `appendPaymentService(context, alias?)` — registers the payment service in the context
|
|
9
|
-
- `PaymentService` — interface for products, plans, subscriptions, and checkout session creation
|
|
10
|
-
- `CreateCheckoutBody` / `CreateCheckoutResponse` — request/response types for checkout
|
|
11
|
-
|
|
12
|
-
## Installation
|
|
13
|
-
|
|
14
|
-
```bash
|
|
15
|
-
bun add @owlmeans/payment@^0.1.18-rc.12
|
|
16
|
-
```
|
|
17
|
-
|
|
18
|
-
## Usage
|
|
19
|
-
|
|
20
|
-
Create a checkout session:
|
|
21
|
-
|
|
22
|
-
```typescript
|
|
23
|
-
import type { CreateCheckoutBody, CreateCheckoutResponse } from '@owlmeans/payment'
|
|
24
|
-
|
|
25
|
-
const result = await ctx.entrypoint<ClientEntrypoint<CreateCheckoutResponse>>(
|
|
26
|
-
paymentApi.service.checkout.session.external.create
|
|
27
|
-
).call({
|
|
28
|
-
body: {
|
|
29
|
-
productSku: 'vib-tokens',
|
|
30
|
-
entityId,
|
|
31
|
-
service: VIB_ALIAS,
|
|
32
|
-
successUrl: helper.makeUrl(service)
|
|
33
|
-
} satisfies CreateCheckoutBody
|
|
34
|
-
})
|
|
35
|
-
window.open(result.url, '_blank')
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
Handle subscription propagation:
|
|
39
|
-
|
|
40
|
-
```typescript
|
|
41
|
-
import { SubscriptionPropagateBody, PlanDuration, SubscriptionStatus } from '@owlmeans/payment'
|
|
42
|
-
|
|
43
|
-
const handler = handleBody<SubscriptionPropagateBody>(async (body, context) => {
|
|
44
|
-
if (body.status === SubscriptionStatus.Consumable) {
|
|
45
|
-
const tokens = body.capabilities?.find(
|
|
46
|
-
c => c.scope === PlanDuration.Consumable
|
|
47
|
-
)?.permissions.units ?? 0
|
|
48
|
-
await ctx.agentToken().topUpTokens(entityId, tokens * 1000)
|
|
49
|
-
}
|
|
50
|
-
})
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
## API
|
|
54
|
-
|
|
55
|
-
### `makePaymentService(alias?): PaymentService`
|
|
56
|
-
|
|
57
|
-
Creates the payment service.
|
|
58
|
-
|
|
59
|
-
### `PaymentService`
|
|
60
|
-
|
|
61
|
-
- `product(sku): Promise<Product>` — get a product by SKU
|
|
62
|
-
- `products(): Promise<Product[]>` — list all products
|
|
63
|
-
- `plans(productSku, duration): Promise<ProductPlan[]>` — list plans for a product
|
|
64
|
-
- `plan(planSku): Promise<ProductPlan>` — get a plan by SKU
|
|
65
|
-
- `shallowAuthentication(token): Promise<string>` — shallow auth for payment flows
|
|
66
|
-
- `localize(lng, entity): Promise<Localization | null>` — get localized payment content
|
|
67
|
-
|
|
68
|
-
### Types
|
|
69
|
-
|
|
70
|
-
- `CreateCheckoutBody` — `{ productSku, entityId, service, successUrl?, cancelUrl? }`
|
|
71
|
-
- `CreateCheckoutResponse` — `{ url: string }`
|
|
72
|
-
- `SubscriptionPropagateBody` — extends `PlanSubscription`
|
|
73
|
-
- `PlanSubscription` — `{ sku, entityId, createdAt, status, capabilities? }`
|
|
74
|
-
|
|
75
|
-
### Enums
|
|
76
|
-
|
|
77
|
-
- `PlanDuration` — `Monthly`, `Yearly`, `Consumable`, etc.
|
|
78
|
-
- `SubscriptionStatus` — `Active`, `Consumable`, `Canceled`, etc.
|
|
79
|
-
- `ProductType` — product category enum
|
|
80
|
-
- `PaymentEntityType` — entity classification enum
|
|
81
|
-
|
|
82
|
-
## Related Packages
|
|
83
|
-
|
|
84
|
-
- [`@owlmeans/client-payment`](../client-payment) — client-side wrapper for browser contexts
|
|
5
|
+
Bind the exported protocol declarations in each runtime, then call the protocol reference from the
|
|
6
|
+
context. `entityId` in a billing payload is the stable organization entity record id; never send an
|
|
7
|
+
`entitySlug` as a billing relation.
|
|
85
8
|
|
|
86
9
|
<!-- owlmeans:agent-guidance:start -->
|
|
87
10
|
## Agent guidance
|
|
@@ -91,7 +14,7 @@ This package ships embedded agent skills under `agent-meta/`. After installing y
|
|
|
91
14
|
your project's skill store (`.agents/skills/`):
|
|
92
15
|
|
|
93
16
|
```sh
|
|
94
|
-
npx @owlmeans/agent-skills@^0.1.18-rc.
|
|
17
|
+
npx @owlmeans/agent-skills@^0.1.18-rc.15
|
|
95
18
|
```
|
|
96
19
|
|
|
97
20
|
The embedded files are version-matched to this package release. Do not edit them
|
package/agent-meta/manifest.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schemaVersion": 2,
|
|
3
3
|
"package": "@owlmeans/payment",
|
|
4
|
-
"version": "0.1.18-rc.
|
|
5
|
-
"generatedAt": "2026-09-
|
|
4
|
+
"version": "0.1.18-rc.16",
|
|
5
|
+
"generatedAt": "2026-09-12T08:39:52.735Z",
|
|
6
6
|
"canonicalRepo": "https://github.com/owlmeans/common",
|
|
7
7
|
"entries": [
|
|
8
8
|
{
|
|
@@ -8,7 +8,7 @@ user-invocable: false
|
|
|
8
8
|
# @owlmeans/payment
|
|
9
9
|
|
|
10
10
|
**Layer:** Core
|
|
11
|
-
**Install:** `"@owlmeans/payment": "^0.1.18-rc.
|
|
11
|
+
**Install:** `"@owlmeans/payment": "^0.1.18-rc.16"` in `dependencies`
|
|
12
12
|
|
|
13
13
|
The contracts half of payments: the catalogue (products, plans, localizations), the subscription
|
|
14
14
|
record, the entitlement grammar, and the entrypoint declarations both sides of a checkout share. It
|
|
@@ -72,8 +72,8 @@ is written as a string:
|
|
|
72
72
|
flag, however true, does not answer it.
|
|
73
73
|
- **A malformed parameter answers `false`, it never throws.** A gate that crashed on a typo would
|
|
74
74
|
take down the endpoint it guards, which is strictly worse than refusing the request.
|
|
75
|
-
- **Declare the requirement on the
|
|
76
|
-
`gate
|
|
75
|
+
- **Declare the requirement on the protocol, not in the handler.** `entitled(...)` is sugar over
|
|
76
|
+
the protocol's `gate: { alias: ENTITLEMENT_GATE, params }` option; the framework asserts a gate before the handler is entered, so
|
|
77
77
|
the route table states what a feature costs and no new endpoint can forget to check. Several
|
|
78
78
|
parameters are OR'd, as with every other gate.
|
|
79
79
|
- The gate service itself is not here — bind something under `ENTITLEMENT_GATE` in the server
|
|
@@ -82,9 +82,12 @@ is written as a string:
|
|
|
82
82
|
```typescript
|
|
83
83
|
import { entitled, hasEntitlement, entitlementList } from '@owlmeans/payment'
|
|
84
84
|
|
|
85
|
-
// On the
|
|
86
|
-
|
|
87
|
-
|
|
85
|
+
// On the protocol:
|
|
86
|
+
protocol(
|
|
87
|
+
route(MY_ROUTE, '/whitelabel', backend(BASE, RouteMethod.POST)),
|
|
88
|
+
contract(typed()),
|
|
89
|
+
{ gate: { alias: ENTITLEMENT_GATE, params: ['feature:branding--whitelabel'] } },
|
|
90
|
+
)
|
|
88
91
|
|
|
89
92
|
// In the UI, to render a control disabled rather than let it fail:
|
|
90
93
|
const allowed = hasEntitlement(capabilities, 'renewable:credits>=100')
|
|
@@ -95,19 +98,20 @@ const granted = entitlementList(capabilities)
|
|
|
95
98
|
## Checkout
|
|
96
99
|
|
|
97
100
|
Register `serviceEntrypoints` (and `entrypoints` where subscriptions are propagated back), then
|
|
98
|
-
|
|
99
|
-
error; `invoke`
|
|
101
|
+
bind the shared declaration in the caller runtime. `call` resolves to the response value itself and
|
|
102
|
+
throws the reply's error; `invoke` returns the value and outcome together.
|
|
100
103
|
|
|
101
104
|
```typescript
|
|
102
105
|
import { paymentApi, serviceEntrypoints } from '@owlmeans/payment'
|
|
103
106
|
import type { CreateCheckoutBody, CreateCheckoutResponse } from '@owlmeans/payment'
|
|
104
|
-
import
|
|
107
|
+
import { entrypointRef } from '@owlmeans/entrypoint'
|
|
105
108
|
|
|
106
109
|
export const appEntrypoints = [...myEntrypoints, ...serviceEntrypoints]
|
|
107
110
|
|
|
108
|
-
const
|
|
111
|
+
const checkout = entrypointRef<{ body: CreateCheckoutBody }, CreateCheckoutResponse>(
|
|
109
112
|
paymentApi.service.checkout.session.external.create
|
|
110
|
-
)
|
|
113
|
+
)
|
|
114
|
+
const result = await ctx.entrypoint(checkout).call({
|
|
111
115
|
body: { productSku, entityId, service, successUrl } satisfies CreateCheckoutBody
|
|
112
116
|
})
|
|
113
117
|
window.open(result.url, '_blank')
|
package/build/entitlement.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { EntrypointOptions } from '@owlmeans/entrypoint';
|
|
2
2
|
import type { PermissionSet } from '@owlmeans/auth';
|
|
3
3
|
/**
|
|
4
4
|
* The gate alias a paid capability is asserted under.
|
|
@@ -49,12 +49,13 @@ export declare const entitlementList: (capabilities: PermissionSet[] | undefined
|
|
|
49
49
|
/**
|
|
50
50
|
* Declare that an entrypoint needs a paid capability.
|
|
51
51
|
*
|
|
52
|
-
*
|
|
52
|
+
* Compatibility sugar over the protocol option
|
|
53
|
+
* `{ gate: { alias: ENTITLEMENT_GATE, params } }` so a route reads as what it means. Several
|
|
53
54
|
* parameters are OR'd, matching every other gate in the framework.
|
|
54
55
|
*
|
|
55
56
|
* Putting the requirement HERE rather than in a handler is the point: the framework asserts a gate
|
|
56
57
|
* before the handler is entered, so the route table states what a feature costs and no new
|
|
57
58
|
* endpoint can forget to check.
|
|
58
59
|
*/
|
|
59
|
-
export declare const entitled: (params: string | string[], opts?:
|
|
60
|
+
export declare const entitled: (params: string | string[], opts?: EntrypointOptions) => EntrypointOptions;
|
|
60
61
|
//# sourceMappingURL=entitlement.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entitlement.d.ts","sourceRoot":"","sources":["../src/entitlement.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"entitlement.d.ts","sourceRoot":"","sources":["../src/entitlement.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AAC7D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAEnD;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,qBAAqB,CAAA;AAElD;;;;;;GAMG;AACH,eAAO,MAAM,wBAAwB,YAAY,CAAA;AAEjD,MAAM,WAAW,gBAAgB;IAC/B,gDAAgD;IAChD,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,6DAA6D;IAC7D,UAAU,EAAE,MAAM,CAAA;IAClB,8FAA8F;IAC9F,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,qBAAqB,UAAW,MAAM,KAAG,gBAerD,CAAA;AAED,eAAO,MAAM,sBAAsB,WAAY,gBAAgB,KAAG,MAER,CAAA;AAE1D;;;;;;;;;GASG;AACH,eAAO,MAAM,cAAc,iBACX,aAAa,EAAE,GAAG,SAAS,SAAS,MAAM,KACvD,OAqBF,CAAA;AAED,kGAAkG;AAClG,eAAO,MAAM,eAAe,iBAAkB,aAAa,EAAE,GAAG,SAAS,KAAG,MAAM,EAYjF,CAAA;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,QAAQ,WACX,MAAM,GAAG,MAAM,EAAE,SAAS,iBAAiB,KAClD,iBAGD,CAAA"}
|
package/build/entitlement.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { gate } from '@owlmeans/entrypoint';
|
|
2
1
|
/**
|
|
3
2
|
* The gate alias a paid capability is asserted under.
|
|
4
3
|
*
|
|
@@ -84,12 +83,16 @@ export const entitlementList = (capabilities) => {
|
|
|
84
83
|
/**
|
|
85
84
|
* Declare that an entrypoint needs a paid capability.
|
|
86
85
|
*
|
|
87
|
-
*
|
|
86
|
+
* Compatibility sugar over the protocol option
|
|
87
|
+
* `{ gate: { alias: ENTITLEMENT_GATE, params } }` so a route reads as what it means. Several
|
|
88
88
|
* parameters are OR'd, matching every other gate in the framework.
|
|
89
89
|
*
|
|
90
90
|
* Putting the requirement HERE rather than in a handler is the point: the framework asserts a gate
|
|
91
91
|
* before the handler is entered, so the route table states what a feature costs and no new
|
|
92
92
|
* endpoint can forget to check.
|
|
93
93
|
*/
|
|
94
|
-
export const entitled = (params, opts) =>
|
|
94
|
+
export const entitled = (params, opts) => ({
|
|
95
|
+
...opts,
|
|
96
|
+
gate: { alias: ENTITLEMENT_GATE, params },
|
|
97
|
+
});
|
|
95
98
|
//# sourceMappingURL=entitlement.js.map
|
package/build/entitlement.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entitlement.js","sourceRoot":"","sources":["../src/entitlement.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"entitlement.js","sourceRoot":"","sources":["../src/entitlement.ts"],"names":[],"mappings":"AAGA;;;;;GAKG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,kBAAkB,CAAA;AAElD;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,SAAS,CAAA;AAWjD;;;;;;;GAO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UAAU,EAAE,CAAC,CAAC,CAAA;QACrE,CAAC;IACH,CAAC;IAED,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,CAAC,CAAA;AAC3B,CAAC,CAAA;AAED;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,CACtB,MAAyB,EAAE,IAAwB,EAChC,EAAE,CAAC,CAAC;IACvB,GAAG,IAAI;IACP,IAAI,EAAE,EAAE,KAAK,EAAE,gBAAgB,EAAE,MAAM,EAAE;CAC1C,CAAC,CAAA"}
|
package/build/entrypoints.d.ts
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
-
export declare const entrypoints: import("@owlmeans/entrypoint").
|
|
2
|
-
|
|
1
|
+
export declare const entrypoints: (import("@owlmeans/entrypoint").EntrypointProtocol<import("@owlmeans/entrypoint").OpenRequest, import("@owlmeans/entrypoint").OpenValue> | import("@owlmeans/entrypoint").EntrypointProtocol<{
|
|
2
|
+
body: import("./types.js").SubscriptionPropagateBody | import("@owlmeans/entrypoint").OpenValue;
|
|
3
|
+
}, undefined>)[];
|
|
4
|
+
export declare const serviceEntrypoints: (import("@owlmeans/entrypoint").EntrypointProtocol<import("@owlmeans/entrypoint").OpenRequest, import("@owlmeans/entrypoint").OpenValue> | import("@owlmeans/entrypoint").EntrypointProtocol<{
|
|
5
|
+
body: import("./types.js").CreateCheckoutBody | import("@owlmeans/entrypoint").OpenValue;
|
|
6
|
+
}, undefined>)[];
|
|
3
7
|
//# sourceMappingURL=entrypoints.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entrypoints.d.ts","sourceRoot":"","sources":["../src/entrypoints.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"entrypoints.d.ts","sourceRoot":"","sources":["../src/entrypoints.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,WAAW;;gBAgBvB,CAAA;AAED,eAAO,MAAM,kBAAkB;;gBAkB9B,CAAA"}
|
package/build/entrypoints.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { contract, openProtocol, protocol, typed } from '@owlmeans/entrypoint';
|
|
2
2
|
import { route, backend, RouteMethod } from '@owlmeans/route';
|
|
3
3
|
import { paymentApi } from './consts.js';
|
|
4
4
|
import { SubscriptionPropagateBodySchema } from './model/subscription.js';
|
|
5
5
|
import { CreateCheckoutBodySchema } from './model/checkout.js';
|
|
6
6
|
export const entrypoints = [
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
openProtocol(route(paymentApi.subscription.base, '/subscription', backend())),
|
|
8
|
+
protocol(route(paymentApi.subscription.propogate, '/propogate', backend(paymentApi.subscription.base, RouteMethod.POST)), contract.request({ body: SubscriptionPropagateBodySchema }, typed())),
|
|
9
|
+
protocol(route(paymentApi.subscription.propagate, '/propagate', backend(paymentApi.subscription.base, RouteMethod.POST)), contract.request({ body: SubscriptionPropagateBodySchema }, typed()))
|
|
10
10
|
];
|
|
11
11
|
export const serviceEntrypoints = [
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
openProtocol(route(paymentApi.service.base, '/payment-service', backend())),
|
|
13
|
+
openProtocol(route(paymentApi.service.checkout.base, '/checkout', backend(paymentApi.service.base))),
|
|
14
|
+
openProtocol(route(paymentApi.service.checkout.session.base, '/session', backend(paymentApi.service.checkout.base))),
|
|
15
|
+
openProtocol(route(paymentApi.service.checkout.session.external.base, '/external', backend(paymentApi.service.checkout.session.base))),
|
|
16
|
+
protocol(route(paymentApi.service.checkout.session.external.create, '/create', backend(paymentApi.service.checkout.session.external.base, RouteMethod.POST)), contract.request({ body: CreateCheckoutBodySchema }, typed()))
|
|
17
17
|
];
|
|
18
18
|
//# sourceMappingURL=entrypoints.js.map
|
package/build/entrypoints.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entrypoints.js","sourceRoot":"","sources":["../src/entrypoints.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"entrypoints.js","sourceRoot":"","sources":["../src/entrypoints.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAA;AAC9E,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,EAAE,+BAA+B,EAAE,MAAM,yBAAyB,CAAA;AACzE,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAA;AAE9D,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,YAAY,CAAC,KAAK,CAAC,UAAU,CAAC,YAAY,CAAC,IAAI,EAAE,eAAe,EAAE,OAAO,EAAE,CAAC,CAAC;IAC7E,QAAQ,CACN,KAAK,CAAC,UAAU,CAAC,YAAY,CAAC,SAAS,EAAE,YAAY,EAAE,OAAO,CAC5D,UAAU,CAAC,YAAY,CAAC,IAAI,EAC5B,WAAW,CAAC,IAAI,CACjB,CAAC,EACF,QAAQ,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,+BAA+B,EAAE,EAAE,KAAK,EAAE,CAAC,CACrE;IACD,QAAQ,CACN,KAAK,CAAC,UAAU,CAAC,YAAY,CAAC,SAAS,EAAE,YAAY,EAAE,OAAO,CAC5D,UAAU,CAAC,YAAY,CAAC,IAAI,EAC5B,WAAW,CAAC,IAAI,CACjB,CAAC,EACF,QAAQ,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,+BAA+B,EAAE,EAAE,KAAK,EAAE,CAAC,CACrE;CACF,CAAA;AAED,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,YAAY,CAAC,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,EAAE,kBAA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a,CAAA;AAC3B,cAAc,kBAAkB,CAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,mBAAmB,YAAY,CAAA;AAC/B,cAAc,kBAAkB,CAAA;AAChC,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,kBAAkB,CAAA;AAChC,cAAc,cAAc,CAAA;AAC5B,cAAc,WAAW,CAAA;AACzB,cAAc,aAAa,CAAA;AAC3B,cAAc,kBAAkB,CAAA"}
|
package/build/index.js
CHANGED
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,cAAc,kBAAkB,CAAA;AAChC,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,kBAAkB,CAAA;AAChC,cAAc,cAAc,CAAA;AAC5B,cAAc,WAAW,CAAA;AACzB,cAAc,aAAa,CAAA;AAC3B,cAAc,kBAAkB,CAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,cAAc,kBAAkB,CAAA;AAChC,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,kBAAkB,CAAA;AAChC,cAAc,cAAc,CAAA;AAC5B,cAAc,WAAW,CAAA;AACzB,cAAc,aAAa,CAAA;AAC3B,cAAc,kBAAkB,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@owlmeans/payment",
|
|
3
|
-
"version": "0.1.18-rc.
|
|
3
|
+
"version": "0.1.18-rc.16",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
@@ -31,16 +31,16 @@
|
|
|
31
31
|
"ajv": "*"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@owlmeans/api-config": "^0.1.18-rc.
|
|
35
|
-
"@owlmeans/auth": "^0.1.18-rc.
|
|
36
|
-
"@owlmeans/basic-envelope": "^0.1.18-rc.
|
|
37
|
-
"@owlmeans/config": "^0.1.18-rc.
|
|
38
|
-
"@owlmeans/context": "^0.1.18-rc.
|
|
39
|
-
"@owlmeans/error": "^0.1.18-rc.
|
|
40
|
-
"@owlmeans/i18n": "^0.1.18-rc.
|
|
41
|
-
"@owlmeans/entrypoint": "^0.1.18-rc.
|
|
42
|
-
"@owlmeans/resource": "^0.1.18-rc.
|
|
43
|
-
"@owlmeans/route": "^0.1.18-rc.
|
|
34
|
+
"@owlmeans/api-config": "^0.1.18-rc.15",
|
|
35
|
+
"@owlmeans/auth": "^0.1.18-rc.12",
|
|
36
|
+
"@owlmeans/basic-envelope": "^0.1.18-rc.15",
|
|
37
|
+
"@owlmeans/config": "^0.1.18-rc.15",
|
|
38
|
+
"@owlmeans/context": "^0.1.18-rc.11",
|
|
39
|
+
"@owlmeans/error": "^0.1.18-rc.11",
|
|
40
|
+
"@owlmeans/i18n": "^0.1.18-rc.11",
|
|
41
|
+
"@owlmeans/entrypoint": "^0.1.18-rc.14",
|
|
42
|
+
"@owlmeans/resource": "^0.1.18-rc.12",
|
|
43
|
+
"@owlmeans/route": "^0.1.18-rc.12"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@owlmeans/dep-config": "workspace:*",
|
package/src/entitlement.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type { CommonEntrypointOptions } from '@owlmeans/entrypoint'
|
|
1
|
+
import type { EntrypointOptions } from '@owlmeans/entrypoint'
|
|
3
2
|
import type { PermissionSet } from '@owlmeans/auth'
|
|
4
3
|
|
|
5
4
|
/**
|
|
@@ -110,7 +109,8 @@ export const entitlementList = (capabilities: PermissionSet[] | undefined): stri
|
|
|
110
109
|
/**
|
|
111
110
|
* Declare that an entrypoint needs a paid capability.
|
|
112
111
|
*
|
|
113
|
-
*
|
|
112
|
+
* Compatibility sugar over the protocol option
|
|
113
|
+
* `{ gate: { alias: ENTITLEMENT_GATE, params } }` so a route reads as what it means. Several
|
|
114
114
|
* parameters are OR'd, matching every other gate in the framework.
|
|
115
115
|
*
|
|
116
116
|
* Putting the requirement HERE rather than in a handler is the point: the framework asserts a gate
|
|
@@ -118,5 +118,8 @@ export const entitlementList = (capabilities: PermissionSet[] | undefined): stri
|
|
|
118
118
|
* endpoint can forget to check.
|
|
119
119
|
*/
|
|
120
120
|
export const entitled = (
|
|
121
|
-
params: string | string[], opts?:
|
|
122
|
-
):
|
|
121
|
+
params: string | string[], opts?: EntrypointOptions,
|
|
122
|
+
): EntrypointOptions => ({
|
|
123
|
+
...opts,
|
|
124
|
+
gate: { alias: ENTITLEMENT_GATE, params },
|
|
125
|
+
})
|
package/src/entrypoints.ts
CHANGED
|
@@ -1,43 +1,43 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { contract, openProtocol, protocol, typed } from '@owlmeans/entrypoint'
|
|
2
2
|
import { route, backend, RouteMethod } from '@owlmeans/route'
|
|
3
3
|
import { paymentApi } from './consts.js'
|
|
4
4
|
import { SubscriptionPropagateBodySchema } from './model/subscription.js'
|
|
5
5
|
import { CreateCheckoutBodySchema } from './model/checkout.js'
|
|
6
6
|
|
|
7
7
|
export const entrypoints = [
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
openProtocol(route(paymentApi.subscription.base, '/subscription', backend())),
|
|
9
|
+
protocol(
|
|
10
10
|
route(paymentApi.subscription.propogate, '/propogate', backend(
|
|
11
11
|
paymentApi.subscription.base,
|
|
12
12
|
RouteMethod.POST
|
|
13
13
|
)),
|
|
14
|
-
|
|
14
|
+
contract.request({ body: SubscriptionPropagateBodySchema }, typed())
|
|
15
15
|
),
|
|
16
|
-
|
|
16
|
+
protocol(
|
|
17
17
|
route(paymentApi.subscription.propagate, '/propagate', backend(
|
|
18
18
|
paymentApi.subscription.base,
|
|
19
19
|
RouteMethod.POST
|
|
20
20
|
)),
|
|
21
|
-
|
|
21
|
+
contract.request({ body: SubscriptionPropagateBodySchema }, typed())
|
|
22
22
|
)
|
|
23
23
|
]
|
|
24
24
|
|
|
25
25
|
export const serviceEntrypoints = [
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
openProtocol(route(paymentApi.service.base, '/payment-service', backend())),
|
|
27
|
+
openProtocol(
|
|
28
28
|
route(paymentApi.service.checkout.base, '/checkout', backend(paymentApi.service.base)),
|
|
29
29
|
),
|
|
30
|
-
|
|
30
|
+
openProtocol(
|
|
31
31
|
route(paymentApi.service.checkout.session.base, '/session', backend(paymentApi.service.checkout.base)),
|
|
32
32
|
),
|
|
33
|
-
|
|
33
|
+
openProtocol(
|
|
34
34
|
route(paymentApi.service.checkout.session.external.base, '/external', backend(paymentApi.service.checkout.session.base)),
|
|
35
35
|
),
|
|
36
|
-
|
|
36
|
+
protocol(
|
|
37
37
|
route(paymentApi.service.checkout.session.external.create, '/create', backend(
|
|
38
38
|
paymentApi.service.checkout.session.external.base,
|
|
39
39
|
RouteMethod.POST
|
|
40
40
|
)),
|
|
41
|
-
|
|
41
|
+
contract.request({ body: CreateCheckoutBodySchema }, typed())
|
|
42
42
|
)
|
|
43
|
-
]
|
|
43
|
+
]
|
package/src/index.ts
CHANGED
package/src/advertise.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { CONFIG_RECORD } from '@owlmeans/context'
|
|
2
|
-
import { apiConfigPlugin, every } from '@owlmeans/api-config'
|
|
3
|
-
import { L10N_RECORD_TYPE, PLAN_RECORD_TYPE, PRODUCT_RECORD_TYPE } from './consts.js'
|
|
4
|
-
|
|
5
|
-
const advertisedRecordTypes = new Set([L10N_RECORD_TYPE, PLAN_RECORD_TYPE, PRODUCT_RECORD_TYPE])
|
|
6
|
-
|
|
7
|
-
apiConfigPlugin({
|
|
8
|
-
allow: {
|
|
9
|
-
[CONFIG_RECORD]: every(
|
|
10
|
-
true,
|
|
11
|
-
value => value != null && typeof value === 'object'
|
|
12
|
-
&& advertisedRecordTypes.has((value as { recordType?: string }).recordType ?? '')
|
|
13
|
-
),
|
|
14
|
-
},
|
|
15
|
-
})
|