@weiliang0121/capix-measurement 0.0.0-stage → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 wei.liang (https://github.com/weiliang0121)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,21 @@
1
- # Temporary Holding Version
1
+ # @weiliang0121/capix-measurement
2
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.
3
+ Message usage measurement and resource contracts for CAPiX.
4
+
5
+ `MessageUsage` consumes the public Transcript `Message` type. Counts use object identity: each selected message is counted once per `add` call, equal text in distinct objects counts separately, and each instance owns its independent counts. Measurement does not depend on transport DTOs.
6
+
7
+ ES modules and TypeScript declarations. Requires Node.js 22.23.2 or newer.
8
+
9
+ ```sh
10
+ npm install @weiliang0121/capix-measurement
11
+ ```
12
+
13
+ ## Public entry points
14
+
15
+ - `@weiliang0121/capix-measurement`
16
+
17
+ This package is part of CAPiX. The npm distribution contains compiled JavaScript, type declarations, and this package's MIT license. Reference services and client applications are not included in this package or the initial npm release.
18
+
19
+ ## License
20
+
21
+ MIT. Copyright (c) 2026 wei.liang. See [LICENSE](LICENSE).
@@ -0,0 +1,2 @@
1
+ export { MessageUsage } from './usage.js';
2
+ export { MessageUsageResource } from './resource.js';
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ /*! MIT License | Copyright (c) 2026 wei.liang | See LICENSE */
2
+ import{MessageUsage}from"./usage.js";import{MessageUsageResource}from"./resource.js";export{MessageUsage,MessageUsageResource};
@@ -0,0 +1,8 @@
1
+ import { ResourceOffer } from '@weiliang0121/capix-resources';
2
+ import type { MessageUsage } from './usage.js';
3
+ import type { Message } from '@weiliang0121/capix-transcript';
4
+ export declare const MessageUsageResource: Readonly<{
5
+ record: ResourceOffer<MessageUsage, Readonly<{
6
+ add(messages: readonly Readonly<Message>[]): void;
7
+ }>, MessageUsage, never>;
8
+ }>;
@@ -0,0 +1,2 @@
1
+ /*! MIT License | Copyright (c) 2026 wei.liang | See LICENSE */
2
+ var __defProp=Object.defineProperty;var __name=(target,value)=>__defProp(target,"name",{value,configurable:!0});import{ResourceOffer}from"@weiliang0121/capix-resources";const MessageUsageResource=Object.freeze({record:new ResourceOffer({name:"message-usage.record",expose:__name((usage,activity)=>Object.freeze({add(messages){activity.runSync("add",{input:__name(()=>({count:new Set(messages).size}),"input")},()=>usage.add(messages))}}),"expose"),timing:"access",describe:__name(()=>({operation:"count-selected-messages"}),"describe")})});export{MessageUsageResource};
@@ -0,0 +1,6 @@
1
+ import type { Message } from '@weiliang0121/capix-transcript';
2
+ export declare class MessageUsage {
3
+ #private;
4
+ get(message: Readonly<Message>): number;
5
+ add(messages: readonly Readonly<Message>[]): void;
6
+ }
package/dist/usage.js ADDED
@@ -0,0 +1,2 @@
1
+ /*! MIT License | Copyright (c) 2026 wei.liang | See LICENSE */
2
+ var __defProp=Object.defineProperty;var __name=(target,value)=>__defProp(target,"name",{value,configurable:!0});class MessageUsage{static{__name(this,"MessageUsage")}#counts=new WeakMap;get(message){return this.#counts.get(message)??0}add(messages){for(const message of new Set(messages))this.#counts.set(message,this.get(message)+1)}}export{MessageUsage};
package/package.json CHANGED
@@ -1,6 +1,44 @@
1
1
  {
2
2
  "name": "@weiliang0121/capix-measurement",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.2.0",
4
+ "private": false,
5
+ "type": "module",
6
+ "exports": {
7
+ ".": {
8
+ "types": "./dist/index.d.ts",
9
+ "import": "./dist/index.js"
10
+ }
11
+ },
12
+ "dependencies": {
13
+ "@weiliang0121/capix-transcript": "0.2.0",
14
+ "@weiliang0121/capix-resources": "0.2.0"
15
+ },
16
+ "description": "Message usage measurement and resource contracts for CAPiX.",
17
+ "license": "MIT",
18
+ "author": "wei.liang (https://github.com/weiliang0121)",
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "git+https://github.com/weiliang0121/capix.git",
22
+ "directory": "packages/measurement"
23
+ },
24
+ "engines": {
25
+ "node": ">=22.23.2"
26
+ },
27
+ "main": "./dist/index.js",
28
+ "types": "./dist/index.d.ts",
29
+ "files": [
30
+ "dist/**/*.js",
31
+ "dist/**/*.d.ts",
32
+ "LICENSE",
33
+ "README.md"
34
+ ],
35
+ "publishConfig": {
36
+ "access": "public",
37
+ "registry": "https://registry.npmjs.org"
38
+ },
39
+ "scripts": {
40
+ "build": "tsc -p tsconfig.json",
41
+ "typecheck": "tsc -p tsconfig.json --noEmit",
42
+ "test": "node ../../scripts/test/run.mjs --package ."
43
+ }
6
44
  }