@kizlo/woocommerce 0.2.0 → 0.2.2
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 +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +22 -26
- package/dist/test.js +1 -1
- package/package.json +4 -4
package/README.md
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as kizlo0 from "kizlo";
|
|
2
2
|
|
|
3
3
|
//#region src/index.d.ts
|
|
4
|
-
declare function woocommerce(): kizlo0.
|
|
4
|
+
declare function woocommerce(): kizlo0.Integration<"woocommerce", {
|
|
5
5
|
cart: {
|
|
6
6
|
get: kizlo0.Procedure<"api", {}, {
|
|
7
7
|
totalItems: number;
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
|
-
import { CurrencyFormat, IdentifierInput, KizloError, ListMetadata, Seo,
|
|
1
|
+
import { CurrencyFormat, IdentifierInput, KizloError, ListMetadata, Seo, createIntegration, createMiddleware, createProcedure, defineErrorMap, deserializeCurrencyFormat, deserializeListMetadata } from "kizlo";
|
|
2
2
|
import { BooleanLike, Media, Metadata, NumberLike, arrayable, normalizeArrayableValue, random, seconds, timestampSec, toPublicMetadata, tryCatch } from "@kizlo/shared";
|
|
3
3
|
import { SignJWT, jwtVerify } from "jose";
|
|
4
4
|
import z$1, { z } from "zod/v4";
|
|
5
5
|
import z$2 from "zod";
|
|
6
6
|
|
|
7
7
|
//#region src/session.ts
|
|
8
|
+
const GUEST_COOKIE_OPTIONS = {
|
|
9
|
+
httpOnly: true,
|
|
10
|
+
path: "/",
|
|
11
|
+
sameSite: "lax"
|
|
12
|
+
};
|
|
8
13
|
async function mintGuestToken(secret, ttlSeconds) {
|
|
9
14
|
const sub = random({
|
|
10
15
|
length: 32,
|
|
@@ -49,10 +54,7 @@ function sessionMiddleware(options) {
|
|
|
49
54
|
await context.cookies.set({
|
|
50
55
|
name: cookieName,
|
|
51
56
|
value: jwt,
|
|
52
|
-
options:
|
|
53
|
-
httpOnly: true,
|
|
54
|
-
sameSite: "lax"
|
|
55
|
-
}
|
|
57
|
+
options: GUEST_COOKIE_OPTIONS
|
|
56
58
|
});
|
|
57
59
|
return next({ context: { sessionHeaders: getCartHeaders({
|
|
58
60
|
token: sub,
|
|
@@ -65,10 +67,7 @@ function sessionMiddleware(options) {
|
|
|
65
67
|
await context.cookies.set({
|
|
66
68
|
name: cookieName,
|
|
67
69
|
value: jwt,
|
|
68
|
-
options:
|
|
69
|
-
httpOnly: true,
|
|
70
|
-
sameSite: "lax"
|
|
71
|
-
}
|
|
70
|
+
options: GUEST_COOKIE_OPTIONS
|
|
72
71
|
});
|
|
73
72
|
throw new KizloError("CART_SESSION_EXPIRED");
|
|
74
73
|
}
|
|
@@ -87,7 +86,7 @@ function sessionMiddleware(options) {
|
|
|
87
86
|
}) });
|
|
88
87
|
if (response.error) context.logger.error("CART_MERGE_FAILED", response.error);
|
|
89
88
|
}
|
|
90
|
-
await context.cookies.delete(cookieName);
|
|
89
|
+
await context.cookies.delete(cookieName, GUEST_COOKIE_OPTIONS);
|
|
91
90
|
}
|
|
92
91
|
return next({ context: { sessionHeaders: getCartHeaders({
|
|
93
92
|
userId: auth.id,
|
|
@@ -741,7 +740,7 @@ function calculateLineItemTotals(input) {
|
|
|
741
740
|
|
|
742
741
|
//#endregion
|
|
743
742
|
//#region src/cart/index.ts
|
|
744
|
-
const
|
|
743
|
+
const CART_PROCEDURES = {
|
|
745
744
|
get: createProcedure({
|
|
746
745
|
scope: "api",
|
|
747
746
|
method: "GET",
|
|
@@ -1261,7 +1260,7 @@ function paymentStatus(status) {
|
|
|
1261
1260
|
|
|
1262
1261
|
//#endregion
|
|
1263
1262
|
//#region src/checkout/index.ts
|
|
1264
|
-
const
|
|
1263
|
+
const CHECKOUT_PROCEDURES = {
|
|
1265
1264
|
get: createProcedure({
|
|
1266
1265
|
scope: "api",
|
|
1267
1266
|
method: "GET",
|
|
@@ -1459,7 +1458,7 @@ function deserializeCustomer(data) {
|
|
|
1459
1458
|
|
|
1460
1459
|
//#endregion
|
|
1461
1460
|
//#region src/customer/index.ts
|
|
1462
|
-
const
|
|
1461
|
+
const CUSTOMER_PROCEDURES = { get: createProcedure({
|
|
1463
1462
|
scope: "api",
|
|
1464
1463
|
method: "GET",
|
|
1465
1464
|
path: "/customers",
|
|
@@ -1707,7 +1706,7 @@ function toTimestamp(date) {
|
|
|
1707
1706
|
|
|
1708
1707
|
//#endregion
|
|
1709
1708
|
//#region src/product/index.ts
|
|
1710
|
-
const
|
|
1709
|
+
const PRODUCT_PROCEDURES = {
|
|
1711
1710
|
get: createProcedure({
|
|
1712
1711
|
scope: "api",
|
|
1713
1712
|
method: "GET",
|
|
@@ -1801,14 +1800,13 @@ const PRODUCT_ROUTER = {
|
|
|
1801
1800
|
//#endregion
|
|
1802
1801
|
//#region src/index.ts
|
|
1803
1802
|
function woocommerce() {
|
|
1804
|
-
return
|
|
1803
|
+
return createIntegration({
|
|
1805
1804
|
id: "woocommerce",
|
|
1806
1805
|
requires: {
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
name: "Kizlo WooCommerce",
|
|
1806
|
+
plugins: [{
|
|
1807
|
+
name: "kizlo-woocommerce",
|
|
1810
1808
|
version: "0.2.0"
|
|
1811
|
-
},
|
|
1809
|
+
}],
|
|
1812
1810
|
endpoints: [
|
|
1813
1811
|
"woocommerce.customers",
|
|
1814
1812
|
"woocommerce.products",
|
|
@@ -1818,13 +1816,11 @@ function woocommerce() {
|
|
|
1818
1816
|
"woocommerce.store.products"
|
|
1819
1817
|
]
|
|
1820
1818
|
},
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
customers: CUSTOMER_ROUTER
|
|
1827
|
-
} };
|
|
1819
|
+
procedures: {
|
|
1820
|
+
cart: CART_PROCEDURES,
|
|
1821
|
+
products: PRODUCT_PROCEDURES,
|
|
1822
|
+
checkout: CHECKOUT_PROCEDURES,
|
|
1823
|
+
customers: CUSTOMER_PROCEDURES
|
|
1828
1824
|
}
|
|
1829
1825
|
});
|
|
1830
1826
|
}
|
package/dist/test.js
CHANGED
|
@@ -3,7 +3,7 @@ import { defineFixture, kizloRelease } from "kizlo/test";
|
|
|
3
3
|
//#region src/constants.ts
|
|
4
4
|
/**
|
|
5
5
|
* Base paths for the two WooCommerce APIs, used only where this package seeds or inspects a store
|
|
6
|
-
* directly. Everything a
|
|
6
|
+
* directly. Everything a procedure or service reaches goes through a generated endpoint, which derives
|
|
7
7
|
* its own prefix from the namespace the plugin declares.
|
|
8
8
|
*/
|
|
9
9
|
const WC_CORE_BASE = "/wp-json/wc/v3";
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kizlo/woocommerce",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": false,
|
|
6
|
-
"description": "WooCommerce
|
|
6
|
+
"description": "WooCommerce integration for Kizlo.",
|
|
7
7
|
"keywords": [
|
|
8
8
|
"wordpress",
|
|
9
9
|
"headless",
|
|
@@ -49,11 +49,11 @@
|
|
|
49
49
|
"access": "public"
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@kizlo/shared": "0.
|
|
52
|
+
"@kizlo/shared": "0.8.0",
|
|
53
53
|
"jose": "6.1.0",
|
|
54
54
|
"zod": "^4.3.6"
|
|
55
55
|
},
|
|
56
56
|
"peerDependencies": {
|
|
57
|
-
"kizlo": ">=0.
|
|
57
|
+
"kizlo": ">=0.16.0"
|
|
58
58
|
}
|
|
59
59
|
}
|