@alwith/module-collection 0.0.0-stage → 0.0.2

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/LICENSE ADDED
@@ -0,0 +1,94 @@
1
+ ALwith Developer and Redistribution License, Version 1.0
2
+ Copyright 2026 ALWITHAI PTE. LTD. All rights reserved, except as expressly granted below.
3
+
4
+ 1. Scope
5
+ This license applies only to ALWITHAI PTE. LTD.'s ("ALwith") own material in
6
+ the npm package accompanying this license (the "Software"). It is a proprietary
7
+ license, not an open-source license. Third-party material is governed by its
8
+ respective licenses, as described in THIRD_PARTY_NOTICES.md. No restriction here
9
+ reduces rights granted by those licenses or by mandatory applicable law.
10
+
11
+ 2. Permission to develop and distribute applications
12
+ Subject to this license, ALwith grants you a worldwide, non-exclusive, royalty-free
13
+ copyright license to use, reproduce, integrate and modify the supplied Software
14
+ to develop, test, host and operate your own applications, for personal,
15
+ internal business or commercial use. You may brand,
16
+ sell and distribute those applications, including the Software embedded in them,
17
+ to your customers and end users. No per-application registration, approval or
18
+ royalty is required by this software license.
19
+
20
+ You may bundle, minify, transform and otherwise adapt the supplied JavaScript,
21
+ styles and declarations for those applications. You may include the supplied
22
+ Software in an application source distribution when necessary to build or use
23
+ that application, provided it remains separately identified under this license.
24
+ You may combine it with separately licensed application code, including MPL-2.0
25
+ code, while complying with both licenses. Your own independent code remains yours;
26
+ this license does not require disclosure of your application source code.
27
+
28
+ Recipients may use the embedded Software to run the application and exercise the
29
+ permissions above under this same license. You may allow your contractors and
30
+ hosting providers to use it for those purposes. You must supply this license and
31
+ all applicable third-party notices with each redistribution (for example in an
32
+ included licenses directory or an accessible legal-notices page), identify your
33
+ modifications, and not impose terms that purport to change ALwith's license.
34
+
35
+ 3. Rights reserved
36
+ No right to ALwith's unpublished source code, private repositories, trademarks,
37
+ or separately distributed Runtime binaries, modules or services is granted here.
38
+ You may not relicense the Software as your own framework or redistribute it as
39
+ a standalone SDK/package for others, except for private development/build caches
40
+ used for applications permitted by Section 2. No restriction is imposed on
41
+ independently developed competing applications or on third-party licensed code.
42
+ You must not misrepresent authorship or imply ALwith endorses your application.
43
+
44
+ 4. Accounts and services
45
+ This license does not supply platform credentials, paid entitlements, hosting,
46
+ support, updates or a service-availability guarantee. Use of ALwith accounts,
47
+ pets, relay or other hosted services is separately subject to the applicable
48
+ service terms and authorization. Do not bypass service access controls or use
49
+ another person's credentials without authorization. Choosing or replacing an
50
+ authentication provider for your own application is not prohibited by this
51
+ software license. Distributing an Auth client does not authorize its recipients
52
+ to access another user's account, data or entitlements.
53
+
54
+ 5. Lawful use and independent responsibility
55
+ You must not use the Software to commit or knowingly facilitate unlawful acts.
56
+ You are responsible for your application's operation, permissions, business
57
+ practices, data processing, content and compliance with applicable law. You must
58
+ not make warranties or commitments on ALwith's behalf. ALwith does not endorse
59
+ your application merely because it uses the Software or connects to ALwith.
60
+ These allocations do not remove either party's own mandatory legal obligations.
61
+
62
+ 6. Disclaimer and limitation of liability
63
+ TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THE SOFTWARE IS PROVIDED
64
+ "AS IS" AND "AS AVAILABLE", WITHOUT EXPRESS OR IMPLIED WARRANTIES, INCLUDING
65
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, ACCURACY,
66
+ SECURITY OR UNINTERRUPTED OPERATION. AI OUTPUTS AND AUTOMATED ACTIONS MAY BE
67
+ INCORRECT OR HARMFUL; YOU MUST DETERMINE APPROPRIATE REVIEW AND SAFEGUARDS.
68
+
69
+ TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, ALWITH AND ITS CONTRIBUTORS
70
+ ARE NOT LIABLE FOR DAMAGES ARISING FROM USE, MODIFICATION OR DISTRIBUTION OF
71
+ THE SOFTWARE, INCLUDING LOST PROFITS, LOST DATA, BUSINESS INTERRUPTION AND
72
+ INDIRECT OR CONSEQUENTIAL LOSS. NOTHING EXCLUDES OR LIMITS LIABILITY THAT
73
+ CANNOT LAWFULLY BE EXCLUDED OR LIMITED, INCLUDING APPLICABLE MANDATORY CONSUMER
74
+ RIGHTS AND LIABILITY FOR FRAUD, WILLFUL MISCONDUCT OR GROSS NEGLIGENCE WHERE
75
+ SUCH EXCLUSION OR LIMITATION IS PROHIBITED. THIS LICENSE DOES NOT EXCLUDE
76
+ CRIMINAL OR REGULATORY RESPONSIBILITY IMPOSED BY LAW.
77
+
78
+ 7. Duration and termination
79
+ The grant for this version continues while you comply with this license. If
80
+ ALwith gives written notice of a material breach, your rights terminate if you
81
+ do not cure it within 30 days; no cure period authorizes continuing unlawful
82
+ conduct. On termination, cease new use and distribution of ALwith's proprietary
83
+ Software except as required by law. Independently compliant recipients retain
84
+ their own grants. Sections concerning reserved rights, notices, disclaimers and
85
+ mandatory-law exceptions survive as applicable. Third-party licenses are not
86
+ terminated by this provision.
87
+
88
+ 8. Versions and severability
89
+ This license governs the accompanying version. A later license or publication
90
+ of source code does not retroactively replace this grant or revoke rights in
91
+ earlier lawfully obtained versions. Any additional open-source license must be
92
+ expressly identified by ALwith. If a provision is unenforceable, the remaining
93
+ provisions continue to the extent permitted by law. A separate written agreement
94
+ signed by you and ALwith may expressly override these terms for its stated scope.
@@ -0,0 +1,5 @@
1
+ # Third-party notices — @alwith/module-collection
2
+
3
+ This package contains ALwith's collection model and no bundled third-party code.
4
+ It has no runtime dependencies. The accompanying ALwith Developer and
5
+ Redistribution License applies to this package's own material.
@@ -0,0 +1,95 @@
1
+ export declare const DEFAULT_COLLECTION_ID = "collection-default";
2
+ export interface Collection {
3
+ id: string;
4
+ name: string;
5
+ nameIsCustom?: boolean;
6
+ collapsed: boolean;
7
+ emoji?: string;
8
+ sessionIds: string[];
9
+ }
10
+ export interface SessionMeta {
11
+ title?: string;
12
+ cwd?: string;
13
+ titleOverride?: boolean;
14
+ }
15
+ export interface CollectionData {
16
+ collections: Record<string, Collection>;
17
+ order: string[];
18
+ sessionMeta: Record<string, SessionMeta>;
19
+ }
20
+ export type CollectionAction = {
21
+ type: "create";
22
+ id: string;
23
+ name: string;
24
+ emoji?: string;
25
+ sessionId?: string;
26
+ sourceCollectionId?: string;
27
+ } | {
28
+ type: "rename";
29
+ id: string;
30
+ name: string;
31
+ emoji?: string;
32
+ } | {
33
+ type: "emoji";
34
+ id: string;
35
+ emoji: string;
36
+ } | {
37
+ type: "collapse";
38
+ id: string;
39
+ collapsed: boolean;
40
+ } | {
41
+ type: "clear" | "delete";
42
+ id: string;
43
+ } | {
44
+ type: "add";
45
+ collectionId: string;
46
+ sessionId: string;
47
+ } | {
48
+ type: "materialize";
49
+ collectionId: string;
50
+ sessionId: string;
51
+ cwd: string;
52
+ } | {
53
+ type: "move";
54
+ sourceCollectionId: string;
55
+ collectionId: string;
56
+ sessionId: string;
57
+ index?: number;
58
+ } | {
59
+ type: "reorder";
60
+ id: string;
61
+ index: number;
62
+ } | {
63
+ type: "remove";
64
+ sessionId: string;
65
+ collectionId?: string;
66
+ } | {
67
+ type: "forget";
68
+ sessionId: string;
69
+ } | {
70
+ type: "favorite";
71
+ sessionId: string;
72
+ } | {
73
+ type: "meta";
74
+ sessionId: string;
75
+ meta: SessionMeta;
76
+ } | {
77
+ type: "renameSession";
78
+ sessionId: string;
79
+ title: string;
80
+ };
81
+ export declare function getCollectionName(collection: Collection, t: (key: "collection.defaultFavorites") => string): string;
82
+ export declare function initialCollectionData(): CollectionData;
83
+ export declare function applyCollectionAction(state: CollectionData, action: CollectionAction): CollectionData;
84
+ export interface LegacyCollections {
85
+ collections: Record<string, {
86
+ id: string;
87
+ name: string;
88
+ collapsed: boolean;
89
+ emoji?: string;
90
+ sessionIds?: string[];
91
+ }>;
92
+ order: string[];
93
+ sessionMeta?: Record<string, SessionMeta>;
94
+ }
95
+ export declare function migrateCollections(legacy: LegacyCollections[], current?: CollectionData): CollectionData;
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ var f="collection-default";function m(o,e){return o.id==="collection-default"?e("collection.defaultFavorites"):o.name}function c(){return{collections:{["collection-default"]:{id:"collection-default",name:"",nameIsCustom:!1,collapsed:!1,sessionIds:[]}},order:["collection-default"],sessionMeta:{}}}function u(o,e){let r={...o.collections},n=(s,d)=>{if(!r[s])throw Error(`Collection missing: ${s}`);r[s]={...r[s],...d}},i=(s,d)=>n(s,{sessionIds:r[s].sessionIds.filter((t)=>t!==d)}),l=(s,d)=>{let t=r[s];if(!t)throw Error(`Collection missing: ${s}`);for(let I of o.order)if(I!==s&&r[I].sessionIds.includes(d))i(I,d);if(!t.sessionIds.includes(d))n(s,{sessionIds:[...t.sessionIds,d],collapsed:!1})};switch(e.type){case"create":{if(!e.name.trim())throw Error("Collection name is empty");if(r[e.id]={id:e.id,name:e.name.trim(),...e.emoji===void 0?{}:{emoji:e.emoji},collapsed:!1,sessionIds:[]},e.sessionId!==void 0){if(e.sourceCollectionId!==void 0)i(e.sourceCollectionId,e.sessionId);l(e.id,e.sessionId)}return{...o,collections:r,order:[...o.order,e.id]}}case"rename":if(e.id==="collection-default")throw Error("Default collection cannot be renamed");if(!e.name.trim())throw Error("Collection name is empty");n(e.id,{name:e.name.trim(),nameIsCustom:!0,...e.emoji===void 0?{}:{emoji:e.emoji}});break;case"collapse":n(e.id,{collapsed:e.collapsed});break;case"emoji":n(e.id,{emoji:e.emoji});break;case"clear":n(e.id,{sessionIds:[]});break;case"delete":if(e.id==="collection-default")throw Error("Default collection cannot be deleted");return delete r[e.id],{...o,collections:r,order:o.order.filter((s)=>s!==e.id)};case"add":l(e.collectionId,e.sessionId);break;case"materialize":return l(e.collectionId,e.sessionId),{...o,collections:r,sessionMeta:{...o.sessionMeta,[e.sessionId]:{...o.sessionMeta[e.sessionId],cwd:e.cwd}}};case"move":{i(e.sourceCollectionId,e.sessionId),l(e.collectionId,e.sessionId);let d=r[e.collectionId].sessionIds.filter((t)=>t!==e.sessionId);d.splice(e.index??d.length,0,e.sessionId),n(e.collectionId,{sessionIds:d,collapsed:!1});break}case"reorder":{if(e.id==="collection-default")throw Error("Default collection cannot be reordered");let s=o.order.filter((d)=>d!==e.id);return s.splice(e.index,0,e.id),{...o,order:s}}case"forget":{for(let d of o.order)i(d,e.sessionId);let s={...o.sessionMeta};return delete s[e.sessionId],{...o,collections:r,sessionMeta:s}}case"remove":for(let s of e.collectionId===void 0?o.order:[e.collectionId])i(s,e.sessionId);break;case"favorite":if(o.order.some((s)=>r[s].sessionIds.includes(e.sessionId)))for(let s of o.order)i(s,e.sessionId);else l("collection-default",e.sessionId);break;case"meta":{let s=o.sessionMeta[e.sessionId],d={...s};if(e.meta.cwd!==void 0)d.cwd=e.meta.cwd;if(e.meta.title!==void 0&&!s?.titleOverride)d.title=e.meta.title;if(s?.cwd===d.cwd&&s?.title===d.title)return o;return{...o,sessionMeta:{...o.sessionMeta,[e.sessionId]:d}}}case"renameSession":{let s=e.title.trim();return{...o,sessionMeta:{...o.sessionMeta,[e.sessionId]:{...o.sessionMeta[e.sessionId],title:s||void 0,titleOverride:s.length>0}}}}}return{...o,collections:r}}function C(o,e=c()){let r={collections:{...e.collections},order:[...e.order],sessionMeta:{...e.sessionMeta}};for(let n of o){for(let[i,l]of Object.entries(n.sessionMeta??{})){let s=r.sessionMeta[i];r.sessionMeta[i]=s?.titleOverride?{...l,...s}:{...s,...l}}for(let i of n.order){if(i==="collection-default")continue;let l=n.collections[i];if(!l)throw Error(`Persisted collection missing: ${i}`);let s=r.collections[i];if(r.collections[i]={...l,...e.collections[i],sessionIds:[...new Set([...s?.sessionIds??[],...l.sessionIds??[]])]},!r.order.includes(i))r.order.push(i)}}return r}export{f as DEFAULT_COLLECTION_ID,u as applyCollectionAction,m as getCollectionName,c as initialCollectionData,C as migrateCollections};
package/package.json CHANGED
@@ -1,6 +1,32 @@
1
1
  {
2
2
  "name": "@alwith/module-collection",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.0.2",
4
+ "type": "module",
5
+ "exports": {
6
+ ".": {
7
+ "types": "./dist/index.d.ts",
8
+ "import": "./dist/index.js",
9
+ "default": "./dist/index.js"
10
+ }
11
+ },
12
+ "files": [
13
+ "dist",
14
+ "LICENSE",
15
+ "THIRD_PARTY_NOTICES.md"
16
+ ],
17
+ "scripts": {
18
+ "build": "bun ../../scripts/build-npm.ts",
19
+ "test": "bun test src",
20
+ "prepack": "bun run build"
21
+ },
22
+ "license": "SEE LICENSE IN LICENSE",
23
+ "publishConfig": {
24
+ "access": "public",
25
+ "registry": "https://registry.npmjs.org"
26
+ },
27
+ "repository": {
28
+ "type": "git",
29
+ "url": "git+https://github.com/ALwith-ai/alwith-modules.git",
30
+ "directory": "packages/collection"
31
+ }
32
+ }
package/README.md DELETED
@@ -1,3 +0,0 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.