@sneat/extension-yardius-contract 0.2.0 → 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 +10 -0
- package/fesm2022/sneat-extension-yardius-contract.mjs +239 -0
- package/fesm2022/sneat-extension-yardius-contract.mjs.map +1 -0
- package/package.json +16 -32
- package/types/sneat-extension-yardius-contract.d.ts +207 -0
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -9
- package/dist/lib/assetus-visibility.d.ts +0 -2
- package/dist/lib/assetus-visibility.js +0 -19
- package/dist/lib/borrow-state.d.ts +0 -5
- package/dist/lib/borrow-state.js +0 -49
- package/dist/lib/friendship.d.ts +0 -42
- package/dist/lib/friendship.js +0 -6
- package/dist/lib/giveaway-state.d.ts +0 -5
- package/dist/lib/giveaway-state.js +0 -36
- package/dist/lib/index.d.ts +0 -10
- package/dist/lib/index.js +0 -10
- package/dist/lib/listing-request.d.ts +0 -11
- package/dist/lib/listing-request.js +0 -17
- package/dist/lib/listing-visibility.d.ts +0 -8
- package/dist/lib/listing-visibility.js +0 -54
- package/dist/lib/listing.d.ts +0 -108
- package/dist/lib/listing.js +0 -15
- package/dist/lib/listings-endpoint.d.ts +0 -15
- package/dist/lib/listings-endpoint.js +0 -1
- package/dist/lib/state-transitions.d.ts +0 -2
- package/dist/lib/state-transitions.js +0 -7
- package/dist/lib/transaction-log.d.ts +0 -8
- package/dist/lib/transaction-log.js +0 -14
package/README.md
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# @sneat/extension-yardius-contract
|
|
2
|
+
|
|
3
|
+
Public Yardius DTOs, contexts, service interfaces, and dependency-injection
|
|
4
|
+
tokens. Lending state machines, borrow mechanics, and UI implementations remain
|
|
5
|
+
in the private Yardius repository.
|
|
6
|
+
|
|
7
|
+
## Provenance
|
|
8
|
+
|
|
9
|
+
Migrated from `sneat-co/ext-yardius` (`frontend/`), commit
|
|
10
|
+
`16091847efc937aab087f24d4ab4c4353fc46a30` (`origin/main`, 2026-08-26 read).
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
import { InjectionToken } from '@angular/core';
|
|
2
|
+
|
|
3
|
+
// The Assetus asset-visibility values, mirrored here as wire values so the
|
|
4
|
+
// listing-visibility ceiling (see `listing-visibility.ts`) can be encoded as
|
|
5
|
+
// shared data with zero runtime dependencies.
|
|
6
|
+
//
|
|
7
|
+
// Source of truth for the VALUES is the pinned assetus-mvp contract
|
|
8
|
+
// (`AssetVisibility` in the `@sneat/extension-assetus-contract` lib):
|
|
9
|
+
// spec display names `Private` / `Family` / `Friends` / `Friends of Friends` /
|
|
10
|
+
// `Specific Space` / `Public` are persisted as the lowercase snake_case wire
|
|
11
|
+
// values below. Yardius only READS asset visibility (REQ
|
|
12
|
+
// assetus-write-boundary) — this type exists so both the Yardius frontend and
|
|
13
|
+
// backend consume the ceiling mapping from this single package.
|
|
14
|
+
const ASSETUS_VISIBILITIES = [
|
|
15
|
+
'private',
|
|
16
|
+
'family',
|
|
17
|
+
'friends',
|
|
18
|
+
'friends_of_friends',
|
|
19
|
+
'specific_space',
|
|
20
|
+
'public',
|
|
21
|
+
];
|
|
22
|
+
|
|
23
|
+
const YARDIUS_FRIENDSHIP_SERVICE = new InjectionToken('YardiusFriendshipService');
|
|
24
|
+
const BEFRIEND_SPACE_PAGE_PATH = 'befriend';
|
|
25
|
+
function friendshipInvitePath(inviteID, pin) {
|
|
26
|
+
return `${BEFRIEND_SPACE_PAGE_PATH}?${new URLSearchParams({ id: inviteID, pin }).toString()}`;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// A Listing's own visibility, per REQ listing-visibility-ceiling (spec display
|
|
30
|
+
// names `Private` / `Members` / `Friends`, persisted as the wire values
|
|
31
|
+
// below):
|
|
32
|
+
// - 'private' — visible only to members of the owning Space;
|
|
33
|
+
// - 'members' — visible to members of the owning Space (reserved distinction
|
|
34
|
+
// from 'private' for future member-subset control; in MVP the two resolve
|
|
35
|
+
// to the same audience, and 'members' is the default);
|
|
36
|
+
// - 'friends' — additionally visible to members of befriended Spaces.
|
|
37
|
+
const LISTING_VISIBILITIES = ['private', 'members', 'friends'];
|
|
38
|
+
// Per REQ listing-visibility-ceiling: `members` is the default listing
|
|
39
|
+
// visibility.
|
|
40
|
+
const DEFAULT_LISTING_VISIBILITY = 'members';
|
|
41
|
+
function listingVisibilityLabel(visibility) {
|
|
42
|
+
switch (visibility) {
|
|
43
|
+
case 'private':
|
|
44
|
+
return 'Private';
|
|
45
|
+
case 'members':
|
|
46
|
+
return 'Members';
|
|
47
|
+
case 'friends':
|
|
48
|
+
return 'Friends';
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
// The asset's Assetus visibility is a CEILING on the listing's visibility,
|
|
52
|
+
// per this exact mapping from REQ listing-visibility-ceiling:
|
|
53
|
+
//
|
|
54
|
+
// | Asset visibility (Assetus) | Permitted listing visibilities |
|
|
55
|
+
// |------------------------------------------|--------------------------------|
|
|
56
|
+
// | Private | Private |
|
|
57
|
+
// | Family | Private, Members |
|
|
58
|
+
// | Specific Space | Private (MVP simplification) |
|
|
59
|
+
// | Friends, Friends of Friends, Public | Private, Members, Friends |
|
|
60
|
+
//
|
|
61
|
+
// Encoded as data so frontend and backend enforce the same source of truth.
|
|
62
|
+
// Publishing with a listing visibility not permitted here MUST be rejected
|
|
63
|
+
// with an actionable error telling the user to raise the asset's visibility
|
|
64
|
+
// in Assetus first.
|
|
65
|
+
const LISTING_VISIBILITY_CEILING = {
|
|
66
|
+
private: ['private'],
|
|
67
|
+
family: ['private', 'members'],
|
|
68
|
+
specific_space: ['private'], // MVP simplification.
|
|
69
|
+
friends: ['private', 'members', 'friends'],
|
|
70
|
+
friends_of_friends: ['private', 'members', 'friends'],
|
|
71
|
+
public: ['private', 'members', 'friends'],
|
|
72
|
+
};
|
|
73
|
+
// The listing visibilities permitted for an asset with the given Assetus
|
|
74
|
+
// visibility. Pure lookup over `LISTING_VISIBILITY_CEILING`.
|
|
75
|
+
function allowedListingVisibilities(assetVisibility) {
|
|
76
|
+
return LISTING_VISIBILITY_CEILING[assetVisibility];
|
|
77
|
+
}
|
|
78
|
+
// True when a listing with `listingVisibility` may be published for an asset
|
|
79
|
+
// whose Assetus visibility is `assetVisibility`.
|
|
80
|
+
function isListingVisibilityAllowed(assetVisibility, listingVisibility) {
|
|
81
|
+
return LISTING_VISIBILITY_CEILING[assetVisibility].includes(listingVisibility);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// True when `from → to` is a legal transition per the given table. Pure and
|
|
85
|
+
// dependency-free by design; a state never legally "transitions" to itself
|
|
86
|
+
// (staying put — e.g. a give-away remaining `claimed` after a failed Assetus
|
|
87
|
+
// transfer — is the absence of a transition, not a transition).
|
|
88
|
+
function canTransition(table, from, to) {
|
|
89
|
+
return table[from].includes(to);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// Borrow-listing lifecycle states, per REQ borrow-lifecycle (spec display
|
|
93
|
+
// names `Available → Requested → Approved → Borrowed → Returned → Closed`,
|
|
94
|
+
// persisted as the wire values below):
|
|
95
|
+
// - 'available' — open, no pending requests;
|
|
96
|
+
// - 'requested' — ≥1 request pending; the Listing stays visible and accepts
|
|
97
|
+
// further requests;
|
|
98
|
+
// - 'approved' — a member of the owning Space approved exactly one request;
|
|
99
|
+
// all other pending requests are automatically declined and no further
|
|
100
|
+
// requests are accepted;
|
|
101
|
+
// - 'borrowed' — a member of the owning Space confirmed handover;
|
|
102
|
+
// - 'returned' — a member of the owning Space confirmed the item is back;
|
|
103
|
+
// - 'closed' — terminal; immediately follows 'returned' (or an
|
|
104
|
+
// owner-cancel — see REQ owner-cancel).
|
|
105
|
+
const BORROW_STATES = [
|
|
106
|
+
'available',
|
|
107
|
+
'requested',
|
|
108
|
+
'approved',
|
|
109
|
+
'borrowed',
|
|
110
|
+
'returned',
|
|
111
|
+
'closed',
|
|
112
|
+
];
|
|
113
|
+
// The legal borrow transitions, per REQ borrow-lifecycle + REQ owner-cancel.
|
|
114
|
+
// Any transition not listed here MUST be rejected.
|
|
115
|
+
//
|
|
116
|
+
// available → requested first request arrives
|
|
117
|
+
// available → closed owner cancels (before 'borrowed' — legal)
|
|
118
|
+
// requested → approved owner approves exactly one request
|
|
119
|
+
// requested → available the only pending request is withdrawn
|
|
120
|
+
// requested → closed owner cancels; all pending requests declined
|
|
121
|
+
// approved → borrowed owner confirms handover
|
|
122
|
+
// approved → closed owner cancels (still before 'borrowed')
|
|
123
|
+
// borrowed → returned owner confirms the item is back; a 'borrowed'
|
|
124
|
+
// Listing MUST NOT be cancellable — 'returned' is
|
|
125
|
+
// its only exit
|
|
126
|
+
// returned → closed immediate, automatic
|
|
127
|
+
// closed → (terminal)
|
|
128
|
+
const BORROW_STATE_TRANSITIONS = {
|
|
129
|
+
available: ['requested', 'closed'],
|
|
130
|
+
requested: ['approved', 'available', 'closed'],
|
|
131
|
+
approved: ['borrowed', 'closed'],
|
|
132
|
+
borrowed: ['returned'],
|
|
133
|
+
returned: ['closed'],
|
|
134
|
+
closed: [],
|
|
135
|
+
};
|
|
136
|
+
// True when `from → to` is a legal borrow-lifecycle transition.
|
|
137
|
+
function canTransitionBorrow(from, to) {
|
|
138
|
+
return canTransition(BORROW_STATE_TRANSITIONS, from, to);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// Give-away-listing lifecycle states, per REQ giveaway-lifecycle (spec
|
|
142
|
+
// display names `Available → Claimed → Transferred → Closed`, persisted as
|
|
143
|
+
// the wire values below):
|
|
144
|
+
// - 'available' — open; eligible viewers claim (claims arriving do NOT
|
|
145
|
+
// change the state — only the owner's selection does);
|
|
146
|
+
// - 'claimed' — a member of the owning Space selected exactly one
|
|
147
|
+
// claimant; other claims automatically declined;
|
|
148
|
+
// - 'transferred' — the Assetus ownership transfer to the claimant's Space
|
|
149
|
+
// succeeded (Assetus appends its own `Transferred` history event); if the
|
|
150
|
+
// transfer FAILS the Listing stays 'claimed' — staying put is not a
|
|
151
|
+
// transition;
|
|
152
|
+
// - 'closed' — terminal; immediately follows 'transferred' (or an
|
|
153
|
+
// owner-cancel — see REQ owner-cancel).
|
|
154
|
+
const GIVEAWAY_STATES = ['available', 'claimed', 'transferred', 'closed'];
|
|
155
|
+
// The legal give-away transitions, per REQ giveaway-lifecycle +
|
|
156
|
+
// REQ owner-cancel. Any transition not listed here MUST be rejected.
|
|
157
|
+
//
|
|
158
|
+
// available → claimed owner selects exactly one claimant
|
|
159
|
+
// available → closed owner cancels (before 'transferred' — legal)
|
|
160
|
+
// claimed → transferred Assetus ownership transfer succeeded on
|
|
161
|
+
// confirmed handover (on failure the Listing
|
|
162
|
+
// remains 'claimed' — no transition)
|
|
163
|
+
// claimed → closed owner cancels; the claim is declined
|
|
164
|
+
// transferred → closed immediate, automatic
|
|
165
|
+
// closed → (terminal)
|
|
166
|
+
const GIVEAWAY_STATE_TRANSITIONS = {
|
|
167
|
+
available: ['claimed', 'closed'],
|
|
168
|
+
claimed: ['transferred', 'closed'],
|
|
169
|
+
transferred: ['closed'],
|
|
170
|
+
closed: [],
|
|
171
|
+
};
|
|
172
|
+
// True when `from → to` is a legal give-away-lifecycle transition.
|
|
173
|
+
function canTransitionGiveaway(from, to) {
|
|
174
|
+
return canTransition(GIVEAWAY_STATE_TRANSITIONS, from, to);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
const LISTING_TYPES = ['borrow', 'giveaway'];
|
|
178
|
+
function isOpenListingState(state) {
|
|
179
|
+
return state !== 'closed';
|
|
180
|
+
}
|
|
181
|
+
function listingTypeLabel(type) {
|
|
182
|
+
return type === 'borrow' ? 'Borrow' : 'Give away';
|
|
183
|
+
}
|
|
184
|
+
function listingStateLabel(state) {
|
|
185
|
+
return state.charAt(0).toUpperCase() + state.slice(1);
|
|
186
|
+
}
|
|
187
|
+
function listingRequestStatusLabel(status) {
|
|
188
|
+
return status.charAt(0).toUpperCase() + status.slice(1);
|
|
189
|
+
}
|
|
190
|
+
const YARDIUS_LISTING_SERVICE = new InjectionToken('YardiusListingService');
|
|
191
|
+
|
|
192
|
+
// The exact set of lifecycle event types recorded in a Listing's per-listing
|
|
193
|
+
// transaction log, per REQ transaction-log.
|
|
194
|
+
const YARDIUS_EVENT_TYPES = [
|
|
195
|
+
'publish',
|
|
196
|
+
'request',
|
|
197
|
+
'withdraw',
|
|
198
|
+
'approve',
|
|
199
|
+
'decline',
|
|
200
|
+
'handover',
|
|
201
|
+
'return',
|
|
202
|
+
'claim',
|
|
203
|
+
'transfer',
|
|
204
|
+
'cancel',
|
|
205
|
+
];
|
|
206
|
+
|
|
207
|
+
// Status of a borrow request or give-away claim:
|
|
208
|
+
// - 'pending' — awaiting the owning Space's decision;
|
|
209
|
+
// - 'approved' — the owner approved this request (borrow) or selected this
|
|
210
|
+
// claimant (give-away); all other pending requests/claims on the Listing
|
|
211
|
+
// are automatically declined (REQ borrow-lifecycle /
|
|
212
|
+
// REQ giveaway-lifecycle);
|
|
213
|
+
// - 'declined' — declined by the owner, auto-declined because another
|
|
214
|
+
// request was approved, cancelled with the Listing (REQ owner-cancel), or
|
|
215
|
+
// auto-declined on friendship removal (REQ friendship-removal);
|
|
216
|
+
// - 'withdrawn' — the requester withdrew their own pending request
|
|
217
|
+
// (REQ borrow-request).
|
|
218
|
+
const LISTING_REQUEST_STATUSES = [
|
|
219
|
+
'pending',
|
|
220
|
+
'approved',
|
|
221
|
+
'declined',
|
|
222
|
+
'withdrawn',
|
|
223
|
+
];
|
|
224
|
+
|
|
225
|
+
// @sneat/extension-yardius-contract — frozen cross-repo contract surface for the yardius extension.
|
|
226
|
+
//
|
|
227
|
+
// Shared DTOs (listings, transaction-log entries, request/claim shapes, the
|
|
228
|
+
// listings-endpoint contract), lifecycle state enums with their legal
|
|
229
|
+
// transition tables, and the listing-visibility ceiling mapping are exported
|
|
230
|
+
// from here so that both the sneat-go backend models and the Sneat super-app
|
|
231
|
+
// extension libs resolve every shared model from this single package. No
|
|
232
|
+
// consumer may re-declare these.
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* Generated bundle index. Do not edit.
|
|
236
|
+
*/
|
|
237
|
+
|
|
238
|
+
export { ASSETUS_VISIBILITIES, BEFRIEND_SPACE_PAGE_PATH, BORROW_STATES, BORROW_STATE_TRANSITIONS, DEFAULT_LISTING_VISIBILITY, GIVEAWAY_STATES, GIVEAWAY_STATE_TRANSITIONS, LISTING_REQUEST_STATUSES, LISTING_TYPES, LISTING_VISIBILITIES, LISTING_VISIBILITY_CEILING, YARDIUS_EVENT_TYPES, YARDIUS_FRIENDSHIP_SERVICE, YARDIUS_LISTING_SERVICE, allowedListingVisibilities, canTransition, canTransitionBorrow, canTransitionGiveaway, friendshipInvitePath, isListingVisibilityAllowed, isOpenListingState, listingRequestStatusLabel, listingStateLabel, listingTypeLabel, listingVisibilityLabel };
|
|
239
|
+
//# sourceMappingURL=sneat-extension-yardius-contract.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sneat-extension-yardius-contract.mjs","sources":["../../../../libs/yardius/src/lib/assetus-visibility.ts","../../../../libs/yardius/src/lib/friendship.ts","../../../../libs/yardius/src/lib/listing-visibility.ts","../../../../libs/yardius/src/lib/state-transitions.ts","../../../../libs/yardius/src/lib/borrow-state.ts","../../../../libs/yardius/src/lib/giveaway-state.ts","../../../../libs/yardius/src/lib/listing.ts","../../../../libs/yardius/src/lib/transaction-log.ts","../../../../libs/yardius/src/lib/listing-request.ts","../../../../libs/yardius/src/index.ts","../../../../libs/yardius/src/sneat-extension-yardius-contract.ts"],"sourcesContent":["// The Assetus asset-visibility values, mirrored here as wire values so the\n// listing-visibility ceiling (see `listing-visibility.ts`) can be encoded as\n// shared data with zero runtime dependencies.\n//\n// Source of truth for the VALUES is the pinned assetus-mvp contract\n// (`AssetVisibility` in the `@sneat/extension-assetus-contract` lib):\n// spec display names `Private` / `Family` / `Friends` / `Friends of Friends` /\n// `Specific Space` / `Public` are persisted as the lowercase snake_case wire\n// values below. Yardius only READS asset visibility (REQ\n// assetus-write-boundary) — this type exists so both the Yardius frontend and\n// backend consume the ceiling mapping from this single package.\nexport const ASSETUS_VISIBILITIES = [\n\t'private',\n\t'family',\n\t'friends',\n\t'friends_of_friends',\n\t'specific_space',\n\t'public',\n] as const;\n\nexport type AssetusVisibility = (typeof ASSETUS_VISIBILITIES)[number];\n","import { InjectionToken } from '@angular/core';\nimport type { Observable } from 'rxjs';\n\nexport type SpaceFriendshipRole = 'friend' | 'neighbour';\n\nexport interface ICreateFriendshipInviteRequest {\n\treadonly spaceID: string;\n\treadonly role?: SpaceFriendshipRole;\n}\n\nexport interface ICreateFriendshipInviteResponse {\n\treadonly id: string;\n\treadonly pin: string;\n}\n\nexport interface IAcceptFriendshipInviteRequest {\n\treadonly inviteID: string;\n\treadonly pin: string;\n\treadonly toSpaceID: string;\n}\n\nexport interface IAcceptFriendshipInviteResponse {\n\treadonly invitingSpaceID: string;\n\treadonly toSpaceID: string;\n\treadonly role: SpaceFriendshipRole;\n}\n\nexport interface IFriendSpace {\n\treadonly id: string;\n\treadonly roles: readonly SpaceFriendshipRole[];\n\treadonly title?: string;\n}\n\nexport interface IListFriendSpacesResponse {\n\treadonly friendSpaces?: readonly IFriendSpace[];\n}\n\nexport interface IRemoveFriendshipRequest {\n\treadonly spaceID: string;\n\treadonly friendSpaceID: string;\n}\n\nexport interface IYardiusFriendshipService {\n\tcreateFriendshipInvite(\n\t\trequest: ICreateFriendshipInviteRequest,\n\t): Observable<ICreateFriendshipInviteResponse>;\n\tacceptFriendshipInvite(\n\t\trequest: IAcceptFriendshipInviteRequest,\n\t): Observable<IAcceptFriendshipInviteResponse>;\n\tlistFriendSpaces(spaceID: string): Observable<IListFriendSpacesResponse>;\n\tremoveFriendship(request: IRemoveFriendshipRequest): Observable<void>;\n}\n\nexport const YARDIUS_FRIENDSHIP_SERVICE =\n\tnew InjectionToken<IYardiusFriendshipService>('YardiusFriendshipService');\n\nexport const BEFRIEND_SPACE_PAGE_PATH = 'befriend';\n\nexport function friendshipInvitePath(inviteID: string, pin: string): string {\n\treturn `${BEFRIEND_SPACE_PAGE_PATH}?${new URLSearchParams({ id: inviteID, pin }).toString()}`;\n}\n","import { AssetusVisibility } from './assetus-visibility.js';\n\n// A Listing's own visibility, per REQ listing-visibility-ceiling (spec display\n// names `Private` / `Members` / `Friends`, persisted as the wire values\n// below):\n// - 'private' — visible only to members of the owning Space;\n// - 'members' — visible to members of the owning Space (reserved distinction\n// from 'private' for future member-subset control; in MVP the two resolve\n// to the same audience, and 'members' is the default);\n// - 'friends' — additionally visible to members of befriended Spaces.\nexport const LISTING_VISIBILITIES = ['private', 'members', 'friends'] as const;\n\nexport type ListingVisibility = (typeof LISTING_VISIBILITIES)[number];\n\n// Per REQ listing-visibility-ceiling: `members` is the default listing\n// visibility.\nexport const DEFAULT_LISTING_VISIBILITY: ListingVisibility = 'members';\n\nexport function listingVisibilityLabel(visibility: ListingVisibility): string {\n\tswitch (visibility) {\n\t\tcase 'private':\n\t\t\treturn 'Private';\n\t\tcase 'members':\n\t\t\treturn 'Members';\n\t\tcase 'friends':\n\t\t\treturn 'Friends';\n\t}\n}\n\n// The asset's Assetus visibility is a CEILING on the listing's visibility,\n// per this exact mapping from REQ listing-visibility-ceiling:\n//\n// | Asset visibility (Assetus) | Permitted listing visibilities |\n// |------------------------------------------|--------------------------------|\n// | Private | Private |\n// | Family | Private, Members |\n// | Specific Space | Private (MVP simplification) |\n// | Friends, Friends of Friends, Public | Private, Members, Friends |\n//\n// Encoded as data so frontend and backend enforce the same source of truth.\n// Publishing with a listing visibility not permitted here MUST be rejected\n// with an actionable error telling the user to raise the asset's visibility\n// in Assetus first.\nexport const LISTING_VISIBILITY_CEILING: Readonly<\n\tRecord<AssetusVisibility, readonly ListingVisibility[]>\n> = {\n\tprivate: ['private'],\n\tfamily: ['private', 'members'],\n\tspecific_space: ['private'], // MVP simplification.\n\tfriends: ['private', 'members', 'friends'],\n\tfriends_of_friends: ['private', 'members', 'friends'],\n\tpublic: ['private', 'members', 'friends'],\n};\n\n// The listing visibilities permitted for an asset with the given Assetus\n// visibility. Pure lookup over `LISTING_VISIBILITY_CEILING`.\nexport function allowedListingVisibilities(\n\tassetVisibility: AssetusVisibility,\n): readonly ListingVisibility[] {\n\treturn LISTING_VISIBILITY_CEILING[assetVisibility];\n}\n\n// True when a listing with `listingVisibility` may be published for an asset\n// whose Assetus visibility is `assetVisibility`.\nexport function isListingVisibilityAllowed(\n\tassetVisibility: AssetusVisibility,\n\tlistingVisibility: ListingVisibility,\n): boolean {\n\treturn LISTING_VISIBILITY_CEILING[assetVisibility].includes(listingVisibility);\n}\n","// A lifecycle's legal transitions as data: for each state, the exact set of\n// states it may move to. Both lifecycles (`borrow-state.ts`,\n// `giveaway-state.ts`) publish their table in this shape so frontend and\n// backend validate transitions from the same source of truth. Any transition\n// not present in the table MUST be rejected.\nexport type StateTransitionTable<TState extends string> = Readonly<\n\tRecord<TState, readonly TState[]>\n>;\n\n// True when `from → to` is a legal transition per the given table. Pure and\n// dependency-free by design; a state never legally \"transitions\" to itself\n// (staying put — e.g. a give-away remaining `claimed` after a failed Assetus\n// transfer — is the absence of a transition, not a transition).\nexport function canTransition<TState extends string>(\n\ttable: StateTransitionTable<TState>,\n\tfrom: TState,\n\tto: TState,\n): boolean {\n\treturn table[from].includes(to);\n}\n","import { canTransition, StateTransitionTable } from './state-transitions.js';\n\n// Borrow-listing lifecycle states, per REQ borrow-lifecycle (spec display\n// names `Available → Requested → Approved → Borrowed → Returned → Closed`,\n// persisted as the wire values below):\n// - 'available' — open, no pending requests;\n// - 'requested' — ≥1 request pending; the Listing stays visible and accepts\n// further requests;\n// - 'approved' — a member of the owning Space approved exactly one request;\n// all other pending requests are automatically declined and no further\n// requests are accepted;\n// - 'borrowed' — a member of the owning Space confirmed handover;\n// - 'returned' — a member of the owning Space confirmed the item is back;\n// - 'closed' — terminal; immediately follows 'returned' (or an\n// owner-cancel — see REQ owner-cancel).\nexport const BORROW_STATES = [\n\t'available',\n\t'requested',\n\t'approved',\n\t'borrowed',\n\t'returned',\n\t'closed',\n] as const;\n\nexport type BorrowState = (typeof BORROW_STATES)[number];\n\n// The legal borrow transitions, per REQ borrow-lifecycle + REQ owner-cancel.\n// Any transition not listed here MUST be rejected.\n//\n// available → requested first request arrives\n// available → closed owner cancels (before 'borrowed' — legal)\n// requested → approved owner approves exactly one request\n// requested → available the only pending request is withdrawn\n// requested → closed owner cancels; all pending requests declined\n// approved → borrowed owner confirms handover\n// approved → closed owner cancels (still before 'borrowed')\n// borrowed → returned owner confirms the item is back; a 'borrowed'\n// Listing MUST NOT be cancellable — 'returned' is\n// its only exit\n// returned → closed immediate, automatic\n// closed → (terminal)\nexport const BORROW_STATE_TRANSITIONS: StateTransitionTable<BorrowState> = {\n\tavailable: ['requested', 'closed'],\n\trequested: ['approved', 'available', 'closed'],\n\tapproved: ['borrowed', 'closed'],\n\tborrowed: ['returned'],\n\treturned: ['closed'],\n\tclosed: [],\n};\n\n// True when `from → to` is a legal borrow-lifecycle transition.\nexport function canTransitionBorrow(from: BorrowState, to: BorrowState): boolean {\n\treturn canTransition(BORROW_STATE_TRANSITIONS, from, to);\n}\n","import { canTransition, StateTransitionTable } from './state-transitions.js';\n\n// Give-away-listing lifecycle states, per REQ giveaway-lifecycle (spec\n// display names `Available → Claimed → Transferred → Closed`, persisted as\n// the wire values below):\n// - 'available' — open; eligible viewers claim (claims arriving do NOT\n// change the state — only the owner's selection does);\n// - 'claimed' — a member of the owning Space selected exactly one\n// claimant; other claims automatically declined;\n// - 'transferred' — the Assetus ownership transfer to the claimant's Space\n// succeeded (Assetus appends its own `Transferred` history event); if the\n// transfer FAILS the Listing stays 'claimed' — staying put is not a\n// transition;\n// - 'closed' — terminal; immediately follows 'transferred' (or an\n// owner-cancel — see REQ owner-cancel).\nexport const GIVEAWAY_STATES = ['available', 'claimed', 'transferred', 'closed'] as const;\n\nexport type GiveawayState = (typeof GIVEAWAY_STATES)[number];\n\n// The legal give-away transitions, per REQ giveaway-lifecycle +\n// REQ owner-cancel. Any transition not listed here MUST be rejected.\n//\n// available → claimed owner selects exactly one claimant\n// available → closed owner cancels (before 'transferred' — legal)\n// claimed → transferred Assetus ownership transfer succeeded on\n// confirmed handover (on failure the Listing\n// remains 'claimed' — no transition)\n// claimed → closed owner cancels; the claim is declined\n// transferred → closed immediate, automatic\n// closed → (terminal)\nexport const GIVEAWAY_STATE_TRANSITIONS: StateTransitionTable<GiveawayState> = {\n\tavailable: ['claimed', 'closed'],\n\tclaimed: ['transferred', 'closed'],\n\ttransferred: ['closed'],\n\tclosed: [],\n};\n\n// True when `from → to` is a legal give-away-lifecycle transition.\nexport function canTransitionGiveaway(from: GiveawayState, to: GiveawayState): boolean {\n\treturn canTransition(GIVEAWAY_STATE_TRANSITIONS, from, to);\n}\n","import { InjectionToken } from '@angular/core';\nimport type { Observable } from 'rxjs';\n\nimport type { BorrowState } from './borrow-state.js';\nimport type { GiveawayState } from './giveaway-state.js';\nimport type { ListingRequestStatus } from './listing-request.js';\nimport type { ListingVisibility } from './listing-visibility.js';\nimport type { IGetListingsResponse } from './listings-endpoint.js';\n\nexport const LISTING_TYPES = ['borrow', 'giveaway'] as const;\nexport type ListingType = (typeof LISTING_TYPES)[number];\nexport type ListingState = BorrowState | GiveawayState;\n\nexport function isOpenListingState(state: ListingState): boolean {\n\treturn state !== 'closed';\n}\n\nexport function listingTypeLabel(type: ListingType): string {\n\treturn type === 'borrow' ? 'Borrow' : 'Give away';\n}\n\nexport function listingStateLabel(state: ListingState): string {\n\treturn state.charAt(0).toUpperCase() + state.slice(1);\n}\n\nexport function listingRequestStatusLabel(status: ListingRequestStatus): string {\n\treturn status.charAt(0).toUpperCase() + status.slice(1);\n}\n\nexport interface IListingDbo {\n\treadonly assetID: string;\n\treadonly type: ListingType;\n\treadonly state: ListingState;\n\treadonly visibility: ListingVisibility;\n\treadonly createdAt?: string;\n\treadonly createdBy?: string;\n}\n\ninterface IListingIdentity {\n\treadonly id: string;\n\treadonly spaceID: string;\n}\n\nexport interface IBorrowListingDto extends IListingDbo, IListingIdentity {\n\treadonly type: 'borrow';\n\treadonly state: BorrowState;\n}\n\nexport interface IGiveawayListingDto extends IListingDbo, IListingIdentity {\n\treadonly type: 'giveaway';\n\treadonly state: GiveawayState;\n}\n\nexport type IListingDto = IBorrowListingDto | IGiveawayListingDto;\n\nexport interface IPublishListingRequest {\n\treadonly spaceID: string;\n\treadonly assetID: string;\n\treadonly type: ListingType;\n\treadonly visibility?: ListingVisibility;\n}\n\nexport interface IListingActionResponse {\n\treadonly id: string;\n\treadonly listing: IListingDbo;\n}\n\nexport interface IListingActionRequest {\n\treadonly spaceID: string;\n\treadonly listingID: string;\n}\n\nexport interface IListingRequestActionRequest extends IListingActionRequest {\n\treadonly requestID: string;\n}\n\nexport interface IApproveRequestResponse extends IListingActionResponse {\n\treadonly declinedRequestIDs?: readonly string[];\n}\n\nexport interface IRequestToBorrowRequest {\n\treadonly spaceID: string;\n\treadonly ownerSpaceID: string;\n\treadonly listingID: string;\n}\n\nexport interface IWithdrawRequestRequest extends IRequestToBorrowRequest {\n\treadonly requestID: string;\n}\n\nexport type AvailableListingSource = 'member' | 'friend';\n\nexport interface IAvailableListingDto {\n\treadonly spaceID: string;\n\treadonly spaceTitle?: string;\n\treadonly listingID: string;\n\treadonly assetID: string;\n\treadonly type: ListingType;\n\treadonly state: ListingState;\n\treadonly visibility: ListingVisibility;\n\treadonly source: AvailableListingSource;\n}\n\nexport interface IMyRequestDto {\n\treadonly id: string;\n\treadonly ownerSpaceID: string;\n\treadonly ownerSpaceTitle?: string;\n\treadonly listingID: string;\n\treadonly assetID: string;\n\treadonly type: ListingType;\n\treadonly status: ListingRequestStatus;\n\treadonly createdAt: string;\n}\n\nexport interface IGetMyRequestsResponse {\n\treadonly requests: readonly IMyRequestDto[];\n}\n\nexport interface IGetListingResult {\n\treadonly listing?: IListingDto;\n\treadonly requests?: readonly import('./listing-request.js').IListingRequestDto[];\n}\n\nexport interface IYardiusListingService {\n\tpublishListing(request: IPublishListingRequest): Observable<IListingActionResponse>;\n\tcancelListing(request: IListingActionRequest): Observable<IListingActionResponse>;\n\trequestToBorrow(request: IRequestToBorrowRequest): Observable<IListingActionResponse>;\n\tclaimListing(request: IRequestToBorrowRequest): Observable<IListingActionResponse>;\n\twithdrawRequest(request: IWithdrawRequestRequest): Observable<IListingActionResponse>;\n\tapproveRequest(request: IListingRequestActionRequest): Observable<IApproveRequestResponse>;\n\tdeclineRequest(request: IListingRequestActionRequest): Observable<IListingActionResponse>;\n\tconfirmHandover(request: IListingActionRequest): Observable<IListingActionResponse>;\n\tconfirmReturn(request: IListingActionRequest): Observable<IListingActionResponse>;\n\tgetAvailableListings(): Observable<IGetListingsResponse>;\n\tgetOurListings(spaceID: string): Observable<readonly IListingDto[]>;\n\tgetListing(spaceID: string, listingID: string): Observable<IGetListingResult>;\n\tgetMyRequests(): Observable<IGetMyRequestsResponse>;\n}\n\nexport const YARDIUS_LISTING_SERVICE =\n\tnew InjectionToken<IYardiusListingService>('YardiusListingService');\n","// The exact set of lifecycle event types recorded in a Listing's per-listing\n// transaction log, per REQ transaction-log.\nexport const YARDIUS_EVENT_TYPES = [\n\t'publish',\n\t'request',\n\t'withdraw',\n\t'approve',\n\t'decline',\n\t'handover',\n\t'return',\n\t'claim',\n\t'transfer',\n\t'cancel',\n] as const;\n\nexport type YardiusEventType = (typeof YARDIUS_EVENT_TYPES)[number];\n\n// One entry in a Listing's transaction log, per REQ transaction-log: every\n// lifecycle event is appended with its event type, timestamp, and acting\n// member. The log is APPEND-ONLY — existing entries MUST NOT be mutated or\n// removed by any normal operation (which is also why every field here is\n// readonly).\n//\n// Persistence (backend concern, not part of this DTO's shape): the log lives\n// with its Listing under `/spaces/{spaceID}/ext/yardius/...`\n// (REQ persistence-convention).\nexport interface ITransactionLogEntry {\n\treadonly event: YardiusEventType;\n\n\t// ISO timestamp string, server-assigned when the event is appended.\n\treadonly at: string;\n\n\t// The acting member: their Space plus their member (contactus contact) ID\n\t// within that Space. For owner-side events (publish, approve, decline,\n\t// handover, return, cancel) this is a member of the owning Space; for\n\t// requester-side events (request, withdraw, claim) it is a member of the\n\t// requesting/claiming Space.\n\treadonly actingMemberSpaceID: string;\n\treadonly actingMemberID: string;\n}\n","// Status of a borrow request or give-away claim:\n// - 'pending' — awaiting the owning Space's decision;\n// - 'approved' — the owner approved this request (borrow) or selected this\n// claimant (give-away); all other pending requests/claims on the Listing\n// are automatically declined (REQ borrow-lifecycle /\n// REQ giveaway-lifecycle);\n// - 'declined' — declined by the owner, auto-declined because another\n// request was approved, cancelled with the Listing (REQ owner-cancel), or\n// auto-declined on friendship removal (REQ friendship-removal);\n// - 'withdrawn' — the requester withdrew their own pending request\n// (REQ borrow-request).\nexport const LISTING_REQUEST_STATUSES = [\n\t'pending',\n\t'approved',\n\t'declined',\n\t'withdrawn',\n] as const;\n\nexport type ListingRequestStatus = (typeof LISTING_REQUEST_STATUSES)[number];\n\n// A request to borrow (on a `borrow` Listing) or a claim (on a `giveaway`\n// Listing) — one shared shape; which it is follows from the Listing's `type`.\n//\n// Per REQ borrow-request, requesters are members of a Space that can see the\n// Listing per its visibility, EXCLUDING members of the owning Space, and\n// owning-Space members see each pending request with the requester's name and\n// Space — hence the requester identity + display fields below.\nexport interface IListingRequestDto {\n\treadonly id: string;\n\n\t// The requester/claimant: their Space plus their member (contactus\n\t// contact) ID within that Space. Never a member of the owning Space.\n\treadonly requesterSpaceID: string;\n\treadonly requesterMemberID: string;\n\n\t// Display labels resolved by the backend (contactus member identity /\n\t// space title) so owning-Space members can render \"who is asking\" without\n\t// a cross-space read. Optional: absent when the caller can resolve them\n\t// locally.\n\treadonly requesterTitle?: string;\n\treadonly requesterSpaceTitle?: string;\n\n\treadonly status: ListingRequestStatus;\n\n\t// ISO timestamp string, server-assigned at creation.\n\treadonly createdAt: string;\n}\n","// @sneat/extension-yardius-contract — frozen cross-repo contract surface for the yardius extension.\n//\n// Shared DTOs (listings, transaction-log entries, request/claim shapes, the\n// listings-endpoint contract), lifecycle state enums with their legal\n// transition tables, and the listing-visibility ceiling mapping are exported\n// from here so that both the sneat-go backend models and the Sneat super-app\n// extension libs resolve every shared model from this single package. No\n// consumer may re-declare these.\n\nexport * from './lib/index.js';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAM,oBAAoB,GAAG;IACnC,SAAS;IACT,QAAQ;IACR,SAAS;IACT,oBAAoB;IACpB,gBAAgB;IAChB,QAAQ;;;MCoCI,0BAA0B,GACtC,IAAI,cAAc,CAA4B,0BAA0B;AAElE,MAAM,wBAAwB,GAAG;AAElC,SAAU,oBAAoB,CAAC,QAAgB,EAAE,GAAW,EAAA;AACjE,IAAA,OAAO,GAAG,wBAAwB,CAAA,CAAA,EAAI,IAAI,eAAe,CAAC,EAAE,EAAE,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC,CAAC,QAAQ,EAAE,EAAE;AAC9F;;AC1DA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAM,oBAAoB,GAAG,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS;AAIpE;AACA;AACO,MAAM,0BAA0B,GAAsB;AAEvD,SAAU,sBAAsB,CAAC,UAA6B,EAAA;IACnE,QAAQ,UAAU;AACjB,QAAA,KAAK,SAAS;AACb,YAAA,OAAO,SAAS;AACjB,QAAA,KAAK,SAAS;AACb,YAAA,OAAO,SAAS;AACjB,QAAA,KAAK,SAAS;AACb,YAAA,OAAO,SAAS;;AAEnB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAM,0BAA0B,GAEnC;IACH,OAAO,EAAE,CAAC,SAAS,CAAC;AACpB,IAAA,MAAM,EAAE,CAAC,SAAS,EAAE,SAAS,CAAC;AAC9B,IAAA,cAAc,EAAE,CAAC,SAAS,CAAC;AAC3B,IAAA,OAAO,EAAE,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,CAAC;AAC1C,IAAA,kBAAkB,EAAE,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,CAAC;AACrD,IAAA,MAAM,EAAE,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,CAAC;;AAG1C;AACA;AACM,SAAU,0BAA0B,CACzC,eAAkC,EAAA;AAElC,IAAA,OAAO,0BAA0B,CAAC,eAAe,CAAC;AACnD;AAEA;AACA;AACM,SAAU,0BAA0B,CACzC,eAAkC,EAClC,iBAAoC,EAAA;IAEpC,OAAO,0BAA0B,CAAC,eAAe,CAAC,CAAC,QAAQ,CAAC,iBAAiB,CAAC;AAC/E;;AC5DA;AACA;AACA;AACA;SACgB,aAAa,CAC5B,KAAmC,EACnC,IAAY,EACZ,EAAU,EAAA;IAEV,OAAO,KAAK,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC;AAChC;;ACjBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAM,aAAa,GAAG;IAC5B,WAAW;IACX,WAAW;IACX,UAAU;IACV,UAAU;IACV,UAAU;IACV,QAAQ;;AAKT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAM,wBAAwB,GAAsC;AAC1E,IAAA,SAAS,EAAE,CAAC,WAAW,EAAE,QAAQ,CAAC;AAClC,IAAA,SAAS,EAAE,CAAC,UAAU,EAAE,WAAW,EAAE,QAAQ,CAAC;AAC9C,IAAA,QAAQ,EAAE,CAAC,UAAU,EAAE,QAAQ,CAAC;IAChC,QAAQ,EAAE,CAAC,UAAU,CAAC;IACtB,QAAQ,EAAE,CAAC,QAAQ,CAAC;AACpB,IAAA,MAAM,EAAE,EAAE;;AAGX;AACM,SAAU,mBAAmB,CAAC,IAAiB,EAAE,EAAe,EAAA;IACrE,OAAO,aAAa,CAAC,wBAAwB,EAAE,IAAI,EAAE,EAAE,CAAC;AACzD;;ACnDA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAM,eAAe,GAAG,CAAC,WAAW,EAAE,SAAS,EAAE,aAAa,EAAE,QAAQ;AAI/E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAM,0BAA0B,GAAwC;AAC9E,IAAA,SAAS,EAAE,CAAC,SAAS,EAAE,QAAQ,CAAC;AAChC,IAAA,OAAO,EAAE,CAAC,aAAa,EAAE,QAAQ,CAAC;IAClC,WAAW,EAAE,CAAC,QAAQ,CAAC;AACvB,IAAA,MAAM,EAAE,EAAE;;AAGX;AACM,SAAU,qBAAqB,CAAC,IAAmB,EAAE,EAAiB,EAAA;IAC3E,OAAO,aAAa,CAAC,0BAA0B,EAAE,IAAI,EAAE,EAAE,CAAC;AAC3D;;MC/Ba,aAAa,GAAG,CAAC,QAAQ,EAAE,UAAU;AAI5C,SAAU,kBAAkB,CAAC,KAAmB,EAAA;IACrD,OAAO,KAAK,KAAK,QAAQ;AAC1B;AAEM,SAAU,gBAAgB,CAAC,IAAiB,EAAA;IACjD,OAAO,IAAI,KAAK,QAAQ,GAAG,QAAQ,GAAG,WAAW;AAClD;AAEM,SAAU,iBAAiB,CAAC,KAAmB,EAAA;AACpD,IAAA,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;AACtD;AAEM,SAAU,yBAAyB,CAAC,MAA4B,EAAA;AACrE,IAAA,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;AACxD;MAgHa,uBAAuB,GACnC,IAAI,cAAc,CAAyB,uBAAuB;;AC5InE;AACA;AACO,MAAM,mBAAmB,GAAG;IAClC,SAAS;IACT,SAAS;IACT,UAAU;IACV,SAAS;IACT,SAAS;IACT,UAAU;IACV,QAAQ;IACR,OAAO;IACP,UAAU;IACV,QAAQ;;;ACZT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAM,wBAAwB,GAAG;IACvC,SAAS;IACT,UAAU;IACV,UAAU;IACV,WAAW;;;ACfZ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACPA;;AAEG;;"}
|
package/package.json
CHANGED
|
@@ -1,43 +1,27 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sneat/extension-yardius-contract",
|
|
3
|
-
"version": "0.2.
|
|
4
|
-
"description": "Frozen cross-repo contract surface (shared DTOs, consts, briefs) for the yardius Sneat extension",
|
|
5
|
-
"license": "MIT",
|
|
6
|
-
"repository": {
|
|
7
|
-
"type": "git",
|
|
8
|
-
"url": "https://github.com/sneat-co/ext-yardius.git"
|
|
9
|
-
},
|
|
10
|
-
"type": "module",
|
|
11
|
-
"main": "./dist/index.js",
|
|
12
|
-
"types": "./dist/index.d.ts",
|
|
13
|
-
"exports": {
|
|
14
|
-
".": {
|
|
15
|
-
"types": "./dist/index.d.ts",
|
|
16
|
-
"default": "./dist/index.js"
|
|
17
|
-
}
|
|
18
|
-
},
|
|
19
|
-
"files": [
|
|
20
|
-
"dist"
|
|
21
|
-
],
|
|
3
|
+
"version": "0.2.1",
|
|
22
4
|
"publishConfig": {
|
|
23
5
|
"access": "public"
|
|
24
6
|
},
|
|
25
|
-
"devDependencies": {
|
|
26
|
-
"@angular/core": "^21.0.0",
|
|
27
|
-
"@nx/js": "22.7.5",
|
|
28
|
-
"nx": "22.7.5",
|
|
29
|
-
"rxjs": "^7.0.0",
|
|
30
|
-
"typescript": "~5.9.3",
|
|
31
|
-
"vite": "^7.2.7",
|
|
32
|
-
"vitest": "4.0.9"
|
|
33
|
-
},
|
|
34
7
|
"peerDependencies": {
|
|
35
8
|
"@angular/core": "^21.0.0",
|
|
36
9
|
"rxjs": "^7.0.0"
|
|
37
10
|
},
|
|
38
|
-
"
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
11
|
+
"sideEffects": false,
|
|
12
|
+
"module": "fesm2022/sneat-extension-yardius-contract.mjs",
|
|
13
|
+
"typings": "types/sneat-extension-yardius-contract.d.ts",
|
|
14
|
+
"exports": {
|
|
15
|
+
"./package.json": {
|
|
16
|
+
"default": "./package.json"
|
|
17
|
+
},
|
|
18
|
+
".": {
|
|
19
|
+
"types": "./types/sneat-extension-yardius-contract.d.ts",
|
|
20
|
+
"default": "./fesm2022/sneat-extension-yardius-contract.mjs"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"type": "module",
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"tslib": "^2.3.0"
|
|
42
26
|
}
|
|
43
27
|
}
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import { InjectionToken } from '@angular/core';
|
|
2
|
+
import { Observable } from 'rxjs';
|
|
3
|
+
|
|
4
|
+
declare const ASSETUS_VISIBILITIES: readonly ["private", "family", "friends", "friends_of_friends", "specific_space", "public"];
|
|
5
|
+
type AssetusVisibility = (typeof ASSETUS_VISIBILITIES)[number];
|
|
6
|
+
|
|
7
|
+
type SpaceFriendshipRole = 'friend' | 'neighbour';
|
|
8
|
+
interface ICreateFriendshipInviteRequest {
|
|
9
|
+
readonly spaceID: string;
|
|
10
|
+
readonly role?: SpaceFriendshipRole;
|
|
11
|
+
}
|
|
12
|
+
interface ICreateFriendshipInviteResponse {
|
|
13
|
+
readonly id: string;
|
|
14
|
+
readonly pin: string;
|
|
15
|
+
}
|
|
16
|
+
interface IAcceptFriendshipInviteRequest {
|
|
17
|
+
readonly inviteID: string;
|
|
18
|
+
readonly pin: string;
|
|
19
|
+
readonly toSpaceID: string;
|
|
20
|
+
}
|
|
21
|
+
interface IAcceptFriendshipInviteResponse {
|
|
22
|
+
readonly invitingSpaceID: string;
|
|
23
|
+
readonly toSpaceID: string;
|
|
24
|
+
readonly role: SpaceFriendshipRole;
|
|
25
|
+
}
|
|
26
|
+
interface IFriendSpace {
|
|
27
|
+
readonly id: string;
|
|
28
|
+
readonly roles: readonly SpaceFriendshipRole[];
|
|
29
|
+
readonly title?: string;
|
|
30
|
+
}
|
|
31
|
+
interface IListFriendSpacesResponse {
|
|
32
|
+
readonly friendSpaces?: readonly IFriendSpace[];
|
|
33
|
+
}
|
|
34
|
+
interface IRemoveFriendshipRequest {
|
|
35
|
+
readonly spaceID: string;
|
|
36
|
+
readonly friendSpaceID: string;
|
|
37
|
+
}
|
|
38
|
+
interface IYardiusFriendshipService {
|
|
39
|
+
createFriendshipInvite(request: ICreateFriendshipInviteRequest): Observable<ICreateFriendshipInviteResponse>;
|
|
40
|
+
acceptFriendshipInvite(request: IAcceptFriendshipInviteRequest): Observable<IAcceptFriendshipInviteResponse>;
|
|
41
|
+
listFriendSpaces(spaceID: string): Observable<IListFriendSpacesResponse>;
|
|
42
|
+
removeFriendship(request: IRemoveFriendshipRequest): Observable<void>;
|
|
43
|
+
}
|
|
44
|
+
declare const YARDIUS_FRIENDSHIP_SERVICE: InjectionToken<IYardiusFriendshipService>;
|
|
45
|
+
declare const BEFRIEND_SPACE_PAGE_PATH = "befriend";
|
|
46
|
+
declare function friendshipInvitePath(inviteID: string, pin: string): string;
|
|
47
|
+
|
|
48
|
+
declare const LISTING_VISIBILITIES: readonly ["private", "members", "friends"];
|
|
49
|
+
type ListingVisibility = (typeof LISTING_VISIBILITIES)[number];
|
|
50
|
+
declare const DEFAULT_LISTING_VISIBILITY: ListingVisibility;
|
|
51
|
+
declare function listingVisibilityLabel(visibility: ListingVisibility): string;
|
|
52
|
+
declare const LISTING_VISIBILITY_CEILING: Readonly<Record<AssetusVisibility, readonly ListingVisibility[]>>;
|
|
53
|
+
declare function allowedListingVisibilities(assetVisibility: AssetusVisibility): readonly ListingVisibility[];
|
|
54
|
+
declare function isListingVisibilityAllowed(assetVisibility: AssetusVisibility, listingVisibility: ListingVisibility): boolean;
|
|
55
|
+
|
|
56
|
+
type StateTransitionTable<TState extends string> = Readonly<Record<TState, readonly TState[]>>;
|
|
57
|
+
declare function canTransition<TState extends string>(table: StateTransitionTable<TState>, from: TState, to: TState): boolean;
|
|
58
|
+
|
|
59
|
+
declare const BORROW_STATES: readonly ["available", "requested", "approved", "borrowed", "returned", "closed"];
|
|
60
|
+
type BorrowState = (typeof BORROW_STATES)[number];
|
|
61
|
+
declare const BORROW_STATE_TRANSITIONS: StateTransitionTable<BorrowState>;
|
|
62
|
+
declare function canTransitionBorrow(from: BorrowState, to: BorrowState): boolean;
|
|
63
|
+
|
|
64
|
+
declare const GIVEAWAY_STATES: readonly ["available", "claimed", "transferred", "closed"];
|
|
65
|
+
type GiveawayState = (typeof GIVEAWAY_STATES)[number];
|
|
66
|
+
declare const GIVEAWAY_STATE_TRANSITIONS: StateTransitionTable<GiveawayState>;
|
|
67
|
+
declare function canTransitionGiveaway(from: GiveawayState, to: GiveawayState): boolean;
|
|
68
|
+
|
|
69
|
+
declare const LISTING_REQUEST_STATUSES: readonly ["pending", "approved", "declined", "withdrawn"];
|
|
70
|
+
type ListingRequestStatus = (typeof LISTING_REQUEST_STATUSES)[number];
|
|
71
|
+
interface IListingRequestDto {
|
|
72
|
+
readonly id: string;
|
|
73
|
+
readonly requesterSpaceID: string;
|
|
74
|
+
readonly requesterMemberID: string;
|
|
75
|
+
readonly requesterTitle?: string;
|
|
76
|
+
readonly requesterSpaceTitle?: string;
|
|
77
|
+
readonly status: ListingRequestStatus;
|
|
78
|
+
readonly createdAt: string;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
type IGetListingsRequest = Record<string, never>;
|
|
82
|
+
type ListingsGroupReason = 'member' | 'friend';
|
|
83
|
+
interface IListingsSpaceGroup {
|
|
84
|
+
readonly spaceID: string;
|
|
85
|
+
readonly spaceTitle: string;
|
|
86
|
+
readonly reason: ListingsGroupReason;
|
|
87
|
+
readonly listings: readonly IListingDto[];
|
|
88
|
+
}
|
|
89
|
+
interface IGetListingsResponse {
|
|
90
|
+
/** Grouped response used by the relationship-first listing endpoint. */
|
|
91
|
+
readonly groups?: readonly IListingsSpaceGroup[];
|
|
92
|
+
/** Flat response used by the existing `get_available_listings` facade. */
|
|
93
|
+
readonly listings?: readonly IAvailableListingDto[];
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
declare const LISTING_TYPES: readonly ["borrow", "giveaway"];
|
|
97
|
+
type ListingType = (typeof LISTING_TYPES)[number];
|
|
98
|
+
type ListingState = BorrowState | GiveawayState;
|
|
99
|
+
declare function isOpenListingState(state: ListingState): boolean;
|
|
100
|
+
declare function listingTypeLabel(type: ListingType): string;
|
|
101
|
+
declare function listingStateLabel(state: ListingState): string;
|
|
102
|
+
declare function listingRequestStatusLabel(status: ListingRequestStatus): string;
|
|
103
|
+
interface IListingDbo {
|
|
104
|
+
readonly assetID: string;
|
|
105
|
+
readonly type: ListingType;
|
|
106
|
+
readonly state: ListingState;
|
|
107
|
+
readonly visibility: ListingVisibility;
|
|
108
|
+
readonly createdAt?: string;
|
|
109
|
+
readonly createdBy?: string;
|
|
110
|
+
}
|
|
111
|
+
interface IListingIdentity {
|
|
112
|
+
readonly id: string;
|
|
113
|
+
readonly spaceID: string;
|
|
114
|
+
}
|
|
115
|
+
interface IBorrowListingDto extends IListingDbo, IListingIdentity {
|
|
116
|
+
readonly type: 'borrow';
|
|
117
|
+
readonly state: BorrowState;
|
|
118
|
+
}
|
|
119
|
+
interface IGiveawayListingDto extends IListingDbo, IListingIdentity {
|
|
120
|
+
readonly type: 'giveaway';
|
|
121
|
+
readonly state: GiveawayState;
|
|
122
|
+
}
|
|
123
|
+
type IListingDto = IBorrowListingDto | IGiveawayListingDto;
|
|
124
|
+
interface IPublishListingRequest {
|
|
125
|
+
readonly spaceID: string;
|
|
126
|
+
readonly assetID: string;
|
|
127
|
+
readonly type: ListingType;
|
|
128
|
+
readonly visibility?: ListingVisibility;
|
|
129
|
+
}
|
|
130
|
+
interface IListingActionResponse {
|
|
131
|
+
readonly id: string;
|
|
132
|
+
readonly listing: IListingDbo;
|
|
133
|
+
}
|
|
134
|
+
interface IListingActionRequest {
|
|
135
|
+
readonly spaceID: string;
|
|
136
|
+
readonly listingID: string;
|
|
137
|
+
}
|
|
138
|
+
interface IListingRequestActionRequest extends IListingActionRequest {
|
|
139
|
+
readonly requestID: string;
|
|
140
|
+
}
|
|
141
|
+
interface IApproveRequestResponse extends IListingActionResponse {
|
|
142
|
+
readonly declinedRequestIDs?: readonly string[];
|
|
143
|
+
}
|
|
144
|
+
interface IRequestToBorrowRequest {
|
|
145
|
+
readonly spaceID: string;
|
|
146
|
+
readonly ownerSpaceID: string;
|
|
147
|
+
readonly listingID: string;
|
|
148
|
+
}
|
|
149
|
+
interface IWithdrawRequestRequest extends IRequestToBorrowRequest {
|
|
150
|
+
readonly requestID: string;
|
|
151
|
+
}
|
|
152
|
+
type AvailableListingSource = 'member' | 'friend';
|
|
153
|
+
interface IAvailableListingDto {
|
|
154
|
+
readonly spaceID: string;
|
|
155
|
+
readonly spaceTitle?: string;
|
|
156
|
+
readonly listingID: string;
|
|
157
|
+
readonly assetID: string;
|
|
158
|
+
readonly type: ListingType;
|
|
159
|
+
readonly state: ListingState;
|
|
160
|
+
readonly visibility: ListingVisibility;
|
|
161
|
+
readonly source: AvailableListingSource;
|
|
162
|
+
}
|
|
163
|
+
interface IMyRequestDto {
|
|
164
|
+
readonly id: string;
|
|
165
|
+
readonly ownerSpaceID: string;
|
|
166
|
+
readonly ownerSpaceTitle?: string;
|
|
167
|
+
readonly listingID: string;
|
|
168
|
+
readonly assetID: string;
|
|
169
|
+
readonly type: ListingType;
|
|
170
|
+
readonly status: ListingRequestStatus;
|
|
171
|
+
readonly createdAt: string;
|
|
172
|
+
}
|
|
173
|
+
interface IGetMyRequestsResponse {
|
|
174
|
+
readonly requests: readonly IMyRequestDto[];
|
|
175
|
+
}
|
|
176
|
+
interface IGetListingResult {
|
|
177
|
+
readonly listing?: IListingDto;
|
|
178
|
+
readonly requests?: readonly IListingRequestDto[];
|
|
179
|
+
}
|
|
180
|
+
interface IYardiusListingService {
|
|
181
|
+
publishListing(request: IPublishListingRequest): Observable<IListingActionResponse>;
|
|
182
|
+
cancelListing(request: IListingActionRequest): Observable<IListingActionResponse>;
|
|
183
|
+
requestToBorrow(request: IRequestToBorrowRequest): Observable<IListingActionResponse>;
|
|
184
|
+
claimListing(request: IRequestToBorrowRequest): Observable<IListingActionResponse>;
|
|
185
|
+
withdrawRequest(request: IWithdrawRequestRequest): Observable<IListingActionResponse>;
|
|
186
|
+
approveRequest(request: IListingRequestActionRequest): Observable<IApproveRequestResponse>;
|
|
187
|
+
declineRequest(request: IListingRequestActionRequest): Observable<IListingActionResponse>;
|
|
188
|
+
confirmHandover(request: IListingActionRequest): Observable<IListingActionResponse>;
|
|
189
|
+
confirmReturn(request: IListingActionRequest): Observable<IListingActionResponse>;
|
|
190
|
+
getAvailableListings(): Observable<IGetListingsResponse>;
|
|
191
|
+
getOurListings(spaceID: string): Observable<readonly IListingDto[]>;
|
|
192
|
+
getListing(spaceID: string, listingID: string): Observable<IGetListingResult>;
|
|
193
|
+
getMyRequests(): Observable<IGetMyRequestsResponse>;
|
|
194
|
+
}
|
|
195
|
+
declare const YARDIUS_LISTING_SERVICE: InjectionToken<IYardiusListingService>;
|
|
196
|
+
|
|
197
|
+
declare const YARDIUS_EVENT_TYPES: readonly ["publish", "request", "withdraw", "approve", "decline", "handover", "return", "claim", "transfer", "cancel"];
|
|
198
|
+
type YardiusEventType = (typeof YARDIUS_EVENT_TYPES)[number];
|
|
199
|
+
interface ITransactionLogEntry {
|
|
200
|
+
readonly event: YardiusEventType;
|
|
201
|
+
readonly at: string;
|
|
202
|
+
readonly actingMemberSpaceID: string;
|
|
203
|
+
readonly actingMemberID: string;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
export { ASSETUS_VISIBILITIES, BEFRIEND_SPACE_PAGE_PATH, BORROW_STATES, BORROW_STATE_TRANSITIONS, DEFAULT_LISTING_VISIBILITY, GIVEAWAY_STATES, GIVEAWAY_STATE_TRANSITIONS, LISTING_REQUEST_STATUSES, LISTING_TYPES, LISTING_VISIBILITIES, LISTING_VISIBILITY_CEILING, YARDIUS_EVENT_TYPES, YARDIUS_FRIENDSHIP_SERVICE, YARDIUS_LISTING_SERVICE, allowedListingVisibilities, canTransition, canTransitionBorrow, canTransitionGiveaway, friendshipInvitePath, isListingVisibilityAllowed, isOpenListingState, listingRequestStatusLabel, listingStateLabel, listingTypeLabel, listingVisibilityLabel };
|
|
207
|
+
export type { AssetusVisibility, AvailableListingSource, BorrowState, GiveawayState, IAcceptFriendshipInviteRequest, IAcceptFriendshipInviteResponse, IApproveRequestResponse, IAvailableListingDto, IBorrowListingDto, ICreateFriendshipInviteRequest, ICreateFriendshipInviteResponse, IFriendSpace, IGetListingResult, IGetListingsRequest, IGetListingsResponse, IGetMyRequestsResponse, IGiveawayListingDto, IListFriendSpacesResponse, IListingActionRequest, IListingActionResponse, IListingDbo, IListingDto, IListingRequestActionRequest, IListingRequestDto, IListingsSpaceGroup, IMyRequestDto, IPublishListingRequest, IRemoveFriendshipRequest, IRequestToBorrowRequest, ITransactionLogEntry, IWithdrawRequestRequest, IYardiusFriendshipService, IYardiusListingService, ListingRequestStatus, ListingState, ListingType, ListingVisibility, ListingsGroupReason, SpaceFriendshipRole, StateTransitionTable, YardiusEventType };
|
package/dist/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './lib/index.js';
|
package/dist/index.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
// @sneat/extension-yardius-contract — frozen cross-repo contract surface for the yardius extension.
|
|
2
|
-
//
|
|
3
|
-
// Shared DTOs (listings, transaction-log entries, request/claim shapes, the
|
|
4
|
-
// listings-endpoint contract), lifecycle state enums with their legal
|
|
5
|
-
// transition tables, and the listing-visibility ceiling mapping are exported
|
|
6
|
-
// from here so that both the sneat-go backend models and the Sneat super-app
|
|
7
|
-
// extension libs resolve every shared model from this single package. No
|
|
8
|
-
// consumer may re-declare these.
|
|
9
|
-
export * from './lib/index.js';
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
// The Assetus asset-visibility values, mirrored here as wire values so the
|
|
2
|
-
// listing-visibility ceiling (see `listing-visibility.ts`) can be encoded as
|
|
3
|
-
// shared data with zero runtime dependencies.
|
|
4
|
-
//
|
|
5
|
-
// Source of truth for the VALUES is the pinned assetus-mvp contract
|
|
6
|
-
// (`AssetVisibility` in the `@sneat/extension-assetus-contract` lib):
|
|
7
|
-
// spec display names `Private` / `Family` / `Friends` / `Friends of Friends` /
|
|
8
|
-
// `Specific Space` / `Public` are persisted as the lowercase snake_case wire
|
|
9
|
-
// values below. Yardius only READS asset visibility (REQ
|
|
10
|
-
// assetus-write-boundary) — this type exists so both the Yardius frontend and
|
|
11
|
-
// backend consume the ceiling mapping from this single package.
|
|
12
|
-
export const ASSETUS_VISIBILITIES = [
|
|
13
|
-
'private',
|
|
14
|
-
'family',
|
|
15
|
-
'friends',
|
|
16
|
-
'friends_of_friends',
|
|
17
|
-
'specific_space',
|
|
18
|
-
'public',
|
|
19
|
-
];
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { StateTransitionTable } from './state-transitions.js';
|
|
2
|
-
export declare const BORROW_STATES: readonly ["available", "requested", "approved", "borrowed", "returned", "closed"];
|
|
3
|
-
export type BorrowState = (typeof BORROW_STATES)[number];
|
|
4
|
-
export declare const BORROW_STATE_TRANSITIONS: StateTransitionTable<BorrowState>;
|
|
5
|
-
export declare function canTransitionBorrow(from: BorrowState, to: BorrowState): boolean;
|
package/dist/lib/borrow-state.js
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { canTransition } from './state-transitions.js';
|
|
2
|
-
// Borrow-listing lifecycle states, per REQ borrow-lifecycle (spec display
|
|
3
|
-
// names `Available → Requested → Approved → Borrowed → Returned → Closed`,
|
|
4
|
-
// persisted as the wire values below):
|
|
5
|
-
// - 'available' — open, no pending requests;
|
|
6
|
-
// - 'requested' — ≥1 request pending; the Listing stays visible and accepts
|
|
7
|
-
// further requests;
|
|
8
|
-
// - 'approved' — a member of the owning Space approved exactly one request;
|
|
9
|
-
// all other pending requests are automatically declined and no further
|
|
10
|
-
// requests are accepted;
|
|
11
|
-
// - 'borrowed' — a member of the owning Space confirmed handover;
|
|
12
|
-
// - 'returned' — a member of the owning Space confirmed the item is back;
|
|
13
|
-
// - 'closed' — terminal; immediately follows 'returned' (or an
|
|
14
|
-
// owner-cancel — see REQ owner-cancel).
|
|
15
|
-
export const BORROW_STATES = [
|
|
16
|
-
'available',
|
|
17
|
-
'requested',
|
|
18
|
-
'approved',
|
|
19
|
-
'borrowed',
|
|
20
|
-
'returned',
|
|
21
|
-
'closed',
|
|
22
|
-
];
|
|
23
|
-
// The legal borrow transitions, per REQ borrow-lifecycle + REQ owner-cancel.
|
|
24
|
-
// Any transition not listed here MUST be rejected.
|
|
25
|
-
//
|
|
26
|
-
// available → requested first request arrives
|
|
27
|
-
// available → closed owner cancels (before 'borrowed' — legal)
|
|
28
|
-
// requested → approved owner approves exactly one request
|
|
29
|
-
// requested → available the only pending request is withdrawn
|
|
30
|
-
// requested → closed owner cancels; all pending requests declined
|
|
31
|
-
// approved → borrowed owner confirms handover
|
|
32
|
-
// approved → closed owner cancels (still before 'borrowed')
|
|
33
|
-
// borrowed → returned owner confirms the item is back; a 'borrowed'
|
|
34
|
-
// Listing MUST NOT be cancellable — 'returned' is
|
|
35
|
-
// its only exit
|
|
36
|
-
// returned → closed immediate, automatic
|
|
37
|
-
// closed → (terminal)
|
|
38
|
-
export const BORROW_STATE_TRANSITIONS = {
|
|
39
|
-
available: ['requested', 'closed'],
|
|
40
|
-
requested: ['approved', 'available', 'closed'],
|
|
41
|
-
approved: ['borrowed', 'closed'],
|
|
42
|
-
borrowed: ['returned'],
|
|
43
|
-
returned: ['closed'],
|
|
44
|
-
closed: [],
|
|
45
|
-
};
|
|
46
|
-
// True when `from → to` is a legal borrow-lifecycle transition.
|
|
47
|
-
export function canTransitionBorrow(from, to) {
|
|
48
|
-
return canTransition(BORROW_STATE_TRANSITIONS, from, to);
|
|
49
|
-
}
|
package/dist/lib/friendship.d.ts
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { InjectionToken } from '@angular/core';
|
|
2
|
-
import type { Observable } from 'rxjs';
|
|
3
|
-
export type SpaceFriendshipRole = 'friend' | 'neighbour';
|
|
4
|
-
export interface ICreateFriendshipInviteRequest {
|
|
5
|
-
readonly spaceID: string;
|
|
6
|
-
readonly role?: SpaceFriendshipRole;
|
|
7
|
-
}
|
|
8
|
-
export interface ICreateFriendshipInviteResponse {
|
|
9
|
-
readonly id: string;
|
|
10
|
-
readonly pin: string;
|
|
11
|
-
}
|
|
12
|
-
export interface IAcceptFriendshipInviteRequest {
|
|
13
|
-
readonly inviteID: string;
|
|
14
|
-
readonly pin: string;
|
|
15
|
-
readonly toSpaceID: string;
|
|
16
|
-
}
|
|
17
|
-
export interface IAcceptFriendshipInviteResponse {
|
|
18
|
-
readonly invitingSpaceID: string;
|
|
19
|
-
readonly toSpaceID: string;
|
|
20
|
-
readonly role: SpaceFriendshipRole;
|
|
21
|
-
}
|
|
22
|
-
export interface IFriendSpace {
|
|
23
|
-
readonly id: string;
|
|
24
|
-
readonly roles: readonly SpaceFriendshipRole[];
|
|
25
|
-
readonly title?: string;
|
|
26
|
-
}
|
|
27
|
-
export interface IListFriendSpacesResponse {
|
|
28
|
-
readonly friendSpaces?: readonly IFriendSpace[];
|
|
29
|
-
}
|
|
30
|
-
export interface IRemoveFriendshipRequest {
|
|
31
|
-
readonly spaceID: string;
|
|
32
|
-
readonly friendSpaceID: string;
|
|
33
|
-
}
|
|
34
|
-
export interface IYardiusFriendshipService {
|
|
35
|
-
createFriendshipInvite(request: ICreateFriendshipInviteRequest): Observable<ICreateFriendshipInviteResponse>;
|
|
36
|
-
acceptFriendshipInvite(request: IAcceptFriendshipInviteRequest): Observable<IAcceptFriendshipInviteResponse>;
|
|
37
|
-
listFriendSpaces(spaceID: string): Observable<IListFriendSpacesResponse>;
|
|
38
|
-
removeFriendship(request: IRemoveFriendshipRequest): Observable<void>;
|
|
39
|
-
}
|
|
40
|
-
export declare const YARDIUS_FRIENDSHIP_SERVICE: InjectionToken<IYardiusFriendshipService>;
|
|
41
|
-
export declare const BEFRIEND_SPACE_PAGE_PATH = "befriend";
|
|
42
|
-
export declare function friendshipInvitePath(inviteID: string, pin: string): string;
|
package/dist/lib/friendship.js
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { InjectionToken } from '@angular/core';
|
|
2
|
-
export const YARDIUS_FRIENDSHIP_SERVICE = new InjectionToken('YardiusFriendshipService');
|
|
3
|
-
export const BEFRIEND_SPACE_PAGE_PATH = 'befriend';
|
|
4
|
-
export function friendshipInvitePath(inviteID, pin) {
|
|
5
|
-
return `${BEFRIEND_SPACE_PAGE_PATH}?${new URLSearchParams({ id: inviteID, pin }).toString()}`;
|
|
6
|
-
}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { StateTransitionTable } from './state-transitions.js';
|
|
2
|
-
export declare const GIVEAWAY_STATES: readonly ["available", "claimed", "transferred", "closed"];
|
|
3
|
-
export type GiveawayState = (typeof GIVEAWAY_STATES)[number];
|
|
4
|
-
export declare const GIVEAWAY_STATE_TRANSITIONS: StateTransitionTable<GiveawayState>;
|
|
5
|
-
export declare function canTransitionGiveaway(from: GiveawayState, to: GiveawayState): boolean;
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { canTransition } from './state-transitions.js';
|
|
2
|
-
// Give-away-listing lifecycle states, per REQ giveaway-lifecycle (spec
|
|
3
|
-
// display names `Available → Claimed → Transferred → Closed`, persisted as
|
|
4
|
-
// the wire values below):
|
|
5
|
-
// - 'available' — open; eligible viewers claim (claims arriving do NOT
|
|
6
|
-
// change the state — only the owner's selection does);
|
|
7
|
-
// - 'claimed' — a member of the owning Space selected exactly one
|
|
8
|
-
// claimant; other claims automatically declined;
|
|
9
|
-
// - 'transferred' — the Assetus ownership transfer to the claimant's Space
|
|
10
|
-
// succeeded (Assetus appends its own `Transferred` history event); if the
|
|
11
|
-
// transfer FAILS the Listing stays 'claimed' — staying put is not a
|
|
12
|
-
// transition;
|
|
13
|
-
// - 'closed' — terminal; immediately follows 'transferred' (or an
|
|
14
|
-
// owner-cancel — see REQ owner-cancel).
|
|
15
|
-
export const GIVEAWAY_STATES = ['available', 'claimed', 'transferred', 'closed'];
|
|
16
|
-
// The legal give-away transitions, per REQ giveaway-lifecycle +
|
|
17
|
-
// REQ owner-cancel. Any transition not listed here MUST be rejected.
|
|
18
|
-
//
|
|
19
|
-
// available → claimed owner selects exactly one claimant
|
|
20
|
-
// available → closed owner cancels (before 'transferred' — legal)
|
|
21
|
-
// claimed → transferred Assetus ownership transfer succeeded on
|
|
22
|
-
// confirmed handover (on failure the Listing
|
|
23
|
-
// remains 'claimed' — no transition)
|
|
24
|
-
// claimed → closed owner cancels; the claim is declined
|
|
25
|
-
// transferred → closed immediate, automatic
|
|
26
|
-
// closed → (terminal)
|
|
27
|
-
export const GIVEAWAY_STATE_TRANSITIONS = {
|
|
28
|
-
available: ['claimed', 'closed'],
|
|
29
|
-
claimed: ['transferred', 'closed'],
|
|
30
|
-
transferred: ['closed'],
|
|
31
|
-
closed: [],
|
|
32
|
-
};
|
|
33
|
-
// True when `from → to` is a legal give-away-lifecycle transition.
|
|
34
|
-
export function canTransitionGiveaway(from, to) {
|
|
35
|
-
return canTransition(GIVEAWAY_STATE_TRANSITIONS, from, to);
|
|
36
|
-
}
|
package/dist/lib/index.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export * from './assetus-visibility.js';
|
|
2
|
-
export * from './friendship.js';
|
|
3
|
-
export * from './listing-visibility.js';
|
|
4
|
-
export * from './state-transitions.js';
|
|
5
|
-
export * from './borrow-state.js';
|
|
6
|
-
export * from './giveaway-state.js';
|
|
7
|
-
export * from './listing.js';
|
|
8
|
-
export * from './transaction-log.js';
|
|
9
|
-
export * from './listing-request.js';
|
|
10
|
-
export * from './listings-endpoint.js';
|
package/dist/lib/index.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export * from './assetus-visibility.js';
|
|
2
|
-
export * from './friendship.js';
|
|
3
|
-
export * from './listing-visibility.js';
|
|
4
|
-
export * from './state-transitions.js';
|
|
5
|
-
export * from './borrow-state.js';
|
|
6
|
-
export * from './giveaway-state.js';
|
|
7
|
-
export * from './listing.js';
|
|
8
|
-
export * from './transaction-log.js';
|
|
9
|
-
export * from './listing-request.js';
|
|
10
|
-
export * from './listings-endpoint.js';
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export declare const LISTING_REQUEST_STATUSES: readonly ["pending", "approved", "declined", "withdrawn"];
|
|
2
|
-
export type ListingRequestStatus = (typeof LISTING_REQUEST_STATUSES)[number];
|
|
3
|
-
export interface IListingRequestDto {
|
|
4
|
-
readonly id: string;
|
|
5
|
-
readonly requesterSpaceID: string;
|
|
6
|
-
readonly requesterMemberID: string;
|
|
7
|
-
readonly requesterTitle?: string;
|
|
8
|
-
readonly requesterSpaceTitle?: string;
|
|
9
|
-
readonly status: ListingRequestStatus;
|
|
10
|
-
readonly createdAt: string;
|
|
11
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
// Status of a borrow request or give-away claim:
|
|
2
|
-
// - 'pending' — awaiting the owning Space's decision;
|
|
3
|
-
// - 'approved' — the owner approved this request (borrow) or selected this
|
|
4
|
-
// claimant (give-away); all other pending requests/claims on the Listing
|
|
5
|
-
// are automatically declined (REQ borrow-lifecycle /
|
|
6
|
-
// REQ giveaway-lifecycle);
|
|
7
|
-
// - 'declined' — declined by the owner, auto-declined because another
|
|
8
|
-
// request was approved, cancelled with the Listing (REQ owner-cancel), or
|
|
9
|
-
// auto-declined on friendship removal (REQ friendship-removal);
|
|
10
|
-
// - 'withdrawn' — the requester withdrew their own pending request
|
|
11
|
-
// (REQ borrow-request).
|
|
12
|
-
export const LISTING_REQUEST_STATUSES = [
|
|
13
|
-
'pending',
|
|
14
|
-
'approved',
|
|
15
|
-
'declined',
|
|
16
|
-
'withdrawn',
|
|
17
|
-
];
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { AssetusVisibility } from './assetus-visibility.js';
|
|
2
|
-
export declare const LISTING_VISIBILITIES: readonly ["private", "members", "friends"];
|
|
3
|
-
export type ListingVisibility = (typeof LISTING_VISIBILITIES)[number];
|
|
4
|
-
export declare const DEFAULT_LISTING_VISIBILITY: ListingVisibility;
|
|
5
|
-
export declare function listingVisibilityLabel(visibility: ListingVisibility): string;
|
|
6
|
-
export declare const LISTING_VISIBILITY_CEILING: Readonly<Record<AssetusVisibility, readonly ListingVisibility[]>>;
|
|
7
|
-
export declare function allowedListingVisibilities(assetVisibility: AssetusVisibility): readonly ListingVisibility[];
|
|
8
|
-
export declare function isListingVisibilityAllowed(assetVisibility: AssetusVisibility, listingVisibility: ListingVisibility): boolean;
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
// A Listing's own visibility, per REQ listing-visibility-ceiling (spec display
|
|
2
|
-
// names `Private` / `Members` / `Friends`, persisted as the wire values
|
|
3
|
-
// below):
|
|
4
|
-
// - 'private' — visible only to members of the owning Space;
|
|
5
|
-
// - 'members' — visible to members of the owning Space (reserved distinction
|
|
6
|
-
// from 'private' for future member-subset control; in MVP the two resolve
|
|
7
|
-
// to the same audience, and 'members' is the default);
|
|
8
|
-
// - 'friends' — additionally visible to members of befriended Spaces.
|
|
9
|
-
export const LISTING_VISIBILITIES = ['private', 'members', 'friends'];
|
|
10
|
-
// Per REQ listing-visibility-ceiling: `members` is the default listing
|
|
11
|
-
// visibility.
|
|
12
|
-
export const DEFAULT_LISTING_VISIBILITY = 'members';
|
|
13
|
-
export function listingVisibilityLabel(visibility) {
|
|
14
|
-
switch (visibility) {
|
|
15
|
-
case 'private':
|
|
16
|
-
return 'Private';
|
|
17
|
-
case 'members':
|
|
18
|
-
return 'Members';
|
|
19
|
-
case 'friends':
|
|
20
|
-
return 'Friends';
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
// The asset's Assetus visibility is a CEILING on the listing's visibility,
|
|
24
|
-
// per this exact mapping from REQ listing-visibility-ceiling:
|
|
25
|
-
//
|
|
26
|
-
// | Asset visibility (Assetus) | Permitted listing visibilities |
|
|
27
|
-
// |------------------------------------------|--------------------------------|
|
|
28
|
-
// | Private | Private |
|
|
29
|
-
// | Family | Private, Members |
|
|
30
|
-
// | Specific Space | Private (MVP simplification) |
|
|
31
|
-
// | Friends, Friends of Friends, Public | Private, Members, Friends |
|
|
32
|
-
//
|
|
33
|
-
// Encoded as data so frontend and backend enforce the same source of truth.
|
|
34
|
-
// Publishing with a listing visibility not permitted here MUST be rejected
|
|
35
|
-
// with an actionable error telling the user to raise the asset's visibility
|
|
36
|
-
// in Assetus first.
|
|
37
|
-
export const LISTING_VISIBILITY_CEILING = {
|
|
38
|
-
private: ['private'],
|
|
39
|
-
family: ['private', 'members'],
|
|
40
|
-
specific_space: ['private'], // MVP simplification.
|
|
41
|
-
friends: ['private', 'members', 'friends'],
|
|
42
|
-
friends_of_friends: ['private', 'members', 'friends'],
|
|
43
|
-
public: ['private', 'members', 'friends'],
|
|
44
|
-
};
|
|
45
|
-
// The listing visibilities permitted for an asset with the given Assetus
|
|
46
|
-
// visibility. Pure lookup over `LISTING_VISIBILITY_CEILING`.
|
|
47
|
-
export function allowedListingVisibilities(assetVisibility) {
|
|
48
|
-
return LISTING_VISIBILITY_CEILING[assetVisibility];
|
|
49
|
-
}
|
|
50
|
-
// True when a listing with `listingVisibility` may be published for an asset
|
|
51
|
-
// whose Assetus visibility is `assetVisibility`.
|
|
52
|
-
export function isListingVisibilityAllowed(assetVisibility, listingVisibility) {
|
|
53
|
-
return LISTING_VISIBILITY_CEILING[assetVisibility].includes(listingVisibility);
|
|
54
|
-
}
|
package/dist/lib/listing.d.ts
DELETED
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
import { InjectionToken } from '@angular/core';
|
|
2
|
-
import type { Observable } from 'rxjs';
|
|
3
|
-
import type { BorrowState } from './borrow-state.js';
|
|
4
|
-
import type { GiveawayState } from './giveaway-state.js';
|
|
5
|
-
import type { ListingRequestStatus } from './listing-request.js';
|
|
6
|
-
import type { ListingVisibility } from './listing-visibility.js';
|
|
7
|
-
import type { IGetListingsResponse } from './listings-endpoint.js';
|
|
8
|
-
export declare const LISTING_TYPES: readonly ["borrow", "giveaway"];
|
|
9
|
-
export type ListingType = (typeof LISTING_TYPES)[number];
|
|
10
|
-
export type ListingState = BorrowState | GiveawayState;
|
|
11
|
-
export declare function isOpenListingState(state: ListingState): boolean;
|
|
12
|
-
export declare function listingTypeLabel(type: ListingType): string;
|
|
13
|
-
export declare function listingStateLabel(state: ListingState): string;
|
|
14
|
-
export declare function listingRequestStatusLabel(status: ListingRequestStatus): string;
|
|
15
|
-
export interface IListingDbo {
|
|
16
|
-
readonly assetID: string;
|
|
17
|
-
readonly type: ListingType;
|
|
18
|
-
readonly state: ListingState;
|
|
19
|
-
readonly visibility: ListingVisibility;
|
|
20
|
-
readonly createdAt?: string;
|
|
21
|
-
readonly createdBy?: string;
|
|
22
|
-
}
|
|
23
|
-
interface IListingIdentity {
|
|
24
|
-
readonly id: string;
|
|
25
|
-
readonly spaceID: string;
|
|
26
|
-
}
|
|
27
|
-
export interface IBorrowListingDto extends IListingDbo, IListingIdentity {
|
|
28
|
-
readonly type: 'borrow';
|
|
29
|
-
readonly state: BorrowState;
|
|
30
|
-
}
|
|
31
|
-
export interface IGiveawayListingDto extends IListingDbo, IListingIdentity {
|
|
32
|
-
readonly type: 'giveaway';
|
|
33
|
-
readonly state: GiveawayState;
|
|
34
|
-
}
|
|
35
|
-
export type IListingDto = IBorrowListingDto | IGiveawayListingDto;
|
|
36
|
-
export interface IPublishListingRequest {
|
|
37
|
-
readonly spaceID: string;
|
|
38
|
-
readonly assetID: string;
|
|
39
|
-
readonly type: ListingType;
|
|
40
|
-
readonly visibility?: ListingVisibility;
|
|
41
|
-
}
|
|
42
|
-
export interface IListingActionResponse {
|
|
43
|
-
readonly id: string;
|
|
44
|
-
readonly listing: IListingDbo;
|
|
45
|
-
}
|
|
46
|
-
export interface IListingActionRequest {
|
|
47
|
-
readonly spaceID: string;
|
|
48
|
-
readonly listingID: string;
|
|
49
|
-
}
|
|
50
|
-
export interface IListingRequestActionRequest extends IListingActionRequest {
|
|
51
|
-
readonly requestID: string;
|
|
52
|
-
}
|
|
53
|
-
export interface IApproveRequestResponse extends IListingActionResponse {
|
|
54
|
-
readonly declinedRequestIDs?: readonly string[];
|
|
55
|
-
}
|
|
56
|
-
export interface IRequestToBorrowRequest {
|
|
57
|
-
readonly spaceID: string;
|
|
58
|
-
readonly ownerSpaceID: string;
|
|
59
|
-
readonly listingID: string;
|
|
60
|
-
}
|
|
61
|
-
export interface IWithdrawRequestRequest extends IRequestToBorrowRequest {
|
|
62
|
-
readonly requestID: string;
|
|
63
|
-
}
|
|
64
|
-
export type AvailableListingSource = 'member' | 'friend';
|
|
65
|
-
export interface IAvailableListingDto {
|
|
66
|
-
readonly spaceID: string;
|
|
67
|
-
readonly spaceTitle?: string;
|
|
68
|
-
readonly listingID: string;
|
|
69
|
-
readonly assetID: string;
|
|
70
|
-
readonly type: ListingType;
|
|
71
|
-
readonly state: ListingState;
|
|
72
|
-
readonly visibility: ListingVisibility;
|
|
73
|
-
readonly source: AvailableListingSource;
|
|
74
|
-
}
|
|
75
|
-
export interface IMyRequestDto {
|
|
76
|
-
readonly id: string;
|
|
77
|
-
readonly ownerSpaceID: string;
|
|
78
|
-
readonly ownerSpaceTitle?: string;
|
|
79
|
-
readonly listingID: string;
|
|
80
|
-
readonly assetID: string;
|
|
81
|
-
readonly type: ListingType;
|
|
82
|
-
readonly status: ListingRequestStatus;
|
|
83
|
-
readonly createdAt: string;
|
|
84
|
-
}
|
|
85
|
-
export interface IGetMyRequestsResponse {
|
|
86
|
-
readonly requests: readonly IMyRequestDto[];
|
|
87
|
-
}
|
|
88
|
-
export interface IGetListingResult {
|
|
89
|
-
readonly listing?: IListingDto;
|
|
90
|
-
readonly requests?: readonly import('./listing-request.js').IListingRequestDto[];
|
|
91
|
-
}
|
|
92
|
-
export interface IYardiusListingService {
|
|
93
|
-
publishListing(request: IPublishListingRequest): Observable<IListingActionResponse>;
|
|
94
|
-
cancelListing(request: IListingActionRequest): Observable<IListingActionResponse>;
|
|
95
|
-
requestToBorrow(request: IRequestToBorrowRequest): Observable<IListingActionResponse>;
|
|
96
|
-
claimListing(request: IRequestToBorrowRequest): Observable<IListingActionResponse>;
|
|
97
|
-
withdrawRequest(request: IWithdrawRequestRequest): Observable<IListingActionResponse>;
|
|
98
|
-
approveRequest(request: IListingRequestActionRequest): Observable<IApproveRequestResponse>;
|
|
99
|
-
declineRequest(request: IListingRequestActionRequest): Observable<IListingActionResponse>;
|
|
100
|
-
confirmHandover(request: IListingActionRequest): Observable<IListingActionResponse>;
|
|
101
|
-
confirmReturn(request: IListingActionRequest): Observable<IListingActionResponse>;
|
|
102
|
-
getAvailableListings(): Observable<IGetListingsResponse>;
|
|
103
|
-
getOurListings(spaceID: string): Observable<readonly IListingDto[]>;
|
|
104
|
-
getListing(spaceID: string, listingID: string): Observable<IGetListingResult>;
|
|
105
|
-
getMyRequests(): Observable<IGetMyRequestsResponse>;
|
|
106
|
-
}
|
|
107
|
-
export declare const YARDIUS_LISTING_SERVICE: InjectionToken<IYardiusListingService>;
|
|
108
|
-
export {};
|
package/dist/lib/listing.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { InjectionToken } from '@angular/core';
|
|
2
|
-
export const LISTING_TYPES = ['borrow', 'giveaway'];
|
|
3
|
-
export function isOpenListingState(state) {
|
|
4
|
-
return state !== 'closed';
|
|
5
|
-
}
|
|
6
|
-
export function listingTypeLabel(type) {
|
|
7
|
-
return type === 'borrow' ? 'Borrow' : 'Give away';
|
|
8
|
-
}
|
|
9
|
-
export function listingStateLabel(state) {
|
|
10
|
-
return state.charAt(0).toUpperCase() + state.slice(1);
|
|
11
|
-
}
|
|
12
|
-
export function listingRequestStatusLabel(status) {
|
|
13
|
-
return status.charAt(0).toUpperCase() + status.slice(1);
|
|
14
|
-
}
|
|
15
|
-
export const YARDIUS_LISTING_SERVICE = new InjectionToken('YardiusListingService');
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { IAvailableListingDto, IListingDto } from './listing.js';
|
|
2
|
-
export type IGetListingsRequest = Record<string, never>;
|
|
3
|
-
export type ListingsGroupReason = 'member' | 'friend';
|
|
4
|
-
export interface IListingsSpaceGroup {
|
|
5
|
-
readonly spaceID: string;
|
|
6
|
-
readonly spaceTitle: string;
|
|
7
|
-
readonly reason: ListingsGroupReason;
|
|
8
|
-
readonly listings: readonly IListingDto[];
|
|
9
|
-
}
|
|
10
|
-
export interface IGetListingsResponse {
|
|
11
|
-
/** Grouped response used by the relationship-first listing endpoint. */
|
|
12
|
-
readonly groups?: readonly IListingsSpaceGroup[];
|
|
13
|
-
/** Flat response used by the existing `get_available_listings` facade. */
|
|
14
|
-
readonly listings?: readonly IAvailableListingDto[];
|
|
15
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
// True when `from → to` is a legal transition per the given table. Pure and
|
|
2
|
-
// dependency-free by design; a state never legally "transitions" to itself
|
|
3
|
-
// (staying put — e.g. a give-away remaining `claimed` after a failed Assetus
|
|
4
|
-
// transfer — is the absence of a transition, not a transition).
|
|
5
|
-
export function canTransition(table, from, to) {
|
|
6
|
-
return table[from].includes(to);
|
|
7
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export declare const YARDIUS_EVENT_TYPES: readonly ["publish", "request", "withdraw", "approve", "decline", "handover", "return", "claim", "transfer", "cancel"];
|
|
2
|
-
export type YardiusEventType = (typeof YARDIUS_EVENT_TYPES)[number];
|
|
3
|
-
export interface ITransactionLogEntry {
|
|
4
|
-
readonly event: YardiusEventType;
|
|
5
|
-
readonly at: string;
|
|
6
|
-
readonly actingMemberSpaceID: string;
|
|
7
|
-
readonly actingMemberID: string;
|
|
8
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
// The exact set of lifecycle event types recorded in a Listing's per-listing
|
|
2
|
-
// transaction log, per REQ transaction-log.
|
|
3
|
-
export const YARDIUS_EVENT_TYPES = [
|
|
4
|
-
'publish',
|
|
5
|
-
'request',
|
|
6
|
-
'withdraw',
|
|
7
|
-
'approve',
|
|
8
|
-
'decline',
|
|
9
|
-
'handover',
|
|
10
|
-
'return',
|
|
11
|
-
'claim',
|
|
12
|
-
'transfer',
|
|
13
|
-
'cancel',
|
|
14
|
-
];
|