@jskit-ai/payments-core 0.2.3 → 0.2.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/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
- `PAYMENT_STORE_FEATURE` is no longer exported from `PaymentStoreFeature.js` (no public entry point offered it): the feature's id is written as `"payments.store"`, so `jskit check` sees a module that requires that capability where it names it.
|
|
6
|
+
- payment_entries declares its foreign key, account_key to payment_accounts.account_key (`foreignKeys`), so json-rest-api 3.1.0 can skip the visibility query a system-context read makes for a record such a key guarantees exists. `jskit test --databases` checks each against an app's test database. `paymentStore.mysql.test.js` proves it matches the migration on MariaDB.
|
|
5
7
|
- `@jskit-ai/database-runtime` and `@jskit-ai/resource-runtime` are optional peer dependencies, as they are of assistant-runtime, instead of dependencies: an app without a database installs, composes and starts the package without them, where installing them made boot refuse it for want of a database driver. An app that uses its payment store has them through its database.
|
|
6
8
|
- On json-rest-api 3.0.0's release candidate, an account's changed state is written with one read of the locked row before its UPDATE, where it took two.
|
|
7
9
|
- The payment store locks or creates each account and catalogue row with its handle's `lockOrCreate`, in place of a helper of its own with the same behaviour.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jskit-ai/payments-core",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Application-owned payment configuration, subscription access and transactional usage credits.",
|
|
6
6
|
"exports": {
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"test": "jskit test"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@jskit-ai/resource-core": "0.1.
|
|
26
|
+
"@jskit-ai/resource-core": "0.1.206",
|
|
27
27
|
"@paddle/paddle-node-sdk": "3.10.0",
|
|
28
28
|
"ajv": "8.20.0",
|
|
29
29
|
"stripe": "22.6.2"
|
|
@@ -69,9 +69,9 @@
|
|
|
69
69
|
}
|
|
70
70
|
},
|
|
71
71
|
"peerDependencies": {
|
|
72
|
-
"@jskit-ai/database-runtime": "0.1.
|
|
73
|
-
"@jskit-ai/kernel": "0.2.
|
|
74
|
-
"@jskit-ai/resource-runtime": "0.2.
|
|
72
|
+
"@jskit-ai/database-runtime": "0.1.264",
|
|
73
|
+
"@jskit-ai/kernel": "0.2.15",
|
|
74
|
+
"@jskit-ai/resource-runtime": "0.2.13"
|
|
75
75
|
},
|
|
76
76
|
"peerDependenciesMeta": {
|
|
77
77
|
"@jskit-ai/database-runtime": {
|
|
@@ -2,13 +2,14 @@ import { defineFeature } from "@jskit-ai/kernel/server/features";
|
|
|
2
2
|
import { PAYMENT_TABLES } from "./paymentResources.js";
|
|
3
3
|
import { createPaymentStore } from "./paymentStore.js";
|
|
4
4
|
|
|
5
|
-
const PAYMENT_STORE_FEATURE = "payments.store";
|
|
6
5
|
const PAYMENT_STORE_SYSTEM_SCOPE = "payment rows are keyed by their merchant and billable subject, which is their scope, not by a workspace or user";
|
|
7
6
|
|
|
8
7
|
// The owner of the payment tables in a JSKIT application: it provides the payment store on their handles as
|
|
9
8
|
// `payments.store`. An application that keeps payments elsewhere passes its own store and leaves this feature out.
|
|
10
9
|
const PaymentStoreFeature = defineFeature({
|
|
11
|
-
id:
|
|
10
|
+
// The id is written out, not exported as a constant: `jskit check` sees a module that requires payments.store only
|
|
11
|
+
// where it names it.
|
|
12
|
+
id: "payments.store",
|
|
12
13
|
domain: "payments",
|
|
13
14
|
owns: PAYMENT_TABLES,
|
|
14
15
|
systemScope: PAYMENT_STORE_SYSTEM_SCOPE,
|
|
@@ -25,4 +26,4 @@ const PaymentStoreFeature = defineFeature({
|
|
|
25
26
|
}
|
|
26
27
|
});
|
|
27
28
|
|
|
28
|
-
export {
|
|
29
|
+
export { PAYMENT_STORE_SYSTEM_SCOPE, PaymentStoreFeature };
|
|
@@ -26,6 +26,7 @@ const paymentEntryResource = defineTableResource({
|
|
|
26
26
|
name: "paymentEntries",
|
|
27
27
|
tableName: "payment_entries",
|
|
28
28
|
ownership: "public",
|
|
29
|
+
foreignKeys: [{ columns: ["accountKey"], referencedTableName: "payment_accounts", referencedColumns: ["account_key"] }],
|
|
29
30
|
idProperty: "entry_key",
|
|
30
31
|
schema: {
|
|
31
32
|
id: key("entry_key"),
|
|
@@ -5,6 +5,8 @@ import { requireTestDatabase } from "@jskit-ai/database-runtime/server/testDatab
|
|
|
5
5
|
import migration from "../migrations/payments_core_initial.cjs";
|
|
6
6
|
import { createPaymentService } from "../src/server/service.js";
|
|
7
7
|
import { validatePaymentConfiguration } from "../src/shared/configuration.js";
|
|
8
|
+
import { checkForeignKeys } from "@jskit-ai/resource-runtime/server";
|
|
9
|
+
import { PAYMENT_TABLES } from "../src/server/paymentResources.js";
|
|
8
10
|
import { createTestPaymentStore } from "./support/paymentStore.js";
|
|
9
11
|
|
|
10
12
|
// The payment store's behaviour on MariaDB, through its public functions, as PaymentStoreFeature provides it: what an
|
|
@@ -53,6 +55,14 @@ function gate() {
|
|
|
53
55
|
return { opened, open };
|
|
54
56
|
}
|
|
55
57
|
|
|
58
|
+
test("the payment table resources declare exactly the foreign keys the migration creates", async (context) => {
|
|
59
|
+
requireTestDatabase(process.env);
|
|
60
|
+
const knex = await ownDatabase(context, "da_payments_keys");
|
|
61
|
+
const resources = PAYMENT_TABLES.map(({ resource }) => resource);
|
|
62
|
+
const tables = resources.map((resource) => resource.tableName);
|
|
63
|
+
assert.deepEqual(await checkForeignKeys({ knex, resources, tables }), { missing: [], undeclared: [] });
|
|
64
|
+
});
|
|
65
|
+
|
|
56
66
|
test("the store refuses incomplete scopes and identities before any work runs", async (context) => {
|
|
57
67
|
requireTestDatabase(process.env);
|
|
58
68
|
const store = await createTestPaymentStore(await ownDatabase(context, "da_pay_refusals"));
|