@sneat/extension-localius-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
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Localius contract
|
|
2
|
+
|
|
3
|
+
`@sneat/extension-localius-contract` is the public, implementation-free API
|
|
4
|
+
for Localius. It exposes Localius DTOs, service interfaces, and Angular DI
|
|
5
|
+
tokens. Hosts provide concrete implementations from a private Localius runtime;
|
|
6
|
+
consumers must not import implementation classes from this package.
|
|
7
|
+
|
|
8
|
+
## Provenance
|
|
9
|
+
|
|
10
|
+
Migrated from `sneat-co/ext-localius@52e7372f805fd2d34d4540d0e6aeb582e5026f4e`.
|
|
11
|
+
npm continuity from `@sneat/extension-localius-contract@0.2.0`.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sneat-extension-localius-contract.mjs","sources":["
|
|
1
|
+
{"version":3,"file":"sneat-extension-localius-contract.mjs","sources":["../../../../libs/localius/src/constants.ts","../../../../libs/localius/src/dto/list.ts","../../../../libs/localius/src/services/localius-service.ts","../../../../libs/localius/src/sneat-extension-localius-contract.ts"],"sourcesContent":["import { EnumAsUnionOfKeys } from '@sneat/core';\n\nexport const enum ListPage {\n list = 'list',\n}\n\nexport type ListPages = EnumAsUnionOfKeys<typeof ListPage>;\n","import { IRecord } from '@sneat/data';\nimport {\n IShortSpaceInfo,\n IWithCreated,\n IWithRestrictions,\n IWithSpaceIDs,\n SneatRecordStatus,\n} from '@sneat/dto';\n\nexport type ListStatus = SneatRecordStatus;\n\nexport interface IQuantity {\n value: number;\n unit: string;\n}\n\nexport interface IListItemCommon extends IListCommon {\n subListId?: string;\n subListType?: ListType;\n quantity?: IQuantity;\n category?: string;\n}\n\nexport type IListItemBase = IListItemCommon;\n\nexport type ListItemStatus = 'done' | 'active';\n\nexport interface IListItemBrief extends IListItemBase {\n id: string;\n readonly created?: string; // UTC datetime\n readonly emoji?: string;\n readonly status?: ListItemStatus;\n readonly img?: string;\n}\n\nexport interface ListCounts {\n // TODO: Use some enumerator as IDB library does.\n active?: number;\n completed?: number;\n}\n\nexport type ListType =\n | 'buy'\n | 'watch'\n | 'cook'\n | 'do'\n | 'other'\n | 'recipes'\n | 'rsvp';\n\n// IListCommon is a common base class for a List & ListItem\nexport interface IListCommon {\n // Do not extend from IWithCreated as it is not applicable for ICreateListItemRequest\n title: string;\n img?: string;\n emoji?: string;\n isDone?: boolean;\n}\n\nexport interface IListBase extends IListCommon, IWithSpaceIDs {\n type: ListType;\n shortId?: string;\n status?: ListStatus;\n}\n\nexport interface IListDbo extends IListBase, IWithRestrictions, IWithCreated {\n dtClosed?: number;\n note?: string; // Is used for example for recipe text\n numberOf?: ListCounts;\n items?: IListItemBrief[];\n commune?: IShortSpaceInfo; // Used just for in-memory columns?\n}\n\nexport class ListItemInfoModel {\n static trackBy: (\n index: number,\n item: IListItemBrief,\n ) => string | number | undefined = (index, item) =>\n !item\n ? index\n : (!!item.id && `id:${item.id}`) ||\n (item.subListId && `subList:${item.subListId}`) ||\n item.title;\n}\n\nexport class ListItemModel {\n static equalListItems(...items: IListItemBrief[]): boolean {\n const { id, title, subListId, category, subListType } = items[0];\n return !items.some((item) => {\n if (id) {\n return item.id !== id;\n }\n return (\n (!!title && item.title !== title) ||\n (!!subListId && item.subListId !== subListId) ||\n (!!category && item.category !== category) ||\n (!!subListType && item.subListType !== subListType)\n );\n });\n }\n}\n\nexport interface IListItemDbo extends IListBase, IListItemCommon {\n listId?: string;\n score?: number;\n subListItems?: IListItemBrief[];\n}\n\nexport function getListShortUrlId(\n communeId: string,\n shortId?: string,\n id?: string,\n): string | undefined {\n if (shortId) {\n return `${communeId}-${shortId}`;\n }\n if (id) {\n return id;\n }\n return undefined;\n}\n\nexport interface IListInfo extends IWithRestrictions {\n parentListId?: string;\n parentListType?: ListType;\n type: ListType;\n id?: string;\n shortId?: string;\n title?: string;\n hidden?: boolean;\n space?: IShortSpaceInfo;\n emoji?: string;\n img?: string;\n note?: string;\n itemsCount?: number;\n}\n\nexport interface IListBrief extends IListBase, IWithCreated {\n emoji?: string;\n}\n\nexport function isListInfoMatchesListDto(\n i: IListInfo,\n l: IRecord<IListDbo>,\n): boolean {\n return (\n (!!i.id && i.id === l.id) ||\n (i.type === l.dbo?.type && !!i.shortId && i.shortId === l.dbo?.shortId)\n );\n}\n\nexport function createListInfoFromDto(\n dto: IListDbo,\n shortId?: string,\n): IListInfo {\n if (!dto.title) {\n throw new Error('!title');\n }\n const listInfo: IListInfo = {\n type: dto.type,\n title: dto.title,\n };\n if (shortId) {\n listInfo.shortId = shortId;\n }\n if (dto.items && dto.items.length) {\n listInfo.itemsCount = dto.items.length;\n }\n if (dto.emoji) {\n listInfo.emoji = dto.emoji;\n }\n if (dto.restrictions) {\n listInfo.restrictions = dto.restrictions;\n }\n if (dto.commune) {\n listInfo.space = dto.commune;\n }\n return listInfo;\n}\n\n// export function createListItemInfoFromListInfo(listInfo: IListInfo): IListItemBrief {\n// \treturn {\n// \t\tid: listInfo.id || '',\n// \t\ttitle: listInfo.title || '',\n// \t\tsubListType: listInfo.type,\n// \t\tsubListId: listInfo.id || `${listInfo.team && listInfo.team.id}-${listInfo.shortId}`,\n// \t\temoji: listInfo.emoji,\n// \t\timg: listInfo.img,\n// \t};\n// }\n\n// export function createListItemInfo(listItem: IListItemDto): IListItemBrief {\n// \tconst v: IListItemBrief = {\n// \t\tid: listItem.id,\n// \t\ttitle: listItem.title,\n// \t};\n// \tif (listItem.emoji) {\n// \t\tv.emoji = listItem.emoji;\n// \t}\n// \tif (listItem.done) {\n// \t\tv.done = true;\n// \t}\n// \treturn v;\n// }\n","import { InjectionToken } from '@angular/core';\nimport { ISpaceContext } from '@sneat/space-models';\nimport { Observable } from 'rxjs';\nimport { IListContext } from '../contexts';\nimport { ListType } from '../dto';\nimport {\n ICreateListRequest,\n IDeleteListItemsRequest,\n IListItemResult,\n IListItemsCommandParams,\n IReorderListItemsRequest,\n ISetListItemsIsComplete,\n} from './interfaces';\n\n// ILocaliusService is the runtime-light contract the template pages and components\n// depend on. Members mirror the concrete ListService public surface used by the\n// UI; the implementation lives in the internal lib and is provided via the\n// LOCALIUS_SERVICE token below. The shared BaseListPage additionally needs the\n// inherited ModuleSpaceItemService surface, so it types the injected token as\n// an intersection with ModuleSpaceItemService<IListBrief, IListDbo>.\nexport interface ILocaliusService {\n createList(request: ICreateListRequest): Observable<IListContext>;\n deleteList(space: ISpaceContext, listId: string): Observable<void>;\n reorderListItems(request: IReorderListItemsRequest): Observable<void>;\n createListItems(\n params: IListItemsCommandParams,\n ): Observable<IListItemResult>;\n setListItemsIsCompleted(\n request: ISetListItemsIsComplete,\n ): Observable<void>;\n deleteListItems(request: IDeleteListItemsRequest): Observable<void>;\n getListById(\n space: ISpaceContext,\n listType: ListType,\n listID: string,\n ): Observable<IListContext>;\n}\n\nexport const LOCALIUS_SERVICE = new InjectionToken<ILocaliusService>(\n 'LocaliusService',\n);\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;IAEkB;AAAlB,CAAA,UAAkB,QAAQ,EAAA;AACxB,IAAA,QAAA,CAAA,MAAA,CAAA,GAAA,MAAa;AACf,CAAC,EAFiB,QAAQ,KAAR,QAAQ,GAAA,EAAA,CAAA,CAAA;;MCuEb,iBAAiB,CAAA;IAC5B,OAAO,OAAO,GAGqB,CAAC,KAAK,EAAE,IAAI,KAC7C,CAAC;AACC,UAAE;AACF,UAAE,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,IAAI,CAAA,GAAA,EAAM,IAAI,CAAC,EAAE,EAAE;aAC5B,IAAI,CAAC,SAAS,IAAI,WAAW,IAAI,CAAC,SAAS,CAAA,CAAE,CAAC;YAC/C,IAAI,CAAC,KAAK;;MAGL,aAAa,CAAA;AACxB,IAAA,OAAO,cAAc,CAAC,GAAG,KAAuB,EAAA;AAC9C,QAAA,MAAM,EAAE,EAAE,EAAE,K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