@proveanything/smartlinks 1.8.11 → 1.9.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/api/facets.d.ts +26 -0
- package/dist/api/facets.js +106 -0
- package/dist/api/index.d.ts +3 -0
- package/dist/api/index.js +3 -0
- package/dist/api/loyalty.d.ts +65 -0
- package/dist/api/loyalty.js +139 -0
- package/dist/api/product.d.ts +52 -3
- package/dist/api/product.js +103 -0
- package/dist/api/products.d.ts +21 -0
- package/dist/api/products.js +114 -0
- package/dist/docs/API_SUMMARY.md +770 -31
- package/dist/docs/PRODUCT_FACETS_SDK.md +347 -0
- package/dist/docs/loyalty.md +333 -0
- package/dist/http.d.ts +2 -1
- package/dist/http.js +3 -2
- package/dist/iframeResponder.js +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/openapi.yaml +5234 -2401
- package/dist/types/facets.d.ts +126 -0
- package/dist/types/facets.js +1 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.js +2 -0
- package/dist/types/loyalty.d.ts +145 -0
- package/dist/types/loyalty.js +2 -0
- package/dist/types/product.d.ts +161 -48
- package/dist/utils/paths.js +3 -2
- package/docs/API_SUMMARY.md +770 -31
- package/docs/PRODUCT_FACETS_SDK.md +347 -0
- package/docs/loyalty.md +333 -0
- package/openapi.yaml +5234 -2401
- package/package.json +1 -1
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { FacetDefinition, FacetDefinitionWriteInput, FacetGetParams, FacetListParams, FacetListResponse, FacetQueryRequest, FacetQueryResponse, FacetValueGetParams, FacetValueListParams, FacetValueListResponse, FacetValueResponse, FacetValueWriteInput, PublicFacetListParams } from "../types/facets";
|
|
2
|
+
/**
|
|
3
|
+
* Facet management and aggregation endpoints.
|
|
4
|
+
*
|
|
5
|
+
* Facets are collection-scoped resources mounted directly under `/facets`.
|
|
6
|
+
* Use this namespace to manage facet definitions and values, and to fetch
|
|
7
|
+
* aggregation buckets for browse and filter UIs.
|
|
8
|
+
*/
|
|
9
|
+
export declare namespace facets {
|
|
10
|
+
function list(collectionId: string, params?: FacetListParams): Promise<FacetListResponse>;
|
|
11
|
+
function create(collectionId: string, data: FacetDefinitionWriteInput): Promise<FacetDefinition>;
|
|
12
|
+
function get(collectionId: string, facetKey: string, params?: FacetGetParams): Promise<FacetDefinition>;
|
|
13
|
+
function update(collectionId: string, facetKey: string, data: FacetDefinitionWriteInput): Promise<FacetDefinition>;
|
|
14
|
+
function remove(collectionId: string, facetKey: string): Promise<void>;
|
|
15
|
+
function listValues(collectionId: string, facetKey: string, params?: FacetValueListParams): Promise<FacetValueListResponse>;
|
|
16
|
+
function createValue(collectionId: string, facetKey: string, data: FacetValueWriteInput): Promise<FacetValueResponse>;
|
|
17
|
+
function getValue(collectionId: string, facetKey: string, valueKey: string, params?: FacetValueGetParams): Promise<FacetValueResponse>;
|
|
18
|
+
function updateValue(collectionId: string, facetKey: string, valueKey: string, data: FacetValueWriteInput): Promise<FacetValueResponse>;
|
|
19
|
+
function removeValue(collectionId: string, facetKey: string, valueKey: string): Promise<void>;
|
|
20
|
+
function query(collectionId: string, body: FacetQueryRequest): Promise<FacetQueryResponse>;
|
|
21
|
+
function publicList(collectionId: string, params?: PublicFacetListParams): Promise<FacetListResponse>;
|
|
22
|
+
function publicGet(collectionId: string, facetKey: string, params?: PublicFacetListParams): Promise<FacetDefinition>;
|
|
23
|
+
function publicListValues(collectionId: string, facetKey: string): Promise<FacetValueListResponse>;
|
|
24
|
+
function publicGetValue(collectionId: string, facetKey: string, valueKey: string): Promise<FacetValueResponse>;
|
|
25
|
+
function publicQuery(collectionId: string, body: FacetQueryRequest): Promise<FacetQueryResponse>;
|
|
26
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { del, post, put, request } from "../http";
|
|
2
|
+
function appendSearchParam(searchParams, key, value) {
|
|
3
|
+
if (value === undefined || value === null)
|
|
4
|
+
return;
|
|
5
|
+
searchParams.set(key, String(value));
|
|
6
|
+
}
|
|
7
|
+
function buildQueryString(params) {
|
|
8
|
+
if (!params)
|
|
9
|
+
return "";
|
|
10
|
+
const searchParams = new URLSearchParams();
|
|
11
|
+
for (const [key, value] of Object.entries(params)) {
|
|
12
|
+
appendSearchParam(searchParams, key, value);
|
|
13
|
+
}
|
|
14
|
+
const query = searchParams.toString();
|
|
15
|
+
return query ? `?${query}` : "";
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Facet management and aggregation endpoints.
|
|
19
|
+
*
|
|
20
|
+
* Facets are collection-scoped resources mounted directly under `/facets`.
|
|
21
|
+
* Use this namespace to manage facet definitions and values, and to fetch
|
|
22
|
+
* aggregation buckets for browse and filter UIs.
|
|
23
|
+
*/
|
|
24
|
+
export var facets;
|
|
25
|
+
(function (facets) {
|
|
26
|
+
async function list(collectionId, params) {
|
|
27
|
+
const path = `/admin/collection/${encodeURIComponent(collectionId)}/facets${buildQueryString(params)}`;
|
|
28
|
+
return request(path);
|
|
29
|
+
}
|
|
30
|
+
facets.list = list;
|
|
31
|
+
async function create(collectionId, data) {
|
|
32
|
+
const path = `/admin/collection/${encodeURIComponent(collectionId)}/facets`;
|
|
33
|
+
return post(path, data);
|
|
34
|
+
}
|
|
35
|
+
facets.create = create;
|
|
36
|
+
async function get(collectionId, facetKey, params) {
|
|
37
|
+
const path = `/admin/collection/${encodeURIComponent(collectionId)}/facets/${encodeURIComponent(facetKey)}${buildQueryString(params)}`;
|
|
38
|
+
return request(path);
|
|
39
|
+
}
|
|
40
|
+
facets.get = get;
|
|
41
|
+
async function update(collectionId, facetKey, data) {
|
|
42
|
+
const path = `/admin/collection/${encodeURIComponent(collectionId)}/facets/${encodeURIComponent(facetKey)}`;
|
|
43
|
+
return put(path, data);
|
|
44
|
+
}
|
|
45
|
+
facets.update = update;
|
|
46
|
+
async function remove(collectionId, facetKey) {
|
|
47
|
+
const path = `/admin/collection/${encodeURIComponent(collectionId)}/facets/${encodeURIComponent(facetKey)}`;
|
|
48
|
+
return del(path);
|
|
49
|
+
}
|
|
50
|
+
facets.remove = remove;
|
|
51
|
+
async function listValues(collectionId, facetKey, params) {
|
|
52
|
+
const path = `/admin/collection/${encodeURIComponent(collectionId)}/facets/${encodeURIComponent(facetKey)}/values${buildQueryString(params)}`;
|
|
53
|
+
return request(path);
|
|
54
|
+
}
|
|
55
|
+
facets.listValues = listValues;
|
|
56
|
+
async function createValue(collectionId, facetKey, data) {
|
|
57
|
+
const path = `/admin/collection/${encodeURIComponent(collectionId)}/facets/${encodeURIComponent(facetKey)}/values`;
|
|
58
|
+
return post(path, data);
|
|
59
|
+
}
|
|
60
|
+
facets.createValue = createValue;
|
|
61
|
+
async function getValue(collectionId, facetKey, valueKey, params) {
|
|
62
|
+
const path = `/admin/collection/${encodeURIComponent(collectionId)}/facets/${encodeURIComponent(facetKey)}/values/${encodeURIComponent(valueKey)}${buildQueryString(params)}`;
|
|
63
|
+
return request(path);
|
|
64
|
+
}
|
|
65
|
+
facets.getValue = getValue;
|
|
66
|
+
async function updateValue(collectionId, facetKey, valueKey, data) {
|
|
67
|
+
const path = `/admin/collection/${encodeURIComponent(collectionId)}/facets/${encodeURIComponent(facetKey)}/values/${encodeURIComponent(valueKey)}`;
|
|
68
|
+
return put(path, data);
|
|
69
|
+
}
|
|
70
|
+
facets.updateValue = updateValue;
|
|
71
|
+
async function removeValue(collectionId, facetKey, valueKey) {
|
|
72
|
+
const path = `/admin/collection/${encodeURIComponent(collectionId)}/facets/${encodeURIComponent(facetKey)}/values/${encodeURIComponent(valueKey)}`;
|
|
73
|
+
return del(path);
|
|
74
|
+
}
|
|
75
|
+
facets.removeValue = removeValue;
|
|
76
|
+
async function query(collectionId, body) {
|
|
77
|
+
const path = `/admin/collection/${encodeURIComponent(collectionId)}/facets/query`;
|
|
78
|
+
return post(path, body);
|
|
79
|
+
}
|
|
80
|
+
facets.query = query;
|
|
81
|
+
async function publicList(collectionId, params) {
|
|
82
|
+
const path = `/public/collection/${encodeURIComponent(collectionId)}/facets${buildQueryString(params)}`;
|
|
83
|
+
return request(path);
|
|
84
|
+
}
|
|
85
|
+
facets.publicList = publicList;
|
|
86
|
+
async function publicGet(collectionId, facetKey, params) {
|
|
87
|
+
const path = `/public/collection/${encodeURIComponent(collectionId)}/facets/${encodeURIComponent(facetKey)}${buildQueryString(params)}`;
|
|
88
|
+
return request(path);
|
|
89
|
+
}
|
|
90
|
+
facets.publicGet = publicGet;
|
|
91
|
+
async function publicListValues(collectionId, facetKey) {
|
|
92
|
+
const path = `/public/collection/${encodeURIComponent(collectionId)}/facets/${encodeURIComponent(facetKey)}/values`;
|
|
93
|
+
return request(path);
|
|
94
|
+
}
|
|
95
|
+
facets.publicListValues = publicListValues;
|
|
96
|
+
async function publicGetValue(collectionId, facetKey, valueKey) {
|
|
97
|
+
const path = `/public/collection/${encodeURIComponent(collectionId)}/facets/${encodeURIComponent(facetKey)}/values/${encodeURIComponent(valueKey)}`;
|
|
98
|
+
return request(path);
|
|
99
|
+
}
|
|
100
|
+
facets.publicGetValue = publicGetValue;
|
|
101
|
+
async function publicQuery(collectionId, body) {
|
|
102
|
+
const path = `/public/collection/${encodeURIComponent(collectionId)}/facets/query`;
|
|
103
|
+
return post(path, body);
|
|
104
|
+
}
|
|
105
|
+
facets.publicQuery = publicQuery;
|
|
106
|
+
})(facets || (facets = {}));
|
package/dist/api/index.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export { collection } from "./collection";
|
|
2
|
+
export { facets } from "./facets";
|
|
2
3
|
export { product } from "./product";
|
|
4
|
+
export { products } from "./products";
|
|
3
5
|
export { proof } from "./proof";
|
|
4
6
|
export { appConfiguration, userAppData } from "./appConfiguration";
|
|
5
7
|
export { asset } from "./asset";
|
|
@@ -32,3 +34,4 @@ export { order } from "./order";
|
|
|
32
34
|
export { app } from "./appObjects";
|
|
33
35
|
export { attestations } from "./attestations";
|
|
34
36
|
export { containers } from "./containers";
|
|
37
|
+
export { loyalty } from "./loyalty";
|
package/dist/api/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
// src/api/index.ts
|
|
2
2
|
// Re-export all resource namespaces so the consumer can import them in one line.
|
|
3
3
|
export { collection } from "./collection";
|
|
4
|
+
export { facets } from "./facets";
|
|
4
5
|
export { product } from "./product";
|
|
6
|
+
export { products } from "./products";
|
|
5
7
|
export { proof } from "./proof";
|
|
6
8
|
export { appConfiguration, userAppData } from "./appConfiguration";
|
|
7
9
|
export { asset } from "./asset";
|
|
@@ -35,3 +37,4 @@ export { order } from "./order";
|
|
|
35
37
|
export { app } from "./appObjects";
|
|
36
38
|
export { attestations } from "./attestations";
|
|
37
39
|
export { containers } from "./containers";
|
|
40
|
+
export { loyalty } from "./loyalty";
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { LoyaltyScheme, LoyaltyMember, LoyaltyTransaction, LoyaltyEarningRule, LoyaltySchemeWithMembership, LoyaltyTransactionResult, LoyaltyPaginationParams, LoyaltyPaginatedResult, CreateLoyaltySchemeBody, UpdateLoyaltySchemeBody, CreateLoyaltyEarningRuleBody, UpdateLoyaltyEarningRuleBody, RecordLoyaltyTransactionBody } from "../types/loyalty";
|
|
2
|
+
export declare namespace loyalty {
|
|
3
|
+
function list(collectionId: string, params?: {
|
|
4
|
+
includeDeleted?: boolean;
|
|
5
|
+
}): Promise<LoyaltyScheme[]>;
|
|
6
|
+
function get(collectionId: string, schemeId: string): Promise<LoyaltyScheme>;
|
|
7
|
+
function create(collectionId: string, body: CreateLoyaltySchemeBody): Promise<LoyaltyScheme>;
|
|
8
|
+
function update(collectionId: string, schemeId: string, body: UpdateLoyaltySchemeBody): Promise<LoyaltyScheme>;
|
|
9
|
+
function remove(collectionId: string, schemeId: string): Promise<LoyaltyScheme>;
|
|
10
|
+
function listEarningRules(collectionId: string, schemeId: string): Promise<LoyaltyEarningRule[]>;
|
|
11
|
+
function getEarningRule(collectionId: string, schemeId: string, ruleId: string): Promise<LoyaltyEarningRule>;
|
|
12
|
+
function createEarningRule(collectionId: string, schemeId: string, body: CreateLoyaltyEarningRuleBody): Promise<LoyaltyEarningRule>;
|
|
13
|
+
function updateEarningRule(collectionId: string, schemeId: string, ruleId: string, body: UpdateLoyaltyEarningRuleBody): Promise<LoyaltyEarningRule>;
|
|
14
|
+
function removeEarningRule(collectionId: string, schemeId: string, ruleId: string): Promise<LoyaltyEarningRule>;
|
|
15
|
+
function listMembers(collectionId: string, schemeId: string, params?: LoyaltyPaginationParams): Promise<LoyaltyPaginatedResult<LoyaltyMember>>;
|
|
16
|
+
function getMember(collectionId: string, schemeId: string, contactId: string): Promise<LoyaltyMember>;
|
|
17
|
+
/**
|
|
18
|
+
* Manually award or deduct points for a contact.
|
|
19
|
+
*
|
|
20
|
+
* - `points` must be a non-zero integer
|
|
21
|
+
* - Positive = award, negative = deduct
|
|
22
|
+
* - Deducting below zero returns HTTP 422 `INSUFFICIENT_BALANCE`
|
|
23
|
+
* - Supply `idempotencyKey` to safely retry without double-crediting
|
|
24
|
+
*
|
|
25
|
+
* Points earned via interaction events are awarded automatically by the
|
|
26
|
+
* server — this endpoint is for manual adjustments and admin overrides.
|
|
27
|
+
*/
|
|
28
|
+
function recordTransaction(collectionId: string, schemeId: string, contactId: string, body: RecordLoyaltyTransactionBody): Promise<LoyaltyTransactionResult>;
|
|
29
|
+
function getMemberHistory(collectionId: string, schemeId: string, contactId: string, params?: LoyaltyPaginationParams): Promise<LoyaltyPaginatedResult<LoyaltyTransaction>>;
|
|
30
|
+
/**
|
|
31
|
+
* List active schemes for a collection. No authentication required.
|
|
32
|
+
*/
|
|
33
|
+
function publicList(collectionId: string): Promise<LoyaltyScheme[]>;
|
|
34
|
+
/**
|
|
35
|
+
* Get a single active scheme. No authentication required.
|
|
36
|
+
*/
|
|
37
|
+
function publicGet(collectionId: string, schemeId: string): Promise<LoyaltyScheme>;
|
|
38
|
+
/**
|
|
39
|
+
* List active earning rules for a scheme — useful for showing "how to earn"
|
|
40
|
+
* in a loyalty UI. No authentication required.
|
|
41
|
+
*/
|
|
42
|
+
function publicListEarningRules(collectionId: string, schemeId: string): Promise<LoyaltyEarningRule[]>;
|
|
43
|
+
/**
|
|
44
|
+
* Get all active schemes with the caller's membership embedded in each.
|
|
45
|
+
*
|
|
46
|
+
* This is the primary entry point for a loyalty widget — one call gives
|
|
47
|
+
* you everything needed to render a user's loyalty status across all
|
|
48
|
+
* programs in a collection.
|
|
49
|
+
*
|
|
50
|
+
* - Authenticated: `member` is populated with balance + lifetimePoints
|
|
51
|
+
* (or null if not yet enrolled in that scheme)
|
|
52
|
+
* - Unauthenticated: `member` is null on all schemes
|
|
53
|
+
*/
|
|
54
|
+
function publicGetMe(collectionId: string): Promise<LoyaltySchemeWithMembership[]>;
|
|
55
|
+
/**
|
|
56
|
+
* Get the authenticated caller's membership (balance + lifetimePoints)
|
|
57
|
+
* on a specific scheme. Requires authentication.
|
|
58
|
+
*/
|
|
59
|
+
function publicGetMine(collectionId: string, schemeId: string): Promise<LoyaltyMember>;
|
|
60
|
+
/**
|
|
61
|
+
* Get the authenticated caller's transaction history on a specific scheme.
|
|
62
|
+
* Ordered newest first. Requires authentication.
|
|
63
|
+
*/
|
|
64
|
+
function publicGetMineHistory(collectionId: string, schemeId: string, params?: LoyaltyPaginationParams): Promise<LoyaltyPaginatedResult<LoyaltyTransaction>>;
|
|
65
|
+
}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
// src/api/loyalty.ts
|
|
2
|
+
import { request, post, patch, del } from "../http";
|
|
3
|
+
function encodeQuery(params) {
|
|
4
|
+
const q = new URLSearchParams();
|
|
5
|
+
for (const [k, v] of Object.entries(params)) {
|
|
6
|
+
if (v !== undefined)
|
|
7
|
+
q.set(k, String(v));
|
|
8
|
+
}
|
|
9
|
+
const s = q.toString();
|
|
10
|
+
return s ? `?${s}` : "";
|
|
11
|
+
}
|
|
12
|
+
export var loyalty;
|
|
13
|
+
(function (loyalty) {
|
|
14
|
+
// ── Admin — Schemes ───────────────────────────────────────────────────────────
|
|
15
|
+
async function list(collectionId, params = {}) {
|
|
16
|
+
return request(`/admin/collection/${encodeURIComponent(collectionId)}/loyaltyScheme${encodeQuery(params)}`);
|
|
17
|
+
}
|
|
18
|
+
loyalty.list = list;
|
|
19
|
+
async function get(collectionId, schemeId) {
|
|
20
|
+
return request(`/admin/collection/${encodeURIComponent(collectionId)}/loyaltyScheme/${encodeURIComponent(schemeId)}`);
|
|
21
|
+
}
|
|
22
|
+
loyalty.get = get;
|
|
23
|
+
async function create(collectionId, body) {
|
|
24
|
+
return post(`/admin/collection/${encodeURIComponent(collectionId)}/loyaltyScheme`, body);
|
|
25
|
+
}
|
|
26
|
+
loyalty.create = create;
|
|
27
|
+
async function update(collectionId, schemeId, body) {
|
|
28
|
+
return patch(`/admin/collection/${encodeURIComponent(collectionId)}/loyaltyScheme/${encodeURIComponent(schemeId)}`, body);
|
|
29
|
+
}
|
|
30
|
+
loyalty.update = update;
|
|
31
|
+
async function remove(collectionId, schemeId) {
|
|
32
|
+
return del(`/admin/collection/${encodeURIComponent(collectionId)}/loyaltyScheme/${encodeURIComponent(schemeId)}`);
|
|
33
|
+
}
|
|
34
|
+
loyalty.remove = remove;
|
|
35
|
+
// ── Admin — Earning Rules ─────────────────────────────────────────────────────
|
|
36
|
+
async function listEarningRules(collectionId, schemeId) {
|
|
37
|
+
return request(`/admin/collection/${encodeURIComponent(collectionId)}/loyaltyScheme/${encodeURIComponent(schemeId)}/earningRule`);
|
|
38
|
+
}
|
|
39
|
+
loyalty.listEarningRules = listEarningRules;
|
|
40
|
+
async function getEarningRule(collectionId, schemeId, ruleId) {
|
|
41
|
+
return request(`/admin/collection/${encodeURIComponent(collectionId)}/loyaltyScheme/${encodeURIComponent(schemeId)}/earningRule/${encodeURIComponent(ruleId)}`);
|
|
42
|
+
}
|
|
43
|
+
loyalty.getEarningRule = getEarningRule;
|
|
44
|
+
async function createEarningRule(collectionId, schemeId, body) {
|
|
45
|
+
return post(`/admin/collection/${encodeURIComponent(collectionId)}/loyaltyScheme/${encodeURIComponent(schemeId)}/earningRule`, body);
|
|
46
|
+
}
|
|
47
|
+
loyalty.createEarningRule = createEarningRule;
|
|
48
|
+
async function updateEarningRule(collectionId, schemeId, ruleId, body) {
|
|
49
|
+
return patch(`/admin/collection/${encodeURIComponent(collectionId)}/loyaltyScheme/${encodeURIComponent(schemeId)}/earningRule/${encodeURIComponent(ruleId)}`, body);
|
|
50
|
+
}
|
|
51
|
+
loyalty.updateEarningRule = updateEarningRule;
|
|
52
|
+
async function removeEarningRule(collectionId, schemeId, ruleId) {
|
|
53
|
+
return del(`/admin/collection/${encodeURIComponent(collectionId)}/loyaltyScheme/${encodeURIComponent(schemeId)}/earningRule/${encodeURIComponent(ruleId)}`);
|
|
54
|
+
}
|
|
55
|
+
loyalty.removeEarningRule = removeEarningRule;
|
|
56
|
+
// ── Admin — Members ───────────────────────────────────────────────────────────
|
|
57
|
+
async function listMembers(collectionId, schemeId, params = {}) {
|
|
58
|
+
return request(`/admin/collection/${encodeURIComponent(collectionId)}/loyaltyScheme/${encodeURIComponent(schemeId)}/member${encodeQuery(params)}`);
|
|
59
|
+
}
|
|
60
|
+
loyalty.listMembers = listMembers;
|
|
61
|
+
async function getMember(collectionId, schemeId, contactId) {
|
|
62
|
+
return request(`/admin/collection/${encodeURIComponent(collectionId)}/loyaltyScheme/${encodeURIComponent(schemeId)}/member/${encodeURIComponent(contactId)}`);
|
|
63
|
+
}
|
|
64
|
+
loyalty.getMember = getMember;
|
|
65
|
+
// ── Admin — Transactions ──────────────────────────────────────────────────────
|
|
66
|
+
/**
|
|
67
|
+
* Manually award or deduct points for a contact.
|
|
68
|
+
*
|
|
69
|
+
* - `points` must be a non-zero integer
|
|
70
|
+
* - Positive = award, negative = deduct
|
|
71
|
+
* - Deducting below zero returns HTTP 422 `INSUFFICIENT_BALANCE`
|
|
72
|
+
* - Supply `idempotencyKey` to safely retry without double-crediting
|
|
73
|
+
*
|
|
74
|
+
* Points earned via interaction events are awarded automatically by the
|
|
75
|
+
* server — this endpoint is for manual adjustments and admin overrides.
|
|
76
|
+
*/
|
|
77
|
+
async function recordTransaction(collectionId, schemeId, contactId, body) {
|
|
78
|
+
return post(`/admin/collection/${encodeURIComponent(collectionId)}/loyaltyScheme/${encodeURIComponent(schemeId)}/member/${encodeURIComponent(contactId)}/transaction`, body);
|
|
79
|
+
}
|
|
80
|
+
loyalty.recordTransaction = recordTransaction;
|
|
81
|
+
async function getMemberHistory(collectionId, schemeId, contactId, params = {}) {
|
|
82
|
+
return request(`/admin/collection/${encodeURIComponent(collectionId)}/loyaltyScheme/${encodeURIComponent(schemeId)}/member/${encodeURIComponent(contactId)}/history${encodeQuery(params)}`);
|
|
83
|
+
}
|
|
84
|
+
loyalty.getMemberHistory = getMemberHistory;
|
|
85
|
+
// ── Public ────────────────────────────────────────────────────────────────────
|
|
86
|
+
/**
|
|
87
|
+
* List active schemes for a collection. No authentication required.
|
|
88
|
+
*/
|
|
89
|
+
async function publicList(collectionId) {
|
|
90
|
+
return request(`/public/collection/${encodeURIComponent(collectionId)}/loyaltyScheme`);
|
|
91
|
+
}
|
|
92
|
+
loyalty.publicList = publicList;
|
|
93
|
+
/**
|
|
94
|
+
* Get a single active scheme. No authentication required.
|
|
95
|
+
*/
|
|
96
|
+
async function publicGet(collectionId, schemeId) {
|
|
97
|
+
return request(`/public/collection/${encodeURIComponent(collectionId)}/loyaltyScheme/${encodeURIComponent(schemeId)}`);
|
|
98
|
+
}
|
|
99
|
+
loyalty.publicGet = publicGet;
|
|
100
|
+
/**
|
|
101
|
+
* List active earning rules for a scheme — useful for showing "how to earn"
|
|
102
|
+
* in a loyalty UI. No authentication required.
|
|
103
|
+
*/
|
|
104
|
+
async function publicListEarningRules(collectionId, schemeId) {
|
|
105
|
+
return request(`/public/collection/${encodeURIComponent(collectionId)}/loyaltyScheme/${encodeURIComponent(schemeId)}/earningRule`);
|
|
106
|
+
}
|
|
107
|
+
loyalty.publicListEarningRules = publicListEarningRules;
|
|
108
|
+
/**
|
|
109
|
+
* Get all active schemes with the caller's membership embedded in each.
|
|
110
|
+
*
|
|
111
|
+
* This is the primary entry point for a loyalty widget — one call gives
|
|
112
|
+
* you everything needed to render a user's loyalty status across all
|
|
113
|
+
* programs in a collection.
|
|
114
|
+
*
|
|
115
|
+
* - Authenticated: `member` is populated with balance + lifetimePoints
|
|
116
|
+
* (or null if not yet enrolled in that scheme)
|
|
117
|
+
* - Unauthenticated: `member` is null on all schemes
|
|
118
|
+
*/
|
|
119
|
+
async function publicGetMe(collectionId) {
|
|
120
|
+
return request(`/public/collection/${encodeURIComponent(collectionId)}/loyaltyScheme/me`);
|
|
121
|
+
}
|
|
122
|
+
loyalty.publicGetMe = publicGetMe;
|
|
123
|
+
/**
|
|
124
|
+
* Get the authenticated caller's membership (balance + lifetimePoints)
|
|
125
|
+
* on a specific scheme. Requires authentication.
|
|
126
|
+
*/
|
|
127
|
+
async function publicGetMine(collectionId, schemeId) {
|
|
128
|
+
return request(`/public/collection/${encodeURIComponent(collectionId)}/loyaltyScheme/${encodeURIComponent(schemeId)}/member/me`);
|
|
129
|
+
}
|
|
130
|
+
loyalty.publicGetMine = publicGetMine;
|
|
131
|
+
/**
|
|
132
|
+
* Get the authenticated caller's transaction history on a specific scheme.
|
|
133
|
+
* Ordered newest first. Requires authentication.
|
|
134
|
+
*/
|
|
135
|
+
async function publicGetMineHistory(collectionId, schemeId, params = {}) {
|
|
136
|
+
return request(`/public/collection/${encodeURIComponent(collectionId)}/loyaltyScheme/${encodeURIComponent(schemeId)}/member/me/history${encodeQuery(params)}`);
|
|
137
|
+
}
|
|
138
|
+
loyalty.publicGetMineHistory = publicGetMineHistory;
|
|
139
|
+
})(loyalty || (loyalty = {}));
|
package/dist/api/product.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { JsonValue, ProductClaimCreateRequestBody, ProductCreateRequest, ProductQueryRequest, ProductQueryResponse, ProductResponse, ProductUpdateRequest } from "../types/product";
|
|
2
|
+
type ProductPublicFindParams = Record<string, string | number | boolean | null | undefined | Array<string | number | boolean>>;
|
|
2
3
|
export declare namespace product {
|
|
3
4
|
/**
|
|
5
|
+
* @deprecated Use `products.get(...)`.
|
|
4
6
|
* Retrieves a single Product Item by Collection ID and Product ID.
|
|
5
7
|
* @param collectionId – Identifier of the parent collection
|
|
6
8
|
* @param productId – Identifier of the product item
|
|
@@ -10,6 +12,7 @@ export declare namespace product {
|
|
|
10
12
|
*/
|
|
11
13
|
function get(collectionId: string, productId: string, admin?: boolean): Promise<ProductResponse>;
|
|
12
14
|
/**
|
|
15
|
+
* @deprecated Use `products.list(...)`.
|
|
13
16
|
* List all Product Items for a Collection.
|
|
14
17
|
* @param collectionId – Identifier of the parent collection
|
|
15
18
|
* @param admin – If true, use admin endpoint; otherwise, use public
|
|
@@ -18,6 +21,7 @@ export declare namespace product {
|
|
|
18
21
|
*/
|
|
19
22
|
function list(collectionId: string, admin?: boolean): Promise<ProductResponse[]>;
|
|
20
23
|
/**
|
|
24
|
+
* @deprecated Use `products.create(...)`.
|
|
21
25
|
* Create a new product for a collection (admin only).
|
|
22
26
|
* The `data` payload follows the same shape as ProductResponse minus `id` and `collectionId`.
|
|
23
27
|
*
|
|
@@ -45,6 +49,7 @@ export declare namespace product {
|
|
|
45
49
|
*/
|
|
46
50
|
function create(collectionId: string, data: ProductCreateRequest): Promise<ProductResponse>;
|
|
47
51
|
/**
|
|
52
|
+
* @deprecated Use `products.update(...)`.
|
|
48
53
|
* Update a product for a collection (admin only).
|
|
49
54
|
* The `data` payload is a partial of ProductResponse minus `id` and `collectionId`.
|
|
50
55
|
*
|
|
@@ -69,6 +74,7 @@ export declare namespace product {
|
|
|
69
74
|
*/
|
|
70
75
|
function update(collectionId: string, productId: string, data: ProductUpdateRequest): Promise<ProductResponse>;
|
|
71
76
|
/**
|
|
77
|
+
* @deprecated Use `products.remove(...)`.
|
|
72
78
|
* Delete a product for a collection (admin only).
|
|
73
79
|
* @param collectionId – Identifier of the parent collection
|
|
74
80
|
* @param productId – Identifier of the product
|
|
@@ -77,6 +83,39 @@ export declare namespace product {
|
|
|
77
83
|
*/
|
|
78
84
|
function remove(collectionId: string, productId: string): Promise<void>;
|
|
79
85
|
/**
|
|
86
|
+
* @deprecated Use `products.query(...)`.
|
|
87
|
+
*/
|
|
88
|
+
function query(collectionId: string, body: ProductQueryRequest): Promise<ProductQueryResponse>;
|
|
89
|
+
/**
|
|
90
|
+
* @deprecated Use `products.find(...)` for admin or `products.publicFind(...)` for public access.
|
|
91
|
+
*/
|
|
92
|
+
function find(collectionId: string, body: ProductQueryRequest): Promise<ProductQueryResponse>;
|
|
93
|
+
/**
|
|
94
|
+
* @deprecated Use `products.publicFind(...)`.
|
|
95
|
+
*/
|
|
96
|
+
function publicFind(collectionId: string, params?: ProductPublicFindParams): Promise<ProductResponse[]>;
|
|
97
|
+
/**
|
|
98
|
+
* @deprecated Use `products.clone(...)`.
|
|
99
|
+
*/
|
|
100
|
+
function clone(collectionId: string, productId: string, body?: Record<string, JsonValue>): Promise<ProductResponse>;
|
|
101
|
+
/**
|
|
102
|
+
* @deprecated Use `products.listAssets(...)`.
|
|
103
|
+
*/
|
|
104
|
+
function listAssets(collectionId: string, productId: string, admin?: boolean): Promise<unknown>;
|
|
105
|
+
/**
|
|
106
|
+
* @deprecated Use `products.createClaimWindow(...)`.
|
|
107
|
+
*/
|
|
108
|
+
function createClaimWindow(collectionId: string, productId: string, body: Record<string, JsonValue>): Promise<unknown>;
|
|
109
|
+
/**
|
|
110
|
+
* @deprecated Use `products.updateClaimWindow(...)`.
|
|
111
|
+
*/
|
|
112
|
+
function updateClaimWindow(collectionId: string, productId: string, claimId: string, body: Record<string, JsonValue>): Promise<unknown>;
|
|
113
|
+
/**
|
|
114
|
+
* @deprecated Use `products.refresh(...)`.
|
|
115
|
+
*/
|
|
116
|
+
function refresh(collectionId: string, productId: string): Promise<ProductResponse>;
|
|
117
|
+
/**
|
|
118
|
+
* @deprecated Use `products.getSN(...)`.
|
|
80
119
|
* Get serial numbers for a product (admin only).
|
|
81
120
|
* @param collectionId - Identifier of the parent collection
|
|
82
121
|
* @param productId - Identifier of the product
|
|
@@ -85,8 +124,9 @@ export declare namespace product {
|
|
|
85
124
|
* @returns Promise resolving to serial number data
|
|
86
125
|
* @throws ErrorResponse if the request fails
|
|
87
126
|
*/
|
|
88
|
-
function getSN(collectionId: string, productId: string, startIndex?: number, count?: number): Promise<
|
|
127
|
+
function getSN(collectionId: string, productId: string, startIndex?: number, count?: number): Promise<unknown>;
|
|
89
128
|
/**
|
|
129
|
+
* @deprecated Use `products.lookupSN(...)`.
|
|
90
130
|
* Look up a serial number by code for a product (admin only).
|
|
91
131
|
* @param collectionId - Identifier of the parent collection
|
|
92
132
|
* @param productId - Identifier of the product
|
|
@@ -94,5 +134,14 @@ export declare namespace product {
|
|
|
94
134
|
* @returns Promise resolving to serial number lookup data
|
|
95
135
|
* @throws ErrorResponse if the request fails
|
|
96
136
|
*/
|
|
97
|
-
function lookupSN(collectionId: string, productId: string, codeId: string): Promise<
|
|
137
|
+
function lookupSN(collectionId: string, productId: string, codeId: string): Promise<unknown>;
|
|
138
|
+
/**
|
|
139
|
+
* @deprecated Use `products.publicLookupClaim(...)`.
|
|
140
|
+
*/
|
|
141
|
+
function publicLookupClaim(collectionId: string, productId: string, claimId: string): Promise<unknown>;
|
|
142
|
+
/**
|
|
143
|
+
* @deprecated Use `products.publicCreateClaim(...)`.
|
|
144
|
+
*/
|
|
145
|
+
function publicCreateClaim(collectionId: string, productId: string, body: ProductClaimCreateRequestBody): Promise<unknown>;
|
|
98
146
|
}
|
|
147
|
+
export {};
|
package/dist/api/product.js
CHANGED
|
@@ -3,6 +3,7 @@ import { request, post, put, del } from "../http";
|
|
|
3
3
|
export var product;
|
|
4
4
|
(function (product) {
|
|
5
5
|
/**
|
|
6
|
+
* @deprecated Use `products.get(...)`.
|
|
6
7
|
* Retrieves a single Product Item by Collection ID and Product ID.
|
|
7
8
|
* @param collectionId – Identifier of the parent collection
|
|
8
9
|
* @param productId – Identifier of the product item
|
|
@@ -17,6 +18,7 @@ export var product;
|
|
|
17
18
|
}
|
|
18
19
|
product.get = get;
|
|
19
20
|
/**
|
|
21
|
+
* @deprecated Use `products.list(...)`.
|
|
20
22
|
* List all Product Items for a Collection.
|
|
21
23
|
* @param collectionId – Identifier of the parent collection
|
|
22
24
|
* @param admin – If true, use admin endpoint; otherwise, use public
|
|
@@ -30,6 +32,7 @@ export var product;
|
|
|
30
32
|
}
|
|
31
33
|
product.list = list;
|
|
32
34
|
/**
|
|
35
|
+
* @deprecated Use `products.create(...)`.
|
|
33
36
|
* Create a new product for a collection (admin only).
|
|
34
37
|
* The `data` payload follows the same shape as ProductResponse minus `id` and `collectionId`.
|
|
35
38
|
*
|
|
@@ -61,6 +64,7 @@ export var product;
|
|
|
61
64
|
}
|
|
62
65
|
product.create = create;
|
|
63
66
|
/**
|
|
67
|
+
* @deprecated Use `products.update(...)`.
|
|
64
68
|
* Update a product for a collection (admin only).
|
|
65
69
|
* The `data` payload is a partial of ProductResponse minus `id` and `collectionId`.
|
|
66
70
|
*
|
|
@@ -89,6 +93,7 @@ export var product;
|
|
|
89
93
|
}
|
|
90
94
|
product.update = update;
|
|
91
95
|
/**
|
|
96
|
+
* @deprecated Use `products.remove(...)`.
|
|
92
97
|
* Delete a product for a collection (admin only).
|
|
93
98
|
* @param collectionId – Identifier of the parent collection
|
|
94
99
|
* @param productId – Identifier of the product
|
|
@@ -101,6 +106,87 @@ export var product;
|
|
|
101
106
|
}
|
|
102
107
|
product.remove = remove;
|
|
103
108
|
/**
|
|
109
|
+
* @deprecated Use `products.query(...)`.
|
|
110
|
+
*/
|
|
111
|
+
async function query(collectionId, body) {
|
|
112
|
+
const path = `/admin/collection/${encodeURIComponent(collectionId)}/product/query`;
|
|
113
|
+
return post(path, body);
|
|
114
|
+
}
|
|
115
|
+
product.query = query;
|
|
116
|
+
/**
|
|
117
|
+
* @deprecated Use `products.find(...)` for admin or `products.publicFind(...)` for public access.
|
|
118
|
+
*/
|
|
119
|
+
async function find(collectionId, body) {
|
|
120
|
+
const path = `/admin/collection/${encodeURIComponent(collectionId)}/product/find`;
|
|
121
|
+
return post(path, body);
|
|
122
|
+
}
|
|
123
|
+
product.find = find;
|
|
124
|
+
/**
|
|
125
|
+
* @deprecated Use `products.publicFind(...)`.
|
|
126
|
+
*/
|
|
127
|
+
async function publicFind(collectionId, params) {
|
|
128
|
+
const searchParams = new URLSearchParams();
|
|
129
|
+
if (params) {
|
|
130
|
+
for (const [key, value] of Object.entries(params)) {
|
|
131
|
+
if (value === undefined || value === null)
|
|
132
|
+
continue;
|
|
133
|
+
if (Array.isArray(value)) {
|
|
134
|
+
for (const item of value)
|
|
135
|
+
searchParams.append(key, String(item));
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
searchParams.set(key, String(value));
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
const query = searchParams.toString();
|
|
143
|
+
const path = `/public/collection/${encodeURIComponent(collectionId)}/product/find${query ? `?${query}` : ''}`;
|
|
144
|
+
return request(path);
|
|
145
|
+
}
|
|
146
|
+
product.publicFind = publicFind;
|
|
147
|
+
/**
|
|
148
|
+
* @deprecated Use `products.clone(...)`.
|
|
149
|
+
*/
|
|
150
|
+
async function clone(collectionId, productId, body = {}) {
|
|
151
|
+
const path = `/admin/collection/${encodeURIComponent(collectionId)}/product/${encodeURIComponent(productId)}/clone`;
|
|
152
|
+
return post(path, body);
|
|
153
|
+
}
|
|
154
|
+
product.clone = clone;
|
|
155
|
+
/**
|
|
156
|
+
* @deprecated Use `products.listAssets(...)`.
|
|
157
|
+
*/
|
|
158
|
+
async function listAssets(collectionId, productId, admin) {
|
|
159
|
+
const base = admin ? '/admin' : '/public';
|
|
160
|
+
const path = `${base}/collection/${encodeURIComponent(collectionId)}/product/${encodeURIComponent(productId)}/asset`;
|
|
161
|
+
return request(path);
|
|
162
|
+
}
|
|
163
|
+
product.listAssets = listAssets;
|
|
164
|
+
/**
|
|
165
|
+
* @deprecated Use `products.createClaimWindow(...)`.
|
|
166
|
+
*/
|
|
167
|
+
async function createClaimWindow(collectionId, productId, body) {
|
|
168
|
+
const path = `/admin/collection/${encodeURIComponent(collectionId)}/product/${encodeURIComponent(productId)}/claimWindow`;
|
|
169
|
+
return post(path, body);
|
|
170
|
+
}
|
|
171
|
+
product.createClaimWindow = createClaimWindow;
|
|
172
|
+
/**
|
|
173
|
+
* @deprecated Use `products.updateClaimWindow(...)`.
|
|
174
|
+
*/
|
|
175
|
+
async function updateClaimWindow(collectionId, productId, claimId, body) {
|
|
176
|
+
const path = `/admin/collection/${encodeURIComponent(collectionId)}/product/${encodeURIComponent(productId)}/claimWindow/${encodeURIComponent(claimId)}`;
|
|
177
|
+
return put(path, body);
|
|
178
|
+
}
|
|
179
|
+
product.updateClaimWindow = updateClaimWindow;
|
|
180
|
+
/**
|
|
181
|
+
* @deprecated Use `products.refresh(...)`.
|
|
182
|
+
*/
|
|
183
|
+
async function refresh(collectionId, productId) {
|
|
184
|
+
const path = `/admin/collection/${encodeURIComponent(collectionId)}/product/${encodeURIComponent(productId)}/refresh`;
|
|
185
|
+
return request(path);
|
|
186
|
+
}
|
|
187
|
+
product.refresh = refresh;
|
|
188
|
+
/**
|
|
189
|
+
* @deprecated Use `products.getSN(...)`.
|
|
104
190
|
* Get serial numbers for a product (admin only).
|
|
105
191
|
* @param collectionId - Identifier of the parent collection
|
|
106
192
|
* @param productId - Identifier of the product
|
|
@@ -119,6 +205,7 @@ export var product;
|
|
|
119
205
|
}
|
|
120
206
|
product.getSN = getSN;
|
|
121
207
|
/**
|
|
208
|
+
* @deprecated Use `products.lookupSN(...)`.
|
|
122
209
|
* Look up a serial number by code for a product (admin only).
|
|
123
210
|
* @param collectionId - Identifier of the parent collection
|
|
124
211
|
* @param productId - Identifier of the product
|
|
@@ -131,4 +218,20 @@ export var product;
|
|
|
131
218
|
return request(path);
|
|
132
219
|
}
|
|
133
220
|
product.lookupSN = lookupSN;
|
|
221
|
+
/**
|
|
222
|
+
* @deprecated Use `products.publicLookupClaim(...)`.
|
|
223
|
+
*/
|
|
224
|
+
async function publicLookupClaim(collectionId, productId, claimId) {
|
|
225
|
+
const path = `/public/collection/${encodeURIComponent(collectionId)}/product/${encodeURIComponent(productId)}/lookupClaim/${encodeURIComponent(claimId)}`;
|
|
226
|
+
return request(path);
|
|
227
|
+
}
|
|
228
|
+
product.publicLookupClaim = publicLookupClaim;
|
|
229
|
+
/**
|
|
230
|
+
* @deprecated Use `products.publicCreateClaim(...)`.
|
|
231
|
+
*/
|
|
232
|
+
async function publicCreateClaim(collectionId, productId, body) {
|
|
233
|
+
const path = `/public/collection/${encodeURIComponent(collectionId)}/product/${encodeURIComponent(productId)}/createClaim`;
|
|
234
|
+
return post(path, body);
|
|
235
|
+
}
|
|
236
|
+
product.publicCreateClaim = publicCreateClaim;
|
|
134
237
|
})(product || (product = {}));
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { JsonValue, ProductClaimCreateRequestBody, ProductCreateRequest, ProductQueryRequest, ProductQueryResponse, ProductResponse, ProductUpdateRequest } from "../types/product";
|
|
2
|
+
export type ProductPublicFindParams = Record<string, string | number | boolean | null | undefined | Array<string | number | boolean>>;
|
|
3
|
+
export declare namespace products {
|
|
4
|
+
function get(collectionId: string, productId: string, admin?: boolean): Promise<ProductResponse>;
|
|
5
|
+
function list(collectionId: string, admin?: boolean): Promise<ProductResponse[]>;
|
|
6
|
+
function create(collectionId: string, data: ProductCreateRequest): Promise<ProductResponse>;
|
|
7
|
+
function update(collectionId: string, productId: string, data: ProductUpdateRequest): Promise<ProductResponse>;
|
|
8
|
+
function remove(collectionId: string, productId: string): Promise<void>;
|
|
9
|
+
function query(collectionId: string, body: ProductQueryRequest): Promise<ProductQueryResponse>;
|
|
10
|
+
function find(collectionId: string, body: ProductQueryRequest | Record<string, JsonValue>): Promise<ProductQueryResponse>;
|
|
11
|
+
function publicFind(collectionId: string, params?: ProductPublicFindParams): Promise<ProductResponse[]>;
|
|
12
|
+
function clone(collectionId: string, productId: string, body?: Record<string, JsonValue>): Promise<ProductResponse>;
|
|
13
|
+
function listAssets(collectionId: string, productId: string, admin?: boolean): Promise<unknown>;
|
|
14
|
+
function createClaimWindow(collectionId: string, productId: string, body: Record<string, JsonValue>): Promise<unknown>;
|
|
15
|
+
function updateClaimWindow(collectionId: string, productId: string, claimId: string, body: Record<string, JsonValue>): Promise<unknown>;
|
|
16
|
+
function refresh(collectionId: string, productId: string): Promise<ProductResponse>;
|
|
17
|
+
function getSN(collectionId: string, productId: string, startIndex?: number, count?: number): Promise<unknown>;
|
|
18
|
+
function lookupSN(collectionId: string, productId: string, codeId: string): Promise<unknown>;
|
|
19
|
+
function publicLookupClaim(collectionId: string, productId: string, claimId: string): Promise<unknown>;
|
|
20
|
+
function publicCreateClaim(collectionId: string, productId: string, body: ProductClaimCreateRequestBody): Promise<unknown>;
|
|
21
|
+
}
|