@substrat-run/engine-metering 0.3.9 → 0.4.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/dist/entities.d.ts +101 -0
- package/dist/entities.d.ts.map +1 -0
- package/dist/entities.js +72 -0
- package/dist/entities.js.map +1 -0
- package/dist/formats.d.ts +49 -0
- package/dist/formats.d.ts.map +1 -0
- package/dist/formats.js +50 -0
- package/dist/formats.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -15
- package/dist/index.js.map +1 -1
- package/dist/operations.d.ts +257 -0
- package/dist/operations.d.ts.map +1 -0
- package/dist/operations.js +181 -0
- package/dist/operations.js.map +1 -0
- package/package.json +5 -5
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* engine-metering's entities (#697/#707), landed for #865's tail.
|
|
4
|
+
*
|
|
5
|
+
* Three of the four tables are entities and one deliberately is not.
|
|
6
|
+
*
|
|
7
|
+
* - **`metering-meter`** is what the platform points at when a meter is
|
|
8
|
+
* configured — `metering.meter-configured` names it as its `EntityRef`, and it
|
|
9
|
+
* has always used that spelling. Keyed by `key` rather than a ULID, which is
|
|
10
|
+
* the point of a meter: `api.calls` is the same meter in every scope that
|
|
11
|
+
* configures one.
|
|
12
|
+
* - **`metering-entry`** is one observation in the append-only ledger. An entity
|
|
13
|
+
* because it has an id and a lifetime of its own — a dedupe replay returns the
|
|
14
|
+
* existing one rather than writing a second.
|
|
15
|
+
* - **`metering-period`** is a close: immutable once written, and the thing a
|
|
16
|
+
* vertical reads back to price.
|
|
17
|
+
* - **`metering_period_lines`** is NOT an entity. A line is a period's frozen
|
|
18
|
+
* aggregate for one meter — it has no identity outside the close that made it,
|
|
19
|
+
* nothing ever refers to one, and an `EntityRef` to a line would be a reference
|
|
20
|
+
* to a third of a period.
|
|
21
|
+
*
|
|
22
|
+
* No `parents`. An entry's `subject` is an opaque `EntityRef` into whatever the
|
|
23
|
+
* VERTICAL is metering — a tenant, a site, a robot — so the edge is the
|
|
24
|
+
* vertical's to declare and this engine cannot know it. A period's lines are the
|
|
25
|
+
* period's own rows rather than children.
|
|
26
|
+
*/
|
|
27
|
+
export declare const meteringEntities: {
|
|
28
|
+
readonly 'metering-meter': {
|
|
29
|
+
readonly table: "metering_meters";
|
|
30
|
+
readonly fields: z.ZodObject<{
|
|
31
|
+
key: z.ZodString;
|
|
32
|
+
kind: z.ZodEnum<{
|
|
33
|
+
counter: "counter";
|
|
34
|
+
gauge: "gauge";
|
|
35
|
+
}>;
|
|
36
|
+
unit: z.ZodString;
|
|
37
|
+
description: z.ZodNullable<z.ZodString>;
|
|
38
|
+
active: z.ZodNumber;
|
|
39
|
+
created_at: z.ZodString;
|
|
40
|
+
}, z.core.$strip>;
|
|
41
|
+
};
|
|
42
|
+
readonly 'metering-entry': {
|
|
43
|
+
readonly table: "metering_entries";
|
|
44
|
+
readonly fields: z.ZodObject<{
|
|
45
|
+
id: z.ZodString;
|
|
46
|
+
meter_key: z.ZodString;
|
|
47
|
+
qty: z.ZodString;
|
|
48
|
+
subject_type: z.ZodNullable<z.ZodString>;
|
|
49
|
+
subject_id: z.ZodNullable<z.ZodString>;
|
|
50
|
+
occurred_at: z.ZodString;
|
|
51
|
+
dedupe_key: z.ZodString;
|
|
52
|
+
note: z.ZodNullable<z.ZodString>;
|
|
53
|
+
created_by: z.ZodString;
|
|
54
|
+
created_at: z.ZodString;
|
|
55
|
+
}, z.core.$strip>;
|
|
56
|
+
};
|
|
57
|
+
readonly 'metering-period': {
|
|
58
|
+
readonly table: "metering_periods";
|
|
59
|
+
readonly fields: z.ZodObject<{
|
|
60
|
+
id: z.ZodString;
|
|
61
|
+
from_at: z.ZodString;
|
|
62
|
+
to_at: z.ZodString;
|
|
63
|
+
closed_by: z.ZodString;
|
|
64
|
+
closed_at: z.ZodString;
|
|
65
|
+
}, z.core.$strip>;
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
/** The stored meter row — for a vertical declaring a return against it. */
|
|
69
|
+
export declare const meterRow: z.ZodObject<{
|
|
70
|
+
key: z.ZodString;
|
|
71
|
+
kind: z.ZodEnum<{
|
|
72
|
+
counter: "counter";
|
|
73
|
+
gauge: "gauge";
|
|
74
|
+
}>;
|
|
75
|
+
unit: z.ZodString;
|
|
76
|
+
description: z.ZodNullable<z.ZodString>;
|
|
77
|
+
active: z.ZodNumber;
|
|
78
|
+
created_at: z.ZodString;
|
|
79
|
+
}, z.core.$strip>;
|
|
80
|
+
/** One observation in the ledger, as stored. */
|
|
81
|
+
export declare const entryRow: z.ZodObject<{
|
|
82
|
+
id: z.ZodString;
|
|
83
|
+
meter_key: z.ZodString;
|
|
84
|
+
qty: z.ZodString;
|
|
85
|
+
subject_type: z.ZodNullable<z.ZodString>;
|
|
86
|
+
subject_id: z.ZodNullable<z.ZodString>;
|
|
87
|
+
occurred_at: z.ZodString;
|
|
88
|
+
dedupe_key: z.ZodString;
|
|
89
|
+
note: z.ZodNullable<z.ZodString>;
|
|
90
|
+
created_by: z.ZodString;
|
|
91
|
+
created_at: z.ZodString;
|
|
92
|
+
}, z.core.$strip>;
|
|
93
|
+
/** One close, as stored. */
|
|
94
|
+
export declare const periodRow: z.ZodObject<{
|
|
95
|
+
id: z.ZodString;
|
|
96
|
+
from_at: z.ZodString;
|
|
97
|
+
to_at: z.ZodString;
|
|
98
|
+
closed_by: z.ZodString;
|
|
99
|
+
closed_at: z.ZodString;
|
|
100
|
+
}, z.core.$strip>;
|
|
101
|
+
//# sourceMappingURL=entities.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entities.d.ts","sourceRoot":"","sources":["../src/entities.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqC3B,CAAC;AAEH,2EAA2E;AAC3E,eAAO,MAAM,QAAQ;;;;;;;;;;iBAA4C,CAAC;AAClE,gDAAgD;AAChD,eAAO,MAAM,QAAQ;;;;;;;;;;;iBAA4C,CAAC;AAClE,4BAA4B;AAC5B,eAAO,MAAM,SAAS;;;;;;iBAA6C,CAAC"}
|
package/dist/entities.js
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { defineEntities } from '@substrat-run/contracts';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
/**
|
|
4
|
+
* engine-metering's entities (#697/#707), landed for #865's tail.
|
|
5
|
+
*
|
|
6
|
+
* Three of the four tables are entities and one deliberately is not.
|
|
7
|
+
*
|
|
8
|
+
* - **`metering-meter`** is what the platform points at when a meter is
|
|
9
|
+
* configured — `metering.meter-configured` names it as its `EntityRef`, and it
|
|
10
|
+
* has always used that spelling. Keyed by `key` rather than a ULID, which is
|
|
11
|
+
* the point of a meter: `api.calls` is the same meter in every scope that
|
|
12
|
+
* configures one.
|
|
13
|
+
* - **`metering-entry`** is one observation in the append-only ledger. An entity
|
|
14
|
+
* because it has an id and a lifetime of its own — a dedupe replay returns the
|
|
15
|
+
* existing one rather than writing a second.
|
|
16
|
+
* - **`metering-period`** is a close: immutable once written, and the thing a
|
|
17
|
+
* vertical reads back to price.
|
|
18
|
+
* - **`metering_period_lines`** is NOT an entity. A line is a period's frozen
|
|
19
|
+
* aggregate for one meter — it has no identity outside the close that made it,
|
|
20
|
+
* nothing ever refers to one, and an `EntityRef` to a line would be a reference
|
|
21
|
+
* to a third of a period.
|
|
22
|
+
*
|
|
23
|
+
* No `parents`. An entry's `subject` is an opaque `EntityRef` into whatever the
|
|
24
|
+
* VERTICAL is metering — a tenant, a site, a robot — so the edge is the
|
|
25
|
+
* vertical's to declare and this engine cannot know it. A period's lines are the
|
|
26
|
+
* period's own rows rather than children.
|
|
27
|
+
*/
|
|
28
|
+
export const meteringEntities = defineEntities({
|
|
29
|
+
'metering-meter': {
|
|
30
|
+
table: 'metering_meters',
|
|
31
|
+
fields: z.object({
|
|
32
|
+
key: z.string(),
|
|
33
|
+
kind: z.enum(['counter', 'gauge']),
|
|
34
|
+
unit: z.string(),
|
|
35
|
+
description: z.string().nullable(),
|
|
36
|
+
active: z.number(),
|
|
37
|
+
created_at: z.string(),
|
|
38
|
+
}),
|
|
39
|
+
},
|
|
40
|
+
'metering-entry': {
|
|
41
|
+
table: 'metering_entries',
|
|
42
|
+
fields: z.object({
|
|
43
|
+
id: z.string(),
|
|
44
|
+
meter_key: z.string(),
|
|
45
|
+
qty: z.string(),
|
|
46
|
+
subject_type: z.string().nullable(),
|
|
47
|
+
subject_id: z.string().nullable(),
|
|
48
|
+
occurred_at: z.string(),
|
|
49
|
+
dedupe_key: z.string(),
|
|
50
|
+
note: z.string().nullable(),
|
|
51
|
+
created_by: z.string(),
|
|
52
|
+
created_at: z.string(),
|
|
53
|
+
}),
|
|
54
|
+
},
|
|
55
|
+
'metering-period': {
|
|
56
|
+
table: 'metering_periods',
|
|
57
|
+
fields: z.object({
|
|
58
|
+
id: z.string(),
|
|
59
|
+
from_at: z.string(),
|
|
60
|
+
to_at: z.string(),
|
|
61
|
+
closed_by: z.string(),
|
|
62
|
+
closed_at: z.string(),
|
|
63
|
+
}),
|
|
64
|
+
},
|
|
65
|
+
});
|
|
66
|
+
/** The stored meter row — for a vertical declaring a return against it. */
|
|
67
|
+
export const meterRow = meteringEntities['metering-meter'].fields;
|
|
68
|
+
/** One observation in the ledger, as stored. */
|
|
69
|
+
export const entryRow = meteringEntities['metering-entry'].fields;
|
|
70
|
+
/** One close, as stored. */
|
|
71
|
+
export const periodRow = meteringEntities['metering-period'].fields;
|
|
72
|
+
//# sourceMappingURL=entities.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entities.js","sourceRoot":"","sources":["../src/entities.ts"],"names":[],"mappings":"AAAA,OAAO,EAA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AAC,CAAC,MAAM,CAAC;YACf,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE;YACd,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE;YACnB,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE;YACjB,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE;YACrB,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE;SACtB,CAAC;KACH;CACF,CAAC,CAAC;AAEH,2EAA2E;AAC3E,MAAM,CAAC,MAAM,QAAQ,GAAG,gBAAgB,CAAC,gBAAgB,CAAC,CAAC,MAAM,CAAC;AAClE,gDAAgD;AAChD,MAAM,CAAC,MAAM,QAAQ,GAAG,gBAAgB,CAAC,gBAAgB,CAAC,CAAC,MAAM,CAAC;AAClE,4BAA4B;AAC5B,MAAM,CAAC,MAAM,SAAS,GAAG,gBAAgB,CAAC,iBAAiB,CAAC,CAAC,MAAM,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The value formats metering speaks, in the one place both ends can import.
|
|
3
|
+
*
|
|
4
|
+
* A leaf module on purpose: `index.ts` imports `operations.ts` (the declared
|
|
5
|
+
* surface is what the module registration is built from), so `operations.ts`
|
|
6
|
+
* cannot import back. Without a third file the two ends re-express the same
|
|
7
|
+
* rules by hand, and they drifted exactly as you would expect — the declared
|
|
8
|
+
* input accepted `"not-a-date"` and `"-"`, and the handler's own parse then
|
|
9
|
+
* refused them. That is the failure the host's boundary parse exists to prevent:
|
|
10
|
+
* an operation contract that says a value is valid, and a handler that disagrees
|
|
11
|
+
* after the guards have run.
|
|
12
|
+
*
|
|
13
|
+
* The declared inputs and the in-scope functions therefore share the FORMAT and
|
|
14
|
+
* differ only where they must — see `isoInstant` below.
|
|
15
|
+
*/
|
|
16
|
+
import { z } from '@substrat-run/contracts';
|
|
17
|
+
/**
|
|
18
|
+
* UTC ISO-8601, at most millisecond precision.
|
|
19
|
+
*
|
|
20
|
+
* Mixed precision would break every string comparison in this engine
|
|
21
|
+
* ('…T00:00:00Z' sorts AFTER '…T00:00:00.000Z'), which is what the normalisation
|
|
22
|
+
* in `isoInstant` is for — and why the two forms exist rather than one.
|
|
23
|
+
*/
|
|
24
|
+
export declare const ISO_INSTANT: RegExp;
|
|
25
|
+
/**
|
|
26
|
+
* What a CALLER may send — validating, never transforming.
|
|
27
|
+
*
|
|
28
|
+
* The declared surface uses this one. A transforming schema at the door would
|
|
29
|
+
* hand the handler a value the in-scope function then re-parses, and a declared
|
|
30
|
+
* input is meant to describe what may be sent rather than what will be stored.
|
|
31
|
+
*/
|
|
32
|
+
export declare const isoInstantIn: z.ZodString;
|
|
33
|
+
/**
|
|
34
|
+
* What gets STORED — the same format, normalised to millisecond precision.
|
|
35
|
+
*
|
|
36
|
+
* The transform is the storage decision, so it stays on the storage side; both
|
|
37
|
+
* ends accept exactly the same set of strings.
|
|
38
|
+
*/
|
|
39
|
+
export declare const isoInstant: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
40
|
+
/** A non-negative decimal string — a gauge's level sample. Never a float (D-E). */
|
|
41
|
+
export declare const nonNegDecimal: z.ZodString;
|
|
42
|
+
/**
|
|
43
|
+
* A signed decimal string — a counter's delta, and the widest quantity any
|
|
44
|
+
* operation accepts. The per-kind narrowing (a gauge refuses a negative) needs
|
|
45
|
+
* to know the meter, so it stays in the handler; a declared input that claimed
|
|
46
|
+
* it would read stricter than it is.
|
|
47
|
+
*/
|
|
48
|
+
export declare const signedDecimal: z.ZodString;
|
|
49
|
+
//# sourceMappingURL=formats.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formats.d.ts","sourceRoot":"","sources":["../src/formats.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,yBAAyB,CAAC;AAE5C;;;;;;GAMG;AACH,eAAO,MAAM,WAAW,QAAuD,CAAC;AAIhF;;;;;;GAMG;AACH,eAAO,MAAM,YAAY,aAAiD,CAAC;AAE3E;;;;;GAKG;AACH,eAAO,MAAM,UAAU,wDAA2D,CAAC;AAEnF,mFAAmF;AACnF,eAAO,MAAM,aAAa,aAA0E,CAAC;AAErG;;;;;GAKG;AACH,eAAO,MAAM,aAAa,aAA+D,CAAC"}
|
package/dist/formats.js
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The value formats metering speaks, in the one place both ends can import.
|
|
3
|
+
*
|
|
4
|
+
* A leaf module on purpose: `index.ts` imports `operations.ts` (the declared
|
|
5
|
+
* surface is what the module registration is built from), so `operations.ts`
|
|
6
|
+
* cannot import back. Without a third file the two ends re-express the same
|
|
7
|
+
* rules by hand, and they drifted exactly as you would expect — the declared
|
|
8
|
+
* input accepted `"not-a-date"` and `"-"`, and the handler's own parse then
|
|
9
|
+
* refused them. That is the failure the host's boundary parse exists to prevent:
|
|
10
|
+
* an operation contract that says a value is valid, and a handler that disagrees
|
|
11
|
+
* after the guards have run.
|
|
12
|
+
*
|
|
13
|
+
* The declared inputs and the in-scope functions therefore share the FORMAT and
|
|
14
|
+
* differ only where they must — see `isoInstant` below.
|
|
15
|
+
*/
|
|
16
|
+
import { z } from '@substrat-run/contracts';
|
|
17
|
+
/**
|
|
18
|
+
* UTC ISO-8601, at most millisecond precision.
|
|
19
|
+
*
|
|
20
|
+
* Mixed precision would break every string comparison in this engine
|
|
21
|
+
* ('…T00:00:00Z' sorts AFTER '…T00:00:00.000Z'), which is what the normalisation
|
|
22
|
+
* in `isoInstant` is for — and why the two forms exist rather than one.
|
|
23
|
+
*/
|
|
24
|
+
export const ISO_INSTANT = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d{1,3})?Z$/;
|
|
25
|
+
const INSTANT_MESSAGE = 'must be a UTC ISO-8601 instant (…Z)';
|
|
26
|
+
/**
|
|
27
|
+
* What a CALLER may send — validating, never transforming.
|
|
28
|
+
*
|
|
29
|
+
* The declared surface uses this one. A transforming schema at the door would
|
|
30
|
+
* hand the handler a value the in-scope function then re-parses, and a declared
|
|
31
|
+
* input is meant to describe what may be sent rather than what will be stored.
|
|
32
|
+
*/
|
|
33
|
+
export const isoInstantIn = z.string().regex(ISO_INSTANT, INSTANT_MESSAGE);
|
|
34
|
+
/**
|
|
35
|
+
* What gets STORED — the same format, normalised to millisecond precision.
|
|
36
|
+
*
|
|
37
|
+
* The transform is the storage decision, so it stays on the storage side; both
|
|
38
|
+
* ends accept exactly the same set of strings.
|
|
39
|
+
*/
|
|
40
|
+
export const isoInstant = isoInstantIn.transform((s) => new Date(s).toISOString());
|
|
41
|
+
/** A non-negative decimal string — a gauge's level sample. Never a float (D-E). */
|
|
42
|
+
export const nonNegDecimal = z.string().regex(/^\d+(\.\d{1,6})?$/, 'must be a non-negative decimal');
|
|
43
|
+
/**
|
|
44
|
+
* A signed decimal string — a counter's delta, and the widest quantity any
|
|
45
|
+
* operation accepts. The per-kind narrowing (a gauge refuses a negative) needs
|
|
46
|
+
* to know the meter, so it stays in the handler; a declared input that claimed
|
|
47
|
+
* it would read stricter than it is.
|
|
48
|
+
*/
|
|
49
|
+
export const signedDecimal = z.string().regex(/^-?\d+(\.\d{1,6})?$/, 'must be a decimal');
|
|
50
|
+
//# sourceMappingURL=formats.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formats.js","sourceRoot":"","sources":["../src/formats.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,yBAAyB,CAAC;AAE5C;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,oDAAoD,CAAC;AAEhF,MAAM,eAAe,GAAG,qCAAqC,CAAC;AAE9D;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,WAAW,EAAE,eAAe,CAAC,CAAC;AAE3E;;;;;GAKG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,YAAY,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC;AAEnF,mFAAmF;AACnF,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,mBAAmB,EAAE,gCAAgC,CAAC,CAAC;AAErG;;;;;GAKG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,qBAAqB,EAAE,mBAAmB,CAAC,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -12,6 +12,8 @@ import { type EntityRef } from '@substrat-run/contracts';
|
|
|
12
12
|
export declare const METERING_CONFLICT_REASONS: readonly ['dedupe_mismatch', 'definition_frozen', 'meter_inactive', 'period_closed', 'period_overlap'];
|
|
13
13
|
export type MeteringConflictReason = (typeof METERING_CONFLICT_REASONS)[number];
|
|
14
14
|
import { type ModuleRegistration, type OperationContext } from '@substrat-run/kernel';
|
|
15
|
+
export { meteringEntities, meterRow, entryRow, periodRow } from './entities.js';
|
|
16
|
+
export { meteringOperations, METERING_PERMISSIONS, meter, usageEntry, meteringPeriod, periodLine, } from './operations.js';
|
|
15
17
|
export declare const PERM: {
|
|
16
18
|
read: string & z.$brand<"PermissionKey">;
|
|
17
19
|
record: string & z.$brand<"PermissionKey">;
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAOL,KAAK,SAAS,EA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rB,KAAK,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,GACjD;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAK5C;AAED,wBAAgB,WAAW,CACzB,GAAG,EAAE,gBAAgB,EACrB,KAAK,CAAC,EAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,SAAS,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,EAAE,CAAC,EAAE,MAAM,CAAA;CAAE,GAC1E,UAAU,EAAE,CAqBd;AAED,eAAO,MAAM,gBAAgB;;;iBAG3B,CAAC;AACH,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAEhE;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CACzB,GAAG,EAAE,gBAAgB,EACrB,QAAQ,EAAE,gBAAgB,GACzB;IAAE,MAAM,EAAE,cAAc,CAAC;IAAC,KAAK,EAAE,UAAU,EAAE,CAAA;CAAE,CA8CjD;AAED,wBAAgB,WAAW,CAAC,GAAG,EAAE,gBAAgB,GAAG,cAAc,EAAE,CAInE;AAED,wBAAgB,WAAW,CAAC,GAAG,EAAE,gBAAgB,EAAE,KAAK,EAAE;IAAE,QAAQ,EAAE,MAAM,CAAA;CAAE,GAAG,UAAU,EAAE,CAW5F;AAwDD,eAAO,MAAM,cAAc,EAAE,kBAe5B,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { addDecimal, compareDecimal, entityRef, moduleManifest, permissionKey, substratError, } from '@substrat-run/contracts';
|
|
2
|
+
import { addDecimal, compareDecimal, entityRef, moduleManifest, operationInputsOf, permissionKey, substratError, } from '@substrat-run/contracts';
|
|
3
3
|
/**
|
|
4
4
|
* The conflict reasons this engine raises — its own vocabulary, narrowing the platform's
|
|
5
5
|
* `conflict` code (#113). Exported so a vertical can branch on WHY a refusal happened
|
|
@@ -32,6 +32,14 @@ import { assertAllowed, ulid, } from '@substrat-run/kernel';
|
|
|
32
32
|
// `metering.period-closed` event exactly like the timesheet hand-off. It is the
|
|
33
33
|
// BILLABLE plane; platform metering stays Analytics Engine (D-A).
|
|
34
34
|
// ============================================================================
|
|
35
|
+
// The entity registry + declared operation surface (#697/#865): what is stored,
|
|
36
|
+
// and what each operation checks and takes.
|
|
37
|
+
export { meteringEntities, meterRow, entryRow, periodRow } from './entities.js';
|
|
38
|
+
export { meteringOperations, METERING_PERMISSIONS, meter, usageEntry, meteringPeriod, periodLine, } from './operations.js';
|
|
39
|
+
import { meteringOperations } from './operations.js';
|
|
40
|
+
// The value formats, shared with the declared surface above so a caller cannot be
|
|
41
|
+
// told a value is acceptable and then have the handler refuse it.
|
|
42
|
+
import { isoInstant, nonNegDecimal, signedDecimal } from './formats.js';
|
|
35
43
|
export const PERM = {
|
|
36
44
|
read: permissionKey.parse('metering:read'),
|
|
37
45
|
record: permissionKey.parse('metering:record'),
|
|
@@ -110,20 +118,6 @@ export const meteringMigrations = [
|
|
|
110
118
|
`,
|
|
111
119
|
},
|
|
112
120
|
];
|
|
113
|
-
// ---------------------------------------------------------------------------
|
|
114
|
-
// Schemas & shapes
|
|
115
|
-
// ---------------------------------------------------------------------------
|
|
116
|
-
/**
|
|
117
|
-
* Instants are UTC ISO-8601, normalized to millisecond precision so
|
|
118
|
-
* lexicographic order IS chronological order — mixed precision would break
|
|
119
|
-
* every string comparison below ('…T00:00:00Z' sorts AFTER '…T00:00:00.000Z').
|
|
120
|
-
*/
|
|
121
|
-
const isoInstant = z
|
|
122
|
-
.string()
|
|
123
|
-
.regex(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d{1,3})?Z$/, 'must be a UTC ISO-8601 instant (…Z)')
|
|
124
|
-
.transform((s) => new Date(s).toISOString());
|
|
125
|
-
const nonNegDecimal = z.string().regex(/^\d+(\.\d{1,6})?$/, 'must be a non-negative decimal');
|
|
126
|
-
const signedDecimal = z.string().regex(/^-?\d+(\.\d{1,6})?$/, 'must be a decimal');
|
|
127
121
|
const toMeter = (r) => ({
|
|
128
122
|
key: r.key,
|
|
129
123
|
kind: r.kind,
|
|
@@ -460,6 +454,8 @@ const periodLinesOp = async (ctx, input) => {
|
|
|
460
454
|
export const meteringModule = {
|
|
461
455
|
manifest: meteringManifest,
|
|
462
456
|
migrations: meteringMigrations,
|
|
457
|
+
// Parse, don't trust: the HOST applies the declared schemas, on every path in.
|
|
458
|
+
operationInputs: operationInputsOf(meteringOperations),
|
|
463
459
|
operations: {
|
|
464
460
|
'metering/configure-meter': configureMeterOp,
|
|
465
461
|
'metering/list-meters': listMetersOp,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACL,UAAU,EACV,cAAc,EACd,SAAS,EACT,cAAc,EACd,aAAa,EAEb,aAAa,GACd,MAAM,yBAAyB,CAAC;AAEjC;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG;IACvC,iBAAiB;IACjB,mBAAmB;IACnB,gBAAgB;IAChB,eAAe;IACf,gBAAgB;CACR,CAAC;AAGX,gGAAgG;AAChG,MAAM,QAAQ,GAAG,CAAC,MAA8B,EAAE,OAAe,EAAE,EAAE,CAAC,aAAa,CAAC,UAAU,EAAE,OAAO,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;AAErH,OAAO,EACL,aAAa,EACb,IAAI,GAIL,MAAM,sBAAsB,CAAC;AAE9B,+EAA+E;AAC/E,gEAAgE;AAChE,8EAA8E;AAC9E,2EAA2E;AAC3E,gFAAgF;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ied
|
|
3
|
+
* to the last three packages that had none).
|
|
4
|
+
*
|
|
5
|
+
* ## Why this file exists now
|
|
6
|
+
*
|
|
7
|
+
* It used to not, and the cost was stated rather than hidden: this engine's
|
|
8
|
+
* node-only claim was a `nodeOnlySuite` tripwire — a grep of `index.ts` for a
|
|
9
|
+
* two-argument `ctx.check`. That proves an absence, never a behaviour, and it is
|
|
10
|
+
* lexical: a check assembled through a helper is invisible to it. A DECLARATION
|
|
11
|
+
* is exact. `planEntityCheckCoverage` reads these eight entries the same way the
|
|
12
|
+
* conformance kit does, so "this engine narrows nowhere" is a fact about the
|
|
13
|
+
* surface rather than about the text, and the day one of them narrows the
|
|
14
|
+
* assessment goes red.
|
|
15
|
+
*
|
|
16
|
+
* ## Every check is a node check, and that is the design
|
|
17
|
+
*
|
|
18
|
+
* Metering counts what a scope consumed. A meter is scope-level configuration,
|
|
19
|
+
* `record` is machine-driven ingest, and a period closes for the scope as a
|
|
20
|
+
* whole — none of the four keys has a per-entity reader. A principal entitled to
|
|
21
|
+
* see one meter's usage and not another's is a reporting concern in the vertical
|
|
22
|
+
* above, expressed by what it queries rather than by narrowing the engine's own
|
|
23
|
+
* checks. Note what would change that: an entry's `subject` is an opaque
|
|
24
|
+
* `EntityRef` into the vertical's own noun, so if a per-subject read is ever
|
|
25
|
+
* wanted it is the VERTICAL that owns the edge and the walk.
|
|
26
|
+
*
|
|
27
|
+
* ## Shapes are the PUBLISHED ones, not the rows
|
|
28
|
+
*
|
|
29
|
+
* The outputs here are the camelCase projections the in-scope functions return
|
|
30
|
+
* (`Meter`, `UsageEntry`, `MeteringPeriod`, `PeriodLine`), not the snake_case
|
|
31
|
+
* rows in `entities.ts`. Both exist on purpose: the registry describes what is
|
|
32
|
+
* STORED (which is what a migration journal is compared against), and these
|
|
33
|
+
* describe what a caller receives.
|
|
34
|
+
*
|
|
35
|
+
* No `http` — an engine owns no URL shape. A vertical binds these names to its
|
|
36
|
+
* own paths with `defineEngineRoutes`.
|
|
37
|
+
*/
|
|
38
|
+
import { z } from '@substrat-run/contracts';
|
|
39
|
+
/** The keys these operations check. Mirrors `PERM` in index.ts. */
|
|
40
|
+
export declare const METERING_PERMISSIONS: readonly ['metering:read', 'metering:record', 'metering:configure', 'metering:close'];
|
|
41
|
+
/** What `configureMeter`/`listMeters` return: the meter, projected. */
|
|
42
|
+
export declare const meter: z.ZodObject<{
|
|
43
|
+
key: z.ZodString;
|
|
44
|
+
kind: z.ZodEnum<{
|
|
45
|
+
counter: "counter";
|
|
46
|
+
gauge: "gauge";
|
|
47
|
+
}>;
|
|
48
|
+
unit: z.ZodString;
|
|
49
|
+
description: z.ZodNullable<z.ZodString>;
|
|
50
|
+
active: z.ZodBoolean;
|
|
51
|
+
createdAt: z.ZodString;
|
|
52
|
+
}, z.core.$strip>;
|
|
53
|
+
/** One observation in the append-only ledger, projected. */
|
|
54
|
+
export declare const usageEntry: z.ZodObject<{
|
|
55
|
+
id: z.ZodString;
|
|
56
|
+
meterKey: z.ZodString;
|
|
57
|
+
qty: z.ZodString;
|
|
58
|
+
subject: z.ZodNullable<z.ZodObject<{
|
|
59
|
+
entityType: z.ZodString;
|
|
60
|
+
entityId: z.ZodString;
|
|
61
|
+
}, z.core.$strip>>;
|
|
62
|
+
occurredAt: z.ZodString;
|
|
63
|
+
dedupeKey: z.ZodString;
|
|
64
|
+
note: z.ZodNullable<z.ZodString>;
|
|
65
|
+
createdBy: z.ZodString;
|
|
66
|
+
createdAt: z.ZodString;
|
|
67
|
+
}, z.core.$strip>;
|
|
68
|
+
/** One close, projected. */
|
|
69
|
+
export declare const meteringPeriod: z.ZodObject<{
|
|
70
|
+
id: z.ZodString;
|
|
71
|
+
from: z.ZodString;
|
|
72
|
+
to: z.ZodString;
|
|
73
|
+
closedBy: z.ZodString;
|
|
74
|
+
closedAt: z.ZodString;
|
|
75
|
+
}, z.core.$strip>;
|
|
76
|
+
/** One meter's frozen aggregate for a closed period. Unpriced, by design (D-E). */
|
|
77
|
+
export declare const periodLine: z.ZodObject<{
|
|
78
|
+
meterKey: z.ZodString;
|
|
79
|
+
kind: z.ZodEnum<{
|
|
80
|
+
counter: "counter";
|
|
81
|
+
gauge: "gauge";
|
|
82
|
+
}>;
|
|
83
|
+
unit: z.ZodString;
|
|
84
|
+
qty: z.ZodString;
|
|
85
|
+
entryCount: z.ZodNumber;
|
|
86
|
+
}, z.core.$strip>;
|
|
87
|
+
export declare const meteringOperations: {
|
|
88
|
+
readonly 'metering/configure-meter': {
|
|
89
|
+
readonly summary: "Register a meter, or update its description and active flag";
|
|
90
|
+
readonly permission: "metering:configure";
|
|
91
|
+
readonly input: z.ZodObject<{
|
|
92
|
+
key: z.ZodString;
|
|
93
|
+
kind: z.ZodEnum<{
|
|
94
|
+
counter: "counter";
|
|
95
|
+
gauge: "gauge";
|
|
96
|
+
}>;
|
|
97
|
+
unit: z.ZodString;
|
|
98
|
+
description: z.ZodOptional<z.ZodString>;
|
|
99
|
+
active: z.ZodOptional<z.ZodBoolean>;
|
|
100
|
+
}, z.core.$strip>;
|
|
101
|
+
readonly output: z.ZodObject<{
|
|
102
|
+
key: z.ZodString;
|
|
103
|
+
kind: z.ZodEnum<{
|
|
104
|
+
counter: "counter";
|
|
105
|
+
gauge: "gauge";
|
|
106
|
+
}>;
|
|
107
|
+
unit: z.ZodString;
|
|
108
|
+
description: z.ZodNullable<z.ZodString>;
|
|
109
|
+
active: z.ZodBoolean;
|
|
110
|
+
createdAt: z.ZodString;
|
|
111
|
+
}, z.core.$strip>;
|
|
112
|
+
};
|
|
113
|
+
readonly 'metering/list-meters': {
|
|
114
|
+
readonly summary: "Every configured meter, by key";
|
|
115
|
+
readonly permission: "metering:read";
|
|
116
|
+
readonly output: z.ZodObject<{
|
|
117
|
+
key: z.ZodString;
|
|
118
|
+
kind: z.ZodEnum<{
|
|
119
|
+
counter: "counter";
|
|
120
|
+
gauge: "gauge";
|
|
121
|
+
}>;
|
|
122
|
+
unit: z.ZodString;
|
|
123
|
+
description: z.ZodNullable<z.ZodString>;
|
|
124
|
+
active: z.ZodBoolean;
|
|
125
|
+
createdAt: z.ZodString;
|
|
126
|
+
}, z.core.$strip>;
|
|
127
|
+
};
|
|
128
|
+
readonly 'metering/record': {
|
|
129
|
+
readonly summary: "Record one usage observation — idempotent per (meter, dedupeKey)";
|
|
130
|
+
readonly permission: "metering:record";
|
|
131
|
+
readonly input: z.ZodObject<{
|
|
132
|
+
meter: z.ZodString;
|
|
133
|
+
qty: z.ZodString;
|
|
134
|
+
subject: z.ZodOptional<z.ZodObject<{
|
|
135
|
+
entityType: z.ZodString;
|
|
136
|
+
entityId: z.ZodString;
|
|
137
|
+
}, z.core.$strip>>;
|
|
138
|
+
occurredAt: z.ZodOptional<z.ZodString>;
|
|
139
|
+
dedupeKey: z.ZodString;
|
|
140
|
+
note: z.ZodOptional<z.ZodString>;
|
|
141
|
+
}, z.core.$strip>;
|
|
142
|
+
readonly output: z.ZodObject<{
|
|
143
|
+
entry: z.ZodObject<{
|
|
144
|
+
id: z.ZodString;
|
|
145
|
+
meterKey: z.ZodString;
|
|
146
|
+
qty: z.ZodString;
|
|
147
|
+
subject: z.ZodNullable<z.ZodObject<{
|
|
148
|
+
entityType: z.ZodString;
|
|
149
|
+
entityId: z.ZodString;
|
|
150
|
+
}, z.core.$strip>>;
|
|
151
|
+
occurredAt: z.ZodString;
|
|
152
|
+
dedupeKey: z.ZodString;
|
|
153
|
+
note: z.ZodNullable<z.ZodString>;
|
|
154
|
+
createdBy: z.ZodString;
|
|
155
|
+
createdAt: z.ZodString;
|
|
156
|
+
}, z.core.$strip>;
|
|
157
|
+
deduped: z.ZodBoolean;
|
|
158
|
+
}, z.core.$strip>;
|
|
159
|
+
};
|
|
160
|
+
readonly 'metering/total': {
|
|
161
|
+
readonly summary: "Aggregate one meter over [from, to)";
|
|
162
|
+
readonly permission: "metering:read";
|
|
163
|
+
readonly input: z.ZodObject<{
|
|
164
|
+
meter: z.ZodString;
|
|
165
|
+
from: z.ZodString;
|
|
166
|
+
to: z.ZodString;
|
|
167
|
+
}, z.core.$strip>;
|
|
168
|
+
readonly output: z.ZodNullable<z.ZodObject<{
|
|
169
|
+
qty: z.ZodString;
|
|
170
|
+
entryCount: z.ZodNumber;
|
|
171
|
+
}, z.core.$strip>>;
|
|
172
|
+
};
|
|
173
|
+
readonly 'metering/list-entries': {
|
|
174
|
+
readonly summary: "The ledger, filtered by meter, subject or window";
|
|
175
|
+
readonly permission: "metering:read";
|
|
176
|
+
readonly input: z.ZodObject<{
|
|
177
|
+
meter: z.ZodOptional<z.ZodString>;
|
|
178
|
+
subject: z.ZodOptional<z.ZodObject<{
|
|
179
|
+
entityType: z.ZodString;
|
|
180
|
+
entityId: z.ZodString;
|
|
181
|
+
}, z.core.$strip>>;
|
|
182
|
+
from: z.ZodOptional<z.ZodString>;
|
|
183
|
+
to: z.ZodOptional<z.ZodString>;
|
|
184
|
+
}, z.core.$strip>;
|
|
185
|
+
readonly inputOptional: true;
|
|
186
|
+
readonly output: z.ZodObject<{
|
|
187
|
+
id: z.ZodString;
|
|
188
|
+
meterKey: z.ZodString;
|
|
189
|
+
qty: z.ZodString;
|
|
190
|
+
subject: z.ZodNullable<z.ZodObject<{
|
|
191
|
+
entityType: z.ZodString;
|
|
192
|
+
entityId: z.ZodString;
|
|
193
|
+
}, z.core.$strip>>;
|
|
194
|
+
occurredAt: z.ZodString;
|
|
195
|
+
dedupeKey: z.ZodString;
|
|
196
|
+
note: z.ZodNullable<z.ZodString>;
|
|
197
|
+
createdBy: z.ZodString;
|
|
198
|
+
createdAt: z.ZodString;
|
|
199
|
+
}, z.core.$strip>;
|
|
200
|
+
};
|
|
201
|
+
readonly 'metering/close-period': {
|
|
202
|
+
readonly summary: "Freeze [from, to) — aggregate every meter and advance the horizon";
|
|
203
|
+
readonly permission: "metering:close";
|
|
204
|
+
readonly input: z.ZodObject<{
|
|
205
|
+
from: z.ZodString;
|
|
206
|
+
to: z.ZodString;
|
|
207
|
+
}, z.core.$strip>;
|
|
208
|
+
readonly output: z.ZodObject<{
|
|
209
|
+
period: z.ZodObject<{
|
|
210
|
+
id: z.ZodString;
|
|
211
|
+
from: z.ZodString;
|
|
212
|
+
to: z.ZodString;
|
|
213
|
+
closedBy: z.ZodString;
|
|
214
|
+
closedAt: z.ZodString;
|
|
215
|
+
}, z.core.$strip>;
|
|
216
|
+
lines: z.ZodArray<z.ZodObject<{
|
|
217
|
+
meterKey: z.ZodString;
|
|
218
|
+
kind: z.ZodEnum<{
|
|
219
|
+
counter: "counter";
|
|
220
|
+
gauge: "gauge";
|
|
221
|
+
}>;
|
|
222
|
+
unit: z.ZodString;
|
|
223
|
+
qty: z.ZodString;
|
|
224
|
+
entryCount: z.ZodNumber;
|
|
225
|
+
}, z.core.$strip>>;
|
|
226
|
+
}, z.core.$strip>;
|
|
227
|
+
};
|
|
228
|
+
readonly 'metering/list-periods': {
|
|
229
|
+
readonly summary: "Closed periods, oldest first";
|
|
230
|
+
readonly permission: "metering:read";
|
|
231
|
+
readonly output: z.ZodObject<{
|
|
232
|
+
id: z.ZodString;
|
|
233
|
+
from: z.ZodString;
|
|
234
|
+
to: z.ZodString;
|
|
235
|
+
closedBy: z.ZodString;
|
|
236
|
+
closedAt: z.ZodString;
|
|
237
|
+
}, z.core.$strip>;
|
|
238
|
+
};
|
|
239
|
+
readonly 'metering/period-lines': {
|
|
240
|
+
readonly summary: "One period's frozen lines";
|
|
241
|
+
readonly permission: "metering:read";
|
|
242
|
+
readonly input: z.ZodObject<{
|
|
243
|
+
periodId: z.ZodString;
|
|
244
|
+
}, z.core.$strip>;
|
|
245
|
+
readonly output: z.ZodObject<{
|
|
246
|
+
meterKey: z.ZodString;
|
|
247
|
+
kind: z.ZodEnum<{
|
|
248
|
+
counter: "counter";
|
|
249
|
+
gauge: "gauge";
|
|
250
|
+
}>;
|
|
251
|
+
unit: z.ZodString;
|
|
252
|
+
qty: z.ZodString;
|
|
253
|
+
entryCount: z.ZodNumber;
|
|
254
|
+
}, z.core.$strip>;
|
|
255
|
+
};
|
|
256
|
+
};
|
|
257
|
+
//# sourceMappingURL=operations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operations.d.ts","sourceRoot":"","sources":["../src/operations.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,OAAO,EAA+B,CAAC,EAAE,MAAM,yBAAyB,CAAC;AAIzE,mEAAmE;AACnE,eAAO,MAAM,oBAAoB,YAC/B,eAAe,EACf,iBAAiB,EACjB,oBAAoB,EACpB,gBAAgB,CACR,CAAC;AAKX,uEAAuE;AACvE,eAAO,MAAM,KAAK;;;;;;;;;;iBAOhB,CAAC;AAEH,4DAA4D;AAC5D,eAAO,MAAM,UAAU;;;;;;;;;;;;;iBAUrB,CAAC;AAEH,4BAA4B;AAC5B,eAAO,MAAM,cAAc;;;;;;iBAMzB,CAAC;AAEH,mFAAmF;AACnF,eAAO,MAAM,UAAU;;;;;;;;;iBAMrB,CAAC;AAkBH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqF7B,CAAC"}
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The metering engine's declared operation surface (#865, #891's recipe applied
|
|
3
|
+
* to the last three packages that had none).
|
|
4
|
+
*
|
|
5
|
+
* ## Why this file exists now
|
|
6
|
+
*
|
|
7
|
+
* It used to not, and the cost was stated rather than hidden: this engine's
|
|
8
|
+
* node-only claim was a `nodeOnlySuite` tripwire — a grep of `index.ts` for a
|
|
9
|
+
* two-argument `ctx.check`. That proves an absence, never a behaviour, and it is
|
|
10
|
+
* lexical: a check assembled through a helper is invisible to it. A DECLARATION
|
|
11
|
+
* is exact. `planEntityCheckCoverage` reads these eight entries the same way the
|
|
12
|
+
* conformance kit does, so "this engine narrows nowhere" is a fact about the
|
|
13
|
+
* surface rather than about the text, and the day one of them narrows the
|
|
14
|
+
* assessment goes red.
|
|
15
|
+
*
|
|
16
|
+
* ## Every check is a node check, and that is the design
|
|
17
|
+
*
|
|
18
|
+
* Metering counts what a scope consumed. A meter is scope-level configuration,
|
|
19
|
+
* `record` is machine-driven ingest, and a period closes for the scope as a
|
|
20
|
+
* whole — none of the four keys has a per-entity reader. A principal entitled to
|
|
21
|
+
* see one meter's usage and not another's is a reporting concern in the vertical
|
|
22
|
+
* above, expressed by what it queries rather than by narrowing the engine's own
|
|
23
|
+
* checks. Note what would change that: an entry's `subject` is an opaque
|
|
24
|
+
* `EntityRef` into the vertical's own noun, so if a per-subject read is ever
|
|
25
|
+
* wanted it is the VERTICAL that owns the edge and the walk.
|
|
26
|
+
*
|
|
27
|
+
* ## Shapes are the PUBLISHED ones, not the rows
|
|
28
|
+
*
|
|
29
|
+
* The outputs here are the camelCase projections the in-scope functions return
|
|
30
|
+
* (`Meter`, `UsageEntry`, `MeteringPeriod`, `PeriodLine`), not the snake_case
|
|
31
|
+
* rows in `entities.ts`. Both exist on purpose: the registry describes what is
|
|
32
|
+
* STORED (which is what a migration journal is compared against), and these
|
|
33
|
+
* describe what a caller receives.
|
|
34
|
+
*
|
|
35
|
+
* No `http` — an engine owns no URL shape. A vertical binds these names to its
|
|
36
|
+
* own paths with `defineEngineRoutes`.
|
|
37
|
+
*/
|
|
38
|
+
import { defineOperations, entityRef, z } from '@substrat-run/contracts';
|
|
39
|
+
import { meteringEntities } from './entities.js';
|
|
40
|
+
import { isoInstantIn, signedDecimal } from './formats.js';
|
|
41
|
+
/** The keys these operations check. Mirrors `PERM` in index.ts. */
|
|
42
|
+
export const METERING_PERMISSIONS = [
|
|
43
|
+
'metering:read',
|
|
44
|
+
'metering:record',
|
|
45
|
+
'metering:configure',
|
|
46
|
+
'metering:close',
|
|
47
|
+
];
|
|
48
|
+
/** A quantity, always a decimal STRING — never a float (D-E, contracts' money rule). */
|
|
49
|
+
const qty = signedDecimal;
|
|
50
|
+
/** What `configureMeter`/`listMeters` return: the meter, projected. */
|
|
51
|
+
export const meter = z.object({
|
|
52
|
+
key: z.string(),
|
|
53
|
+
kind: z.enum(['counter', 'gauge']),
|
|
54
|
+
unit: z.string(),
|
|
55
|
+
description: z.string().nullable(),
|
|
56
|
+
active: z.boolean(),
|
|
57
|
+
createdAt: z.string(),
|
|
58
|
+
});
|
|
59
|
+
/** One observation in the append-only ledger, projected. */
|
|
60
|
+
export const usageEntry = z.object({
|
|
61
|
+
id: z.string(),
|
|
62
|
+
meterKey: z.string(),
|
|
63
|
+
qty,
|
|
64
|
+
subject: entityRef.nullable(),
|
|
65
|
+
occurredAt: z.string(),
|
|
66
|
+
dedupeKey: z.string(),
|
|
67
|
+
note: z.string().nullable(),
|
|
68
|
+
createdBy: z.string(),
|
|
69
|
+
createdAt: z.string(),
|
|
70
|
+
});
|
|
71
|
+
/** One close, projected. */
|
|
72
|
+
export const meteringPeriod = z.object({
|
|
73
|
+
id: z.string(),
|
|
74
|
+
from: z.string(),
|
|
75
|
+
to: z.string(),
|
|
76
|
+
closedBy: z.string(),
|
|
77
|
+
closedAt: z.string(),
|
|
78
|
+
});
|
|
79
|
+
/** One meter's frozen aggregate for a closed period. Unpriced, by design (D-E). */
|
|
80
|
+
export const periodLine = z.object({
|
|
81
|
+
meterKey: z.string(),
|
|
82
|
+
kind: z.enum(['counter', 'gauge']),
|
|
83
|
+
unit: z.string(),
|
|
84
|
+
qty,
|
|
85
|
+
entryCount: z.number(),
|
|
86
|
+
});
|
|
87
|
+
/**
|
|
88
|
+
* An instant as the operations accept one.
|
|
89
|
+
*
|
|
90
|
+
* The VALIDATING half of the storage schema, shared through `formats.ts` — the
|
|
91
|
+
* same strings, without the transform that normalises to millisecond precision.
|
|
92
|
+
* Non-transforming on purpose: a transforming schema at the door would hand the
|
|
93
|
+
* handler a value the in-scope function then re-parses, and a declared input
|
|
94
|
+
* describes what a caller may send rather than what will be stored.
|
|
95
|
+
*
|
|
96
|
+
* What it must NOT be is looser than the handler. It was `z.string().min(1)`,
|
|
97
|
+
* so `"not-a-date"` passed the boundary parse the host applies and was refused
|
|
98
|
+
* by `isoInstant.parse` inside — a contract saying a value is valid and a
|
|
99
|
+
* handler disagreeing after the guards ran.
|
|
100
|
+
*/
|
|
101
|
+
const instantIn = isoInstantIn;
|
|
102
|
+
export const meteringOperations = defineOperations(meteringEntities, METERING_PERMISSIONS)({
|
|
103
|
+
'metering/configure-meter': {
|
|
104
|
+
summary: 'Register a meter, or update its description and active flag',
|
|
105
|
+
permission: 'metering:configure',
|
|
106
|
+
input: z.object({
|
|
107
|
+
key: z.string().min(1),
|
|
108
|
+
kind: z.enum(['counter', 'gauge']),
|
|
109
|
+
unit: z.string().min(1),
|
|
110
|
+
description: z.string().optional(),
|
|
111
|
+
active: z.boolean().optional(),
|
|
112
|
+
}),
|
|
113
|
+
output: meter,
|
|
114
|
+
},
|
|
115
|
+
'metering/list-meters': {
|
|
116
|
+
summary: 'Every configured meter, by key',
|
|
117
|
+
permission: 'metering:read',
|
|
118
|
+
output: meter,
|
|
119
|
+
},
|
|
120
|
+
'metering/record': {
|
|
121
|
+
summary: 'Record one usage observation — idempotent per (meter, dedupeKey)',
|
|
122
|
+
permission: 'metering:record',
|
|
123
|
+
input: z.object({
|
|
124
|
+
meter: z.string().min(1),
|
|
125
|
+
/**
|
|
126
|
+
* Counters take signed deltas (a correction is a compensating entry, never
|
|
127
|
+
* an edit); gauges take non-negative level samples. The per-kind half is
|
|
128
|
+
* enforced by the handler, which knows the meter — a declared input cannot,
|
|
129
|
+
* and claiming otherwise here would be a schema that reads stricter than it
|
|
130
|
+
* is. The DECIMAL half is not per-kind and belongs here: `"-"` used to reach
|
|
131
|
+
* a handler that then refused it.
|
|
132
|
+
*/
|
|
133
|
+
qty: signedDecimal,
|
|
134
|
+
subject: entityRef.optional(),
|
|
135
|
+
occurredAt: instantIn.optional(),
|
|
136
|
+
dedupeKey: z.string().min(1),
|
|
137
|
+
note: z.string().optional(),
|
|
138
|
+
}),
|
|
139
|
+
// `deduped` is the fact a caller branches on: a replay is not an error, and a
|
|
140
|
+
// caller that cannot tell the two apart cannot report either honestly.
|
|
141
|
+
output: z.object({ entry: usageEntry, deduped: z.boolean() }),
|
|
142
|
+
},
|
|
143
|
+
'metering/total': {
|
|
144
|
+
summary: 'Aggregate one meter over [from, to)',
|
|
145
|
+
permission: 'metering:read',
|
|
146
|
+
input: z.object({ meter: z.string().min(1), from: instantIn, to: instantIn }),
|
|
147
|
+
// Null when the window holds nothing — distinct from a zero total, which a
|
|
148
|
+
// counter with compensating entries can legitimately produce.
|
|
149
|
+
output: z.object({ qty, entryCount: z.number() }).nullable(),
|
|
150
|
+
},
|
|
151
|
+
'metering/list-entries': {
|
|
152
|
+
summary: 'The ledger, filtered by meter, subject or window',
|
|
153
|
+
permission: 'metering:read',
|
|
154
|
+
input: z.object({
|
|
155
|
+
meter: z.string().min(1).optional(),
|
|
156
|
+
subject: entityRef.optional(),
|
|
157
|
+
from: instantIn.optional(),
|
|
158
|
+
to: instantIn.optional(),
|
|
159
|
+
}),
|
|
160
|
+
inputOptional: true,
|
|
161
|
+
output: usageEntry,
|
|
162
|
+
},
|
|
163
|
+
'metering/close-period': {
|
|
164
|
+
summary: 'Freeze [from, to) — aggregate every meter and advance the horizon',
|
|
165
|
+
permission: 'metering:close',
|
|
166
|
+
input: z.object({ from: instantIn, to: instantIn }),
|
|
167
|
+
output: z.object({ period: meteringPeriod, lines: z.array(periodLine) }),
|
|
168
|
+
},
|
|
169
|
+
'metering/list-periods': {
|
|
170
|
+
summary: 'Closed periods, oldest first',
|
|
171
|
+
permission: 'metering:read',
|
|
172
|
+
output: meteringPeriod,
|
|
173
|
+
},
|
|
174
|
+
'metering/period-lines': {
|
|
175
|
+
summary: "One period's frozen lines",
|
|
176
|
+
permission: 'metering:read',
|
|
177
|
+
input: z.object({ periodId: z.string().min(1) }),
|
|
178
|
+
output: periodLine,
|
|
179
|
+
},
|
|
180
|
+
});
|
|
181
|
+
//# sourceMappingURL=operations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operations.js","sourceRoot":"","sources":["../src/operations.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,CAAC,EAAE,MAAM,yBAAyB,CAAC;AACzE,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE3D,mEAAmE;AACnE,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,eAAe;IACf,iBAAiB;IACjB,oBAAoB;IACpB,gBAAgB;CACR,CAAC;AAEX,wFAAwF;AACxF,MAAM,GAAG,GAAG,aAAa,CAAC;AAE1B,uEAAuE;AACvE,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,CAAC,MAAM,CAAC;IAC5B,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE;IACf,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IAClC,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;IAChB,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAClC,MAAM,EAAE,CAAC,CAAC,OAAO,EAAE;IACnB,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE;CACtB,CAAC,CAAC;AAEH,4DAA4D;AAC5D,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,CAAC,MAAM,CAAC;IACjC,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE;IACd,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE;IACpB,GAAG;IACH,OAAO,EAAE,SA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,MAAM,EAAE,UAAU;KACnB;CACF,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@substrat-run/engine-metering",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Substrat engine: billable usage — an append-only, idempotent meter ledger (counters and gauges) whose closed periods are frozen billing evidence",
|
|
5
5
|
"license": "AGPL-3.0-only",
|
|
6
6
|
"repository": {
|
|
@@ -25,15 +25,15 @@
|
|
|
25
25
|
"access": "public"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@substrat-run/contracts": "^0.
|
|
29
|
-
"@substrat-run/kernel": "^0.
|
|
28
|
+
"@substrat-run/contracts": "^0.90.0",
|
|
29
|
+
"@substrat-run/kernel": "^0.90.0"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"typescript": "^7.0.0",
|
|
33
33
|
"vitest": "^3.2.7",
|
|
34
34
|
"zod": "^4.4.3",
|
|
35
|
-
"@substrat-run/
|
|
36
|
-
"@substrat-run/
|
|
35
|
+
"@substrat-run/contract-tests": "^0.90.0",
|
|
36
|
+
"@substrat-run/engine-test-kit": "^0.3.17"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
39
|
"zod": "^4.4.0"
|