@foxy.io/sdk 1.9.4 → 1.10.0
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/cdn/FoxySDKCustomer.js +3 -3
- package/dist/cjs/core/API/Node.js +3 -2
- package/dist/cjs/core/getResourceId.js +24 -0
- package/dist/cjs/core/index.js +3 -1
- package/dist/esm/core/API/Node.js +3 -2
- package/dist/esm/core/getResourceId.js +20 -0
- package/dist/esm/core/index.js +1 -0
- package/dist/types/backend/Graph/applied_coupon_code.d.ts +2 -0
- package/dist/types/backend/Graph/cart.d.ts +9 -5
- package/dist/types/backend/Graph/hosted_payment_gateways_helper.d.ts +1 -0
- package/dist/types/backend/Graph/item.d.ts +8 -2
- package/dist/types/backend/Graph/payment_gateways_helper.d.ts +1 -0
- package/dist/types/backend/Graph/sub_modification_url.d.ts +5 -0
- package/dist/types/backend/Graph/subscription.d.ts +3 -0
- package/dist/types/core/getResourceId.d.ts +9 -0
- package/dist/types/core/index.d.ts +1 -0
- package/package.json +8 -8
|
@@ -78,8 +78,9 @@ class Node {
|
|
|
78
78
|
const { filters, fields, offset, limit, order, zoom } = query !== null && query !== void 0 ? query : {};
|
|
79
79
|
if (filters !== undefined) {
|
|
80
80
|
filters.forEach((filter) => {
|
|
81
|
-
const
|
|
82
|
-
|
|
81
|
+
const [key, value = ''] = filter.split('=');
|
|
82
|
+
if (key)
|
|
83
|
+
url.searchParams.append(key, value);
|
|
83
84
|
});
|
|
84
85
|
}
|
|
85
86
|
if (fields !== undefined)
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getResourceId = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Returns the last path segment, which is usually an ID.
|
|
6
|
+
* If it's a non-NaN numeric ID (true for most Foxy resources) then a `number` is returned.
|
|
7
|
+
* Otherwise returns a string or `null` if the path is empty.
|
|
8
|
+
*
|
|
9
|
+
* @param uri `self` link on a resource, e.g. `https://api.foxy.io/stores/123`
|
|
10
|
+
* @returns resource ID or `null` if not found
|
|
11
|
+
*/
|
|
12
|
+
function getResourceId(uri) {
|
|
13
|
+
try {
|
|
14
|
+
const idAsString = new URL(uri).pathname.split('/').pop() || undefined;
|
|
15
|
+
if (idAsString === undefined)
|
|
16
|
+
return null;
|
|
17
|
+
const idAsInt = parseInt(idAsString);
|
|
18
|
+
return isNaN(idAsInt) ? idAsString : idAsInt;
|
|
19
|
+
}
|
|
20
|
+
catch (_a) {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.getResourceId = getResourceId;
|
package/dist/cjs/core/index.js
CHANGED
|
@@ -19,10 +19,12 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
19
19
|
return result;
|
|
20
20
|
};
|
|
21
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
exports.API = exports.Rumour = exports.BooleanSelector = exports.Nucleon = void 0;
|
|
22
|
+
exports.API = exports.Rumour = exports.getResourceId = exports.BooleanSelector = exports.Nucleon = void 0;
|
|
23
23
|
exports.Nucleon = __importStar(require("./Nucleon/index.js"));
|
|
24
24
|
var BooleanSelector_js_1 = require("./BooleanSelector.js");
|
|
25
25
|
Object.defineProperty(exports, "BooleanSelector", { enumerable: true, get: function () { return BooleanSelector_js_1.BooleanSelector; } });
|
|
26
|
+
var getResourceId_js_1 = require("./getResourceId.js");
|
|
27
|
+
Object.defineProperty(exports, "getResourceId", { enumerable: true, get: function () { return getResourceId_js_1.getResourceId; } });
|
|
26
28
|
var index_js_1 = require("./Rumour/index.js");
|
|
27
29
|
Object.defineProperty(exports, "Rumour", { enumerable: true, get: function () { return index_js_1.Rumour; } });
|
|
28
30
|
var index_js_2 = require("./API/index.js");
|
|
@@ -72,8 +72,9 @@ export class Node {
|
|
|
72
72
|
const { filters, fields, offset, limit, order, zoom } = query !== null && query !== void 0 ? query : {};
|
|
73
73
|
if (filters !== undefined) {
|
|
74
74
|
filters.forEach((filter) => {
|
|
75
|
-
const
|
|
76
|
-
|
|
75
|
+
const [key, value = ''] = filter.split('=');
|
|
76
|
+
if (key)
|
|
77
|
+
url.searchParams.append(key, value);
|
|
77
78
|
});
|
|
78
79
|
}
|
|
79
80
|
if (fields !== undefined)
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns the last path segment, which is usually an ID.
|
|
3
|
+
* If it's a non-NaN numeric ID (true for most Foxy resources) then a `number` is returned.
|
|
4
|
+
* Otherwise returns a string or `null` if the path is empty.
|
|
5
|
+
*
|
|
6
|
+
* @param uri `self` link on a resource, e.g. `https://api.foxy.io/stores/123`
|
|
7
|
+
* @returns resource ID or `null` if not found
|
|
8
|
+
*/
|
|
9
|
+
export function getResourceId(uri) {
|
|
10
|
+
try {
|
|
11
|
+
const idAsString = new URL(uri).pathname.split('/').pop() || undefined;
|
|
12
|
+
if (idAsString === undefined)
|
|
13
|
+
return null;
|
|
14
|
+
const idAsInt = parseInt(idAsString);
|
|
15
|
+
return isNaN(idAsInt) ? idAsString : idAsInt;
|
|
16
|
+
}
|
|
17
|
+
catch (_a) {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
}
|
package/dist/esm/core/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as Nucleon_1 from './Nucleon/index.js';
|
|
2
2
|
export { Nucleon_1 as Nucleon };
|
|
3
3
|
export { BooleanSelector } from './BooleanSelector.js';
|
|
4
|
+
export { getResourceId } from './getResourceId.js';
|
|
4
5
|
export { Rumour } from './Rumour/index.js';
|
|
5
6
|
export { API } from './API/index.js';
|
|
@@ -23,6 +23,8 @@ export interface AppliedCouponCode extends Graph {
|
|
|
23
23
|
props: {
|
|
24
24
|
/** The coupon code applied to this cart. */
|
|
25
25
|
code: string;
|
|
26
|
+
/** Allow the coupon to be added to the cart, even if it has expired or the number of uses per coupon, code or customer has reached their maximums. This value is available only in POST request body. */
|
|
27
|
+
ignore_usage_limits?: boolean;
|
|
26
28
|
/** The date this resource was created. */
|
|
27
29
|
date_created: string | null;
|
|
28
30
|
/** The date this resource was last modified. */
|
|
@@ -113,16 +113,20 @@ export interface Cart extends Graph {
|
|
|
113
113
|
template_set_uri: string;
|
|
114
114
|
/** The language defined by the template set being used. */
|
|
115
115
|
language: string;
|
|
116
|
+
/** The 3 character ISO code for the currency. This value may be unavailable in some carts. */
|
|
117
|
+
currency_code?: string;
|
|
118
|
+
/** The currency symbol, such as $, £, €, etc. This value may be unavailable in some carts. */
|
|
119
|
+
currency_symbol?: string;
|
|
116
120
|
/** Total amount of the items in this cart. */
|
|
117
|
-
total_item_price:
|
|
121
|
+
total_item_price: number;
|
|
118
122
|
/** Total amount of the taxes for this cart. */
|
|
119
|
-
total_tax:
|
|
123
|
+
total_tax: number;
|
|
120
124
|
/** Total amount of the shipping costs for this cart. */
|
|
121
|
-
total_shipping:
|
|
125
|
+
total_shipping: number;
|
|
122
126
|
/** If this cart has any shippable subscription items which will process in the future, this will be the total amount of shipping costs for those items. */
|
|
123
|
-
total_future_shipping:
|
|
127
|
+
total_future_shipping: number;
|
|
124
128
|
/** Total order amount of this cart including all items, taxes, shipping costs and discounts. */
|
|
125
|
-
total_order:
|
|
129
|
+
total_order: number;
|
|
126
130
|
/** The date this resource was created. */
|
|
127
131
|
date_created: string | null;
|
|
128
132
|
/** The date this resource was last modified. */
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Attributes } from './attributes';
|
|
2
|
+
import type { Cart } from './cart';
|
|
2
3
|
import type { CouponDetails } from './coupon_details';
|
|
3
4
|
import type { DiscountDetails } from './discount_details';
|
|
4
5
|
import type { Graph } from '../../core';
|
|
@@ -6,6 +7,7 @@ import type { ItemCategory } from './item_category';
|
|
|
6
7
|
import type { ItemOptions } from './item_options';
|
|
7
8
|
import type { Shipment } from './shipment';
|
|
8
9
|
import type { Store } from './store';
|
|
10
|
+
import type { Subscription } from './subscription';
|
|
9
11
|
import type { Transaction } from './transaction';
|
|
10
12
|
|
|
11
13
|
export interface Item extends Graph {
|
|
@@ -16,12 +18,16 @@ export interface Item extends Graph {
|
|
|
16
18
|
'self': Item;
|
|
17
19
|
/** Store this item belongs to. */
|
|
18
20
|
'fx:store': Store;
|
|
19
|
-
/** Related shipment info. */
|
|
21
|
+
/** Related shipment info. This link is available in purchased items only. */
|
|
20
22
|
'fx:shipment': Shipment;
|
|
21
23
|
/** Custom attributes linked to this item. */
|
|
22
24
|
'fx:attributes': Attributes;
|
|
23
|
-
/** Related transaction info. */
|
|
25
|
+
/** Related transaction info. This link is available in transaction items only. */
|
|
24
26
|
'fx:transaction': Transaction;
|
|
27
|
+
/** Related subscription info. This link is available only when this item is part of a subscription. */
|
|
28
|
+
'fx:subscription': Subscription;
|
|
29
|
+
/** Related cart info. This link is available in cart items only. */
|
|
30
|
+
'fx:cart': Cart;
|
|
25
31
|
/** Various custom options for this item. */
|
|
26
32
|
'fx:item_options': ItemOptions;
|
|
27
33
|
/** Category this item belongs in. */
|
|
@@ -4,6 +4,7 @@ import type { Graph } from '../../core';
|
|
|
4
4
|
import type { LastTransaction } from './last_transaction';
|
|
5
5
|
import type { OriginalTransaction } from './original_transaction';
|
|
6
6
|
import type { Store } from './store';
|
|
7
|
+
import type { SubModificationUrl } from './sub_modification_url';
|
|
7
8
|
import type { SubTokenUrl } from './sub_token_url';
|
|
8
9
|
import type { TransactionTemplate } from './transaction_template';
|
|
9
10
|
import type { Transactions } from './transactions';
|
|
@@ -28,6 +29,8 @@ export interface Subscription extends Graph {
|
|
|
28
29
|
'fx:transaction_template': TransactionTemplate;
|
|
29
30
|
/** Open this link in browser to load up the subscription template into a full HTML cart for the store. */
|
|
30
31
|
'fx:sub_token_url': SubTokenUrl;
|
|
32
|
+
/** URL of the page where the customer can modify this subscription. This link is available only when configured in subscription settings. */
|
|
33
|
+
'fx:sub_modification_url': SubModificationUrl;
|
|
31
34
|
};
|
|
32
35
|
|
|
33
36
|
props: {
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns the last path segment, which is usually an ID.
|
|
3
|
+
* If it's a non-NaN numeric ID (true for most Foxy resources) then a `number` is returned.
|
|
4
|
+
* Otherwise returns a string or `null` if the path is empty.
|
|
5
|
+
*
|
|
6
|
+
* @param uri `self` link on a resource, e.g. `https://api.foxy.io/stores/123`
|
|
7
|
+
* @returns resource ID or `null` if not found
|
|
8
|
+
*/
|
|
9
|
+
export declare function getResourceId(uri: string): string | number | null;
|
|
@@ -4,5 +4,6 @@ export type { Query } from './Query';
|
|
|
4
4
|
export type { Graph } from './Graph';
|
|
5
5
|
export * as Nucleon from './Nucleon/index.js';
|
|
6
6
|
export { BooleanSelector } from './BooleanSelector.js';
|
|
7
|
+
export { getResourceId } from './getResourceId.js';
|
|
7
8
|
export { Rumour } from './Rumour/index.js';
|
|
8
9
|
export { API } from './API/index.js';
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@foxy.io/sdk",
|
|
3
3
|
"type": "commonjs",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.10.0",
|
|
5
5
|
"description": "Universal SDK for a full server-side and a limited in-browser access to Foxy hAPI.",
|
|
6
6
|
"main": "dist/cjs/index.js",
|
|
7
7
|
"module": "dist/esm/index.js",
|
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
"backend.d.ts"
|
|
32
32
|
],
|
|
33
33
|
"scripts": {
|
|
34
|
-
"test": "jest",
|
|
35
|
-
"test:watch": "jest --watch",
|
|
34
|
+
"test": "NODE_OPTIONS=--no-experimental-fetch jest",
|
|
35
|
+
"test:watch": "NODE_OPTIONS=--no-experimental-fetch jest --watch",
|
|
36
36
|
"lint": "npm run lint:eslint && npm run lint:prettier",
|
|
37
37
|
"lint:eslint": "eslint --ext .ts,.html . --ignore-path .gitignore",
|
|
38
38
|
"lint:prettier": "prettier \"**/*.ts\" --check --ignore-path .gitignore",
|
|
@@ -85,17 +85,17 @@
|
|
|
85
85
|
"rimraf": "^3.0.2",
|
|
86
86
|
"semantic-release": "^17.3.0",
|
|
87
87
|
"ts-jest": "^26.4.4",
|
|
88
|
-
"ts-loader": "^8.0
|
|
88
|
+
"ts-loader": "^8.4.0",
|
|
89
89
|
"ts-node": "^9.1.1",
|
|
90
|
-
"ttypescript": "^1.5.
|
|
90
|
+
"ttypescript": "^1.5.15",
|
|
91
91
|
"typedoc": "^0.22.18",
|
|
92
92
|
"typescript": "^4.0.3",
|
|
93
|
-
"webpack": "^5.
|
|
94
|
-
"webpack-cli": "^4.
|
|
93
|
+
"webpack": "^5.75.0",
|
|
94
|
+
"webpack-cli": "^4.10.0",
|
|
95
95
|
"webpack-node-externals": "^2.5.2"
|
|
96
96
|
},
|
|
97
97
|
"engines": {
|
|
98
|
-
"node": ">=10 <=
|
|
98
|
+
"node": ">=10 <=20"
|
|
99
99
|
},
|
|
100
100
|
"eslintConfig": {
|
|
101
101
|
"extends": [
|