@sneat/extension-splitus-contract 0.0.1 → 0.2.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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sneat-extension-splitus-contract.mjs","sources":["../../../../../../libs/extensions/splitus/contract/src/lib/services/splitus-service.ts","../../../../../../libs/extensions/splitus/contract/src/sneat-extension-splitus-contract.ts"],"sourcesContent":["import { InjectionToken } from '@angular/core';\nimport { Observable } from 'rxjs';\n\nexport type CurrencyCode = 'EUR' | 'USD';\n\
|
|
1
|
+
{"version":3,"file":"sneat-extension-splitus-contract.mjs","sources":["../../../../../../libs/extensions/splitus/contract/src/lib/services/splitus-service.ts","../../../../../../libs/extensions/splitus/contract/src/sneat-extension-splitus-contract.ts"],"sourcesContent":["import { InjectionToken } from '@angular/core';\nimport { Observable } from 'rxjs';\nimport type {\n ICreateSplitRequest,\n ICreateSplitResponse,\n ISplit,\n ISplitListItem,\n} from '../models/splitus-models';\n\nexport type CurrencyCode = 'EUR' | 'USD';\n\n// ISplitusService is the runtime-light contract the splitus components\n// depend on. Members mirror the concrete SplitusService's public surface\n// exactly; the implementation lives in the -internal lib and is provided via\n// the SPLITUS_SERVICE token below.\n//\n// Splitus persists no balance of its own — the payer/participants/shares\n// given to createSplit are posted to the real backend (POST\n// /api4splitus/create-split), which records the expense and posts Debtus\n// transfers as the only who-owes-what records. getSplit/getSplits read the\n// settled state back verbatim from that same API — there is no client-side\n// settled cache (see ISplitParticipant.status in splitus-models.ts).\nexport interface ISplitusService {\n /** REAL: POST /api4splitus/create-split. Payer is the authenticated user. */\n createSplit(request: ICreateSplitRequest): Observable<ICreateSplitResponse>;\n\n /** REAL: GET /api4splitus/split?spaceID=&id= */\n getSplit(spaceID: string, id: string): Observable<ISplit>;\n\n /** REAL: GET /api4splitus/splits?spaceID= */\n getSplits(spaceID: string): Observable<ISplitListItem[]>;\n}\n\nexport const SPLITUS_SERVICE = new InjectionToken<ISplitusService>('SplitusService');\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;MAiCa,eAAe,GAAG,IAAI,cAAc,CAAkB,gBAAgB;;ACjCnF;;AAEG;;;;"}
|
package/package.json
CHANGED
|
@@ -1,17 +1,89 @@
|
|
|
1
1
|
import { InjectionToken } from '@angular/core';
|
|
2
2
|
import { Observable } from 'rxjs';
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
/** Mirrors models4splitus.SplitMode (backend/splitus/models4splitus). */
|
|
5
|
+
type SplitMode = 'equally' | 'exact-amount' | 'percentage';
|
|
6
|
+
/**
|
|
7
|
+
* One participant's custom share for `exact-amount` / `percentage` split
|
|
8
|
+
* modes. An omitted/empty `contactID` denotes the payer's own share. Ignored
|
|
9
|
+
* (and may be omitted) for `equally`, which the backend computes itself.
|
|
10
|
+
*/
|
|
11
|
+
interface ISplitShare {
|
|
12
|
+
readonly contactID?: string;
|
|
13
|
+
/** Decimal string, e.g. "35.00" — required for `exact-amount`. */
|
|
14
|
+
readonly amount?: string;
|
|
15
|
+
/** Decimal string, e.g. "33.34" — required for `percentage`. */
|
|
16
|
+
readonly percent?: string;
|
|
17
|
+
}
|
|
18
|
+
interface ICreateSplitRequest {
|
|
19
|
+
readonly spaceID: string;
|
|
20
|
+
readonly title?: string;
|
|
21
|
+
readonly currency: CurrencyCode;
|
|
22
|
+
/** Decimal string, e.g. "90.00" — the total expense. */
|
|
23
|
+
readonly amount: string;
|
|
24
|
+
/** Defaults to `equally` server-side when omitted. */
|
|
25
|
+
readonly splitMode?: SplitMode;
|
|
26
|
+
/**
|
|
27
|
+
* contactus contact IDs of the space. The payer (the authenticated user)
|
|
28
|
+
* is always a participant and must NOT be listed here.
|
|
29
|
+
*/
|
|
30
|
+
readonly participantContactIDs: string[];
|
|
31
|
+
/** Required for `exact-amount` / `percentage`; ignored for `equally`. */
|
|
32
|
+
readonly shares?: ISplitShare[];
|
|
33
|
+
}
|
|
34
|
+
interface ICreateSplitTransfer {
|
|
35
|
+
readonly id: string;
|
|
36
|
+
readonly contactID: string;
|
|
37
|
+
readonly amount: number;
|
|
38
|
+
}
|
|
39
|
+
interface ICreateSplitResponse {
|
|
40
|
+
readonly id: string;
|
|
41
|
+
/**
|
|
42
|
+
* The Debtus transfers holding the balances — the only who-owes-what
|
|
43
|
+
* records for this split. Splitus itself persists no balance.
|
|
44
|
+
*/
|
|
45
|
+
readonly transfers: ICreateSplitTransfer[];
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* "settled" or "outstanding", derived server-side by reading the linked
|
|
49
|
+
* Debtus transfers — never computed or cached on the client.
|
|
50
|
+
*/
|
|
51
|
+
type SplitShareStatus = 'settled' | 'outstanding';
|
|
52
|
+
interface ISplitParticipant {
|
|
53
|
+
readonly contactID?: string;
|
|
54
|
+
readonly userID?: string;
|
|
55
|
+
readonly name: string;
|
|
56
|
+
readonly share: number;
|
|
57
|
+
readonly isPayer?: boolean;
|
|
58
|
+
readonly status: SplitShareStatus;
|
|
10
59
|
}
|
|
60
|
+
interface ISplit {
|
|
61
|
+
readonly id: string;
|
|
62
|
+
readonly title?: string;
|
|
63
|
+
readonly currency: CurrencyCode;
|
|
64
|
+
readonly amount: number;
|
|
65
|
+
readonly status: string;
|
|
66
|
+
readonly participants: ISplitParticipant[];
|
|
67
|
+
}
|
|
68
|
+
interface ISplitListItem {
|
|
69
|
+
readonly id: string;
|
|
70
|
+
readonly title?: string;
|
|
71
|
+
readonly amount: number;
|
|
72
|
+
readonly currency: CurrencyCode;
|
|
73
|
+
readonly status: string;
|
|
74
|
+
readonly membersCount: number;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
type CurrencyCode = 'EUR' | 'USD';
|
|
11
78
|
interface ISplitusService {
|
|
12
|
-
|
|
79
|
+
/** REAL: POST /api4splitus/create-split. Payer is the authenticated user. */
|
|
80
|
+
createSplit(request: ICreateSplitRequest): Observable<ICreateSplitResponse>;
|
|
81
|
+
/** REAL: GET /api4splitus/split?spaceID=&id= */
|
|
82
|
+
getSplit(spaceID: string, id: string): Observable<ISplit>;
|
|
83
|
+
/** REAL: GET /api4splitus/splits?spaceID= */
|
|
84
|
+
getSplits(spaceID: string): Observable<ISplitListItem[]>;
|
|
13
85
|
}
|
|
14
86
|
declare const SPLITUS_SERVICE: InjectionToken<ISplitusService>;
|
|
15
87
|
|
|
16
88
|
export { SPLITUS_SERVICE };
|
|
17
|
-
export type { CurrencyCode,
|
|
89
|
+
export type { CurrencyCode, ICreateSplitRequest, ICreateSplitResponse, ICreateSplitTransfer, ISplit, ISplitListItem, ISplitParticipant, ISplitShare, ISplitusService, SplitMode, SplitShareStatus };
|