feeef 0.8.2 → 0.8.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/build/index.js +177 -51
- package/build/index.js.map +1 -1
- package/build/src/feeef/feeef.d.ts +10 -0
- package/build/src/feeef/repositories/apps.d.ts +101 -0
- package/build/src/feeef/repositories/promos.d.ts +77 -0
- package/build/src/feeef/repositories/store_invites_repository.d.ts +48 -0
- package/build/src/feeef/repositories/stores.d.ts +8 -38
- package/build/src/index.d.ts +5 -0
- package/package.json +1 -1
|
@@ -3,7 +3,9 @@ import { OrderRepository } from './repositories/orders.js';
|
|
|
3
3
|
import { ProductRepository } from './repositories/products.js';
|
|
4
4
|
import { StoreRepository } from './repositories/stores.js';
|
|
5
5
|
import { UserRepository } from './repositories/users.js';
|
|
6
|
+
import { AppRepository } from './repositories/apps.js';
|
|
6
7
|
import { DepositRepository } from './repositories/deposits.js';
|
|
8
|
+
import { PromoRepository } from './repositories/promos.js';
|
|
7
9
|
import { TransferRepository } from './repositories/transfers.js';
|
|
8
10
|
import { CategoryRepository } from './repositories/categories.js';
|
|
9
11
|
import { CountryRepository } from './repositories/countries.js';
|
|
@@ -86,6 +88,10 @@ export declare class FeeeF {
|
|
|
86
88
|
* The repository for managing users.
|
|
87
89
|
*/
|
|
88
90
|
users: UserRepository;
|
|
91
|
+
/**
|
|
92
|
+
* The repository for managing developer-registered apps (OAuth clients).
|
|
93
|
+
*/
|
|
94
|
+
apps: AppRepository;
|
|
89
95
|
/**
|
|
90
96
|
* The repository for managing orders.
|
|
91
97
|
*/
|
|
@@ -98,6 +104,10 @@ export declare class FeeeF {
|
|
|
98
104
|
* The repository for managing transfers.
|
|
99
105
|
*/
|
|
100
106
|
transfers: TransferRepository;
|
|
107
|
+
/**
|
|
108
|
+
* The repository for managing promo codes (list, validate, create).
|
|
109
|
+
*/
|
|
110
|
+
promos: PromoRepository;
|
|
101
111
|
/**
|
|
102
112
|
* The repository for managing categories.
|
|
103
113
|
*/
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { AxiosInstance } from 'axios';
|
|
2
|
+
import { ModelRepository, ListResponse } from './repository.js';
|
|
3
|
+
/**
|
|
4
|
+
* Developer-registered app (OAuth client) returned by the apps API.
|
|
5
|
+
* clientSecret is present only on create and regenerateSecret responses.
|
|
6
|
+
*/
|
|
7
|
+
export interface AppEntity {
|
|
8
|
+
id: string;
|
|
9
|
+
/** Owner user id. Always present from API. */
|
|
10
|
+
userId?: string;
|
|
11
|
+
name: string;
|
|
12
|
+
clientId: string;
|
|
13
|
+
redirectUris: string[];
|
|
14
|
+
scopes: string[];
|
|
15
|
+
active: boolean;
|
|
16
|
+
lastUsedAt: string | null;
|
|
17
|
+
createdAt: string;
|
|
18
|
+
updatedAt: string | null;
|
|
19
|
+
/** Present only when returned from create or regenerateSecret. Store securely. */
|
|
20
|
+
clientSecret?: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Input for creating a new app.
|
|
24
|
+
* userId is optional; admins may set it to create an app for another user.
|
|
25
|
+
*/
|
|
26
|
+
export interface AppCreateInput {
|
|
27
|
+
name: string;
|
|
28
|
+
redirectUris: string[];
|
|
29
|
+
scopes: string[];
|
|
30
|
+
userId?: string;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Input for updating an existing app.
|
|
34
|
+
*/
|
|
35
|
+
export interface AppUpdateInput {
|
|
36
|
+
name?: string;
|
|
37
|
+
redirectUris?: string[];
|
|
38
|
+
scopes?: string[];
|
|
39
|
+
active?: boolean;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Options for listing apps (pagination, filterator, search).
|
|
43
|
+
* filterator: JSON string from dashboard advanced filter; backend applies filtering/ordering.
|
|
44
|
+
* q: optional search (backend may support free-text search on name/clientId).
|
|
45
|
+
*/
|
|
46
|
+
export interface AppListOptions {
|
|
47
|
+
page?: number;
|
|
48
|
+
limit?: number;
|
|
49
|
+
q?: string;
|
|
50
|
+
filterator?: string;
|
|
51
|
+
userId?: string;
|
|
52
|
+
active?: boolean;
|
|
53
|
+
params?: Record<string, any>;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Repository for developer-registered apps (CRUD and regenerate secret).
|
|
57
|
+
* Requires an authenticated user (Bearer token).
|
|
58
|
+
*
|
|
59
|
+
* Terminology: "app" / "apps" is used consistently for the resource;
|
|
60
|
+
* OAuth is used only for the flow (authorize, token endpoints).
|
|
61
|
+
*/
|
|
62
|
+
export declare class AppRepository extends ModelRepository<AppEntity, AppCreateInput, AppUpdateInput> {
|
|
63
|
+
constructor(client: AxiosInstance);
|
|
64
|
+
/**
|
|
65
|
+
* Lists apps with optional pagination and filterator.
|
|
66
|
+
* @param options - Page, limit, filterator, q, and extra params forwarded to the API.
|
|
67
|
+
*/
|
|
68
|
+
list(options?: AppListOptions): Promise<ListResponse<AppEntity>>;
|
|
69
|
+
/**
|
|
70
|
+
* Regenerates the client secret for the app. Returns the app with
|
|
71
|
+
* clientSecret set once; store it securely.
|
|
72
|
+
*
|
|
73
|
+
* @param id - The app id.
|
|
74
|
+
* @returns The app including clientSecret.
|
|
75
|
+
*/
|
|
76
|
+
regenerateSecret(id: string): Promise<AppEntity>;
|
|
77
|
+
/**
|
|
78
|
+
* Builds the OAuth authorize URL to which the user should be redirected.
|
|
79
|
+
*
|
|
80
|
+
* @param params - Parameters for the authorize URL.
|
|
81
|
+
* @param params.baseUrl - API base URL (e.g. https://api.feeef.org/api/v1).
|
|
82
|
+
* @param params.clientId - The app client id.
|
|
83
|
+
* @param params.redirectUri - Redirect URI registered for the app.
|
|
84
|
+
* @param params.responseType - Must be 'code' for authorization code flow.
|
|
85
|
+
* @param params.scope - Optional list of scopes (space-separated in URL).
|
|
86
|
+
* @param params.state - Optional state for CSRF protection.
|
|
87
|
+
* @param params.codeChallenge - Optional PKCE code challenge.
|
|
88
|
+
* @param params.codeChallengeMethod - Optional 'S256' or 'plain'.
|
|
89
|
+
* @returns The full authorize URL.
|
|
90
|
+
*/
|
|
91
|
+
static buildAuthorizeUrl(params: {
|
|
92
|
+
baseUrl: string;
|
|
93
|
+
clientId: string;
|
|
94
|
+
redirectUri: string;
|
|
95
|
+
responseType: string;
|
|
96
|
+
scope?: string[];
|
|
97
|
+
state?: string;
|
|
98
|
+
codeChallenge?: string;
|
|
99
|
+
codeChallengeMethod?: string;
|
|
100
|
+
}): string;
|
|
101
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { AxiosInstance } from 'axios';
|
|
2
|
+
/**
|
|
3
|
+
* Promo entity (list item from GET /promos).
|
|
4
|
+
*/
|
|
5
|
+
export interface PromoEntity {
|
|
6
|
+
id: string;
|
|
7
|
+
code: string;
|
|
8
|
+
discount: Array<[number, number]>;
|
|
9
|
+
strict: boolean;
|
|
10
|
+
min_months: number | null;
|
|
11
|
+
count: number;
|
|
12
|
+
max: number | null;
|
|
13
|
+
starts_at: string | null;
|
|
14
|
+
ends_at: string | null;
|
|
15
|
+
referral_id: string | null;
|
|
16
|
+
created_at: string;
|
|
17
|
+
updated_at: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Result of POST /promos/validate.
|
|
21
|
+
*/
|
|
22
|
+
export interface PromoValidationResult {
|
|
23
|
+
valid: boolean;
|
|
24
|
+
reason?: 'invalid' | 'expired' | 'not_yet_valid' | 'max_uses';
|
|
25
|
+
code?: string;
|
|
26
|
+
discount?: Array<[number, number]>;
|
|
27
|
+
strict?: boolean;
|
|
28
|
+
minMonths?: number;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* List response for promos (backend returns { data, total, page, limit }).
|
|
32
|
+
*/
|
|
33
|
+
export interface PromoListResponse {
|
|
34
|
+
data: PromoEntity[];
|
|
35
|
+
total?: number;
|
|
36
|
+
page?: number;
|
|
37
|
+
limit?: number;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Input for creating a promo.
|
|
41
|
+
*/
|
|
42
|
+
export interface PromoCreateInput {
|
|
43
|
+
code: string;
|
|
44
|
+
discount: Array<[number, number]>;
|
|
45
|
+
strict: boolean;
|
|
46
|
+
min_months?: number | null;
|
|
47
|
+
max?: number | null;
|
|
48
|
+
starts_at?: string | null;
|
|
49
|
+
ends_at?: string | null;
|
|
50
|
+
referral_id?: string | null;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Repository for promo codes: list, validate, create.
|
|
54
|
+
*/
|
|
55
|
+
export declare class PromoRepository {
|
|
56
|
+
private client;
|
|
57
|
+
constructor(client: AxiosInstance);
|
|
58
|
+
/**
|
|
59
|
+
* Lists promos with optional pagination and validNow filter.
|
|
60
|
+
*/
|
|
61
|
+
list(params?: {
|
|
62
|
+
page?: number;
|
|
63
|
+
limit?: number;
|
|
64
|
+
validNow?: boolean;
|
|
65
|
+
}): Promise<PromoListResponse>;
|
|
66
|
+
/**
|
|
67
|
+
* Validates a promo code. Returns validation result with discount info or reason.
|
|
68
|
+
*/
|
|
69
|
+
validate(params: {
|
|
70
|
+
code: string;
|
|
71
|
+
storeId?: string;
|
|
72
|
+
}): Promise<PromoValidationResult>;
|
|
73
|
+
/**
|
|
74
|
+
* Creates a promo (admin). Returns the created promo.
|
|
75
|
+
*/
|
|
76
|
+
create(data: PromoCreateInput): Promise<PromoEntity>;
|
|
77
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { AxiosInstance } from 'axios';
|
|
2
|
+
import { StoreInvite, CreateStoreInviteInput, StoreMember } from '../../core/entities/store.js';
|
|
3
|
+
/**
|
|
4
|
+
* Repository for store invites. Exposed as `ff.stores.invites`.
|
|
5
|
+
* All methods require a store ID since invites are scoped to a store.
|
|
6
|
+
*/
|
|
7
|
+
export declare class StoreInvitesRepository {
|
|
8
|
+
private readonly client;
|
|
9
|
+
private readonly resource;
|
|
10
|
+
constructor(client: AxiosInstance, resource: string);
|
|
11
|
+
/**
|
|
12
|
+
* Lists invites for a store.
|
|
13
|
+
* @param storeId - The store ID.
|
|
14
|
+
* @param params - Optional filters (e.g. status).
|
|
15
|
+
* @returns A Promise that resolves to the list of invites.
|
|
16
|
+
*/
|
|
17
|
+
list(storeId: string, params?: {
|
|
18
|
+
status?: string;
|
|
19
|
+
}): Promise<StoreInvite[]>;
|
|
20
|
+
/**
|
|
21
|
+
* Creates a store invite (sends email to invitee).
|
|
22
|
+
* @param storeId - The store ID.
|
|
23
|
+
* @param data - The invite data.
|
|
24
|
+
* @returns A Promise that resolves to the created invite.
|
|
25
|
+
*/
|
|
26
|
+
create(storeId: string, data: CreateStoreInviteInput): Promise<StoreInvite>;
|
|
27
|
+
/**
|
|
28
|
+
* Gets invite details (public or full if authorized).
|
|
29
|
+
* @param storeId - The store ID.
|
|
30
|
+
* @param inviteId - The invite ID.
|
|
31
|
+
* @returns A Promise that resolves to the invite.
|
|
32
|
+
*/
|
|
33
|
+
get(storeId: string, inviteId: string): Promise<StoreInvite>;
|
|
34
|
+
/**
|
|
35
|
+
* Revokes a pending invite.
|
|
36
|
+
* @param storeId - The store ID.
|
|
37
|
+
* @param inviteId - The invite ID.
|
|
38
|
+
*/
|
|
39
|
+
revoke(storeId: string, inviteId: string): Promise<void>;
|
|
40
|
+
/**
|
|
41
|
+
* Accepts an invite (authenticated user's email must match invite email).
|
|
42
|
+
* @param storeId - The store ID.
|
|
43
|
+
* @param inviteId - The invite ID.
|
|
44
|
+
* @param token - The invite token from the email link.
|
|
45
|
+
* @returns A Promise that resolves to the created store member.
|
|
46
|
+
*/
|
|
47
|
+
accept(storeId: string, inviteId: string, token: string): Promise<StoreMember>;
|
|
48
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { AxiosInstance } from 'axios';
|
|
2
2
|
import { ModelRepository, ListResponse } from './repository.js';
|
|
3
|
-
import { StoreEntity, StoreSummary, StoreMember,
|
|
3
|
+
import { StoreEntity, StoreSummary, StoreMember, StoreSubscriptionType, AddStoreMemberInput, UpdateStoreMemberInput, StoreCreateInput, StoreUpdateInput } from '../../core/entities/store.js';
|
|
4
|
+
import { StoreInvitesRepository } from './store_invites_repository.js';
|
|
4
5
|
/**
|
|
5
6
|
* Options for listing stores
|
|
6
7
|
*/
|
|
@@ -78,50 +79,19 @@ export declare class StoreRepository extends ModelRepository<StoreEntity, StoreC
|
|
|
78
79
|
*/
|
|
79
80
|
removeMember(storeId: string, memberId: string): Promise<void>;
|
|
80
81
|
/**
|
|
81
|
-
*
|
|
82
|
-
* @param storeId - The store ID.
|
|
83
|
-
* @param data - The invite data.
|
|
84
|
-
* @returns A Promise that resolves to the created invite.
|
|
85
|
-
*/
|
|
86
|
-
createInvite(storeId: string, data: CreateStoreInviteInput): Promise<StoreInvite>;
|
|
87
|
-
/**
|
|
88
|
-
* Lists invites for a store.
|
|
89
|
-
* @param storeId - The store ID.
|
|
90
|
-
* @param params - Optional filters (e.g. status).
|
|
91
|
-
* @returns A Promise that resolves to the list of invites.
|
|
92
|
-
*/
|
|
93
|
-
listInvites(storeId: string, params?: {
|
|
94
|
-
status?: string;
|
|
95
|
-
}): Promise<StoreInvite[]>;
|
|
96
|
-
/**
|
|
97
|
-
* Revokes a pending invite.
|
|
98
|
-
* @param storeId - The store ID.
|
|
99
|
-
* @param inviteId - The invite ID.
|
|
100
|
-
*/
|
|
101
|
-
revokeInvite(storeId: string, inviteId: string): Promise<void>;
|
|
102
|
-
/**
|
|
103
|
-
* Gets invite details (public or full if authorized).
|
|
104
|
-
* @param storeId - The store ID.
|
|
105
|
-
* @param inviteId - The invite ID.
|
|
106
|
-
* @returns A Promise that resolves to the invite.
|
|
107
|
-
*/
|
|
108
|
-
getInvite(storeId: string, inviteId: string): Promise<StoreInvite>;
|
|
109
|
-
/**
|
|
110
|
-
* Accepts an invite (authenticated user's email must match invite email).
|
|
111
|
-
* @param storeId - The store ID.
|
|
112
|
-
* @param inviteId - The invite ID.
|
|
113
|
-
* @param token - The invite token from the email link.
|
|
114
|
-
* @returns A Promise that resolves to the created store member.
|
|
82
|
+
* Repository for store invites. Use e.g. `ff.stores.invites.list(storeId)`, `ff.stores.invites.create(storeId, data)`.
|
|
115
83
|
*/
|
|
116
|
-
|
|
84
|
+
get invites(): StoreInvitesRepository;
|
|
117
85
|
/**
|
|
118
86
|
* Upgrades or renews a store's subscription plan.
|
|
119
87
|
* @param id - The store ID.
|
|
120
88
|
* @param plan - The plan type to upgrade to.
|
|
121
89
|
* @param months - The number of months (1-12).
|
|
122
|
-
* @
|
|
90
|
+
* @param code - Optional promo code.
|
|
123
91
|
*/
|
|
124
|
-
upgrade(id: string, plan: StoreSubscriptionType, months: number
|
|
92
|
+
upgrade(id: string, plan: StoreSubscriptionType, months: number, options?: {
|
|
93
|
+
code?: string;
|
|
94
|
+
}): Promise<void>;
|
|
125
95
|
/**
|
|
126
96
|
* Purchases additional points for a store's subscription.
|
|
127
97
|
* @param id - The store ID.
|
package/build/src/index.d.ts
CHANGED
|
@@ -17,12 +17,15 @@ export * from './core/entities/city.js';
|
|
|
17
17
|
export * from './core/entities/currency.js';
|
|
18
18
|
export * from './core/entities/feedback.js';
|
|
19
19
|
export * from './feeef/repositories/repository.js';
|
|
20
|
+
export * from './feeef/repositories/apps.js';
|
|
20
21
|
export * from './feeef/repositories/deposits.js';
|
|
22
|
+
export * from './feeef/repositories/promos.js';
|
|
21
23
|
export * from './feeef/repositories/transfers.js';
|
|
22
24
|
export * from './feeef/repositories/shipping_prices.js';
|
|
23
25
|
export * from './feeef/repositories/shipping_methods.js';
|
|
24
26
|
export * from './feeef/repositories/users.js';
|
|
25
27
|
export * from './feeef/repositories/stores.js';
|
|
28
|
+
export * from './feeef/repositories/store_invites_repository.js';
|
|
26
29
|
export * from './feeef/repositories/products.js';
|
|
27
30
|
export * from './feeef/repositories/orders.js';
|
|
28
31
|
export * from './feeef/repositories/image_prompt_templates.js';
|
|
@@ -33,8 +36,10 @@ export * from './feeef/repositories/countries.js';
|
|
|
33
36
|
export * from './feeef/repositories/states.js';
|
|
34
37
|
export * from './feeef/repositories/cities.js';
|
|
35
38
|
export * from './feeef/repositories/currencies.js';
|
|
39
|
+
export type { AppEntity, AppCreateInput, AppUpdateInput } from './feeef/repositories/apps.js';
|
|
36
40
|
export type { TransferEntity, TransferCreateInput, TransferUpdateInput, TransferType, TransferListOptions, } from './feeef/repositories/transfers.js';
|
|
37
41
|
export type { DepositEntity, DepositCreateInput, DepositUpdateInput, DepositStatus, DepositListOptions, PayPalOrderResponse, PayPalCaptureResponse, } from './feeef/repositories/deposits.js';
|
|
42
|
+
export type { PromoEntity, PromoValidationResult, PromoListResponse, PromoCreateInput, } from './feeef/repositories/promos.js';
|
|
38
43
|
export * from './core/embadded/address.js';
|
|
39
44
|
export * from './core/embadded/category.js';
|
|
40
45
|
export * from './core/embadded/contact.js';
|