@sneat/extension-splitus-contract 0.0.1 → 0.2.1

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 CHANGED
@@ -1,8 +1,7 @@
1
1
  # @sneat/extension-splitus-contract
2
2
 
3
- The `contract` tier of the **splitus** extension (extension library-architecture
4
- convention). See the repo root `README.md` → Frontend for the tier table.
3
+ Splitus extension contract library.
5
4
 
6
- ## Running unit tests
5
+ ## Provenance
7
6
 
8
- Run `npx nx test extension-splitus-contract` to execute the unit tests.
7
+ Migrated from sneat-co/debtus (npm continuity from @sneat/extension-splitus-contract@0.2.0).
@@ -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\nexport interface ICreateSplitRecordRequest {\n spaceID: string;\n contactID: string;\n currency: CurrencyCode;\n amount: number;\n}\n\n// ISplitusService is the runtime-light contract the splitus components depend on.\n// Members mirror the concrete SplitusService's public surface exactly; the\n// implementation lives in the -internal lib and is provided via the\n// SPLITUS_SERVICE token below.\nexport interface ISplitusService {\n createSplitRecord(request: ICreateSplitRecordRequest): Observable<string>;\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":";;MAoBa,eAAe,GAAG,IAAI,cAAc,CAAkB,gBAAgB;;ACpBnF;;AAEG;;;;"}
1
+ {"version":3,"file":"sneat-extension-splitus-contract.mjs","sources":["../../../../libs/splitus/src/services.ts","../../../../libs/splitus/src/sneat-extension-splitus-contract.ts"],"sourcesContent":["import { InjectionToken } from '@angular/core';\nimport { Observable } from 'rxjs';\nimport { ICreateSplitRequest, ICreateSplitResponse, ISplit, ISplitListItem } from './dto';\n\nexport interface ISplitusService {\n /** REAL: POST /api4splitus/create-split. Payer is the authenticated user. */\n createSplit(request: ICreateSplitRequest): Observable<ICreateSplitResponse>;\n /** REAL: GET /api4splitus/split?spaceID=&id= */\n getSplit(spaceID: string, id: string): Observable<ISplit>;\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":";;MAaa,eAAe,GAAG,IAAI,cAAc,CAAkB,gBAAgB;;ACbnF;;AAEG;;"}
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@sneat/extension-splitus-contract",
3
- "version": "0.0.1",
3
+ "version": "0.2.1",
4
+ "publishConfig": {
5
+ "access": "public"
6
+ },
4
7
  "peerDependencies": {
5
8
  "@angular/core": "^21.0.0",
6
9
  "rxjs": "^7.0.0"
7
10
  },
8
11
  "sideEffects": false,
9
- "publishConfig": {
10
- "access": "public"
11
- },
12
12
  "module": "fesm2022/sneat-extension-splitus-contract.mjs",
13
13
  "typings": "types/sneat-extension-splitus-contract.d.ts",
14
14
  "exports": {
@@ -1,17 +1,89 @@
1
1
  import { InjectionToken } from '@angular/core';
2
2
  import { Observable } from 'rxjs';
3
3
 
4
+ /** Mirrors models4splitus.SplitMode (backend/splitus/models4splitus). */
5
+ type SplitMode = 'equally' | 'exact-amount' | 'percentage';
4
6
  type CurrencyCode = 'EUR' | 'USD';
5
- interface ICreateSplitRecordRequest {
6
- spaceID: string;
7
- contactID: string;
8
- currency: CurrencyCode;
9
- amount: number;
7
+ /**
8
+ * One participant's custom share for `exact-amount` / `percentage` split
9
+ * modes. An omitted/empty `contactID` denotes the payer's own share. Ignored
10
+ * (and may be omitted) for `equally`, which the backend computes itself.
11
+ */
12
+ interface ISplitShare {
13
+ readonly contactID?: string;
14
+ /** Decimal string, e.g. "35.00" — required for `exact-amount`. */
15
+ readonly amount?: string;
16
+ /** Decimal string, e.g. "33.34" — required for `percentage`. */
17
+ readonly percent?: string;
10
18
  }
19
+ interface ICreateSplitRequest {
20
+ readonly spaceID: string;
21
+ readonly title?: string;
22
+ readonly currency: CurrencyCode;
23
+ /** Decimal string, e.g. "90.00" — the total expense. */
24
+ readonly amount: string;
25
+ /** Defaults to `equally` server-side when omitted. */
26
+ readonly splitMode?: SplitMode;
27
+ /**
28
+ * contactus contact IDs of the space. The payer (the authenticated user)
29
+ * is always a participant and must NOT be listed here.
30
+ */
31
+ readonly participantContactIDs: string[];
32
+ /** Required for `exact-amount` / `percentage`; ignored for `equally`. */
33
+ readonly shares?: ISplitShare[];
34
+ }
35
+ interface ICreateSplitTransfer {
36
+ readonly id: string;
37
+ readonly contactID: string;
38
+ readonly amount: number;
39
+ }
40
+ interface ICreateSplitResponse {
41
+ readonly id: string;
42
+ /**
43
+ * The Debtus transfers holding the balances — the only who-owes-what
44
+ * records for this split. Splitus itself persists no balance.
45
+ */
46
+ readonly transfers: ICreateSplitTransfer[];
47
+ }
48
+ /**
49
+ * "settled" or "outstanding", derived server-side by reading the linked
50
+ * Debtus transfers — never computed or cached on the client.
51
+ */
52
+ type SplitShareStatus = 'settled' | 'outstanding';
53
+ interface ISplitParticipant {
54
+ readonly contactID?: string;
55
+ readonly userID?: string;
56
+ readonly name: string;
57
+ readonly share: number;
58
+ readonly isPayer?: boolean;
59
+ readonly status: SplitShareStatus;
60
+ }
61
+ interface ISplit {
62
+ readonly id: string;
63
+ readonly title?: string;
64
+ readonly currency: CurrencyCode;
65
+ readonly amount: number;
66
+ readonly status: string;
67
+ readonly participants: ISplitParticipant[];
68
+ }
69
+ interface ISplitListItem {
70
+ readonly id: string;
71
+ readonly title?: string;
72
+ readonly amount: number;
73
+ readonly currency: CurrencyCode;
74
+ readonly status: string;
75
+ readonly membersCount: number;
76
+ }
77
+
11
78
  interface ISplitusService {
12
- createSplitRecord(request: ICreateSplitRecordRequest): Observable<string>;
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, ICreateSplitRecordRequest, ISplitusService };
89
+ export type { CurrencyCode, ICreateSplitRequest, ICreateSplitResponse, ICreateSplitTransfer, ISplit, ISplitListItem, ISplitParticipant, ISplitShare, ISplitusService, SplitMode, SplitShareStatus };