@stratum-hq/core 1.5.0 → 1.5.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 -8
- package/dist/types/usage.d.ts +1 -1
- package/dist/types/usage.js +1 -1
- package/dist/utils/ancestry.d.ts +1 -1
- package/dist/utils/ancestry.js +1 -1
- package/package.json +6 -3
package/README.md
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# @stratum-hq/core
|
|
2
2
|
|
|
3
|
-
Shared foundation for all [Stratum](https://github.com/stratum-hq/Stratum) packages
|
|
3
|
+
Shared foundation for all [Stratum](https://github.com/stratum-hq/Stratum) packages: TypeScript types, Zod validation schemas, error classes, utility functions, and constants. Every other Stratum package depends on it.
|
|
4
|
+
|
|
5
|
+
Read the documentation at [docs.stratum-hq.org/packages/core](https://docs.stratum-hq.org/packages/core/).
|
|
4
6
|
|
|
5
7
|
## Installation
|
|
6
8
|
|
|
@@ -27,7 +29,7 @@ import {
|
|
|
27
29
|
IsolationStrategy.SHARED_RLS; // "SHARED_RLS"
|
|
28
30
|
PermissionMode.LOCKED; // "LOCKED"
|
|
29
31
|
|
|
30
|
-
// Zod schemas
|
|
32
|
+
// Zod schemas: validate untrusted input
|
|
31
33
|
SlugSchema.parse("acme_corp"); // passes
|
|
32
34
|
SlugSchema.parse("INVALID"); // throws ZodError
|
|
33
35
|
|
|
@@ -44,12 +46,12 @@ try {
|
|
|
44
46
|
|
|
45
47
|
## What's Exported
|
|
46
48
|
|
|
47
|
-
- **Types
|
|
48
|
-
- **Enums
|
|
49
|
-
- **Zod schemas
|
|
50
|
-
- **Ancestry utilities
|
|
51
|
-
- **Errors
|
|
52
|
-
- **Constants
|
|
49
|
+
- **Types**: `TenantNode`, `TenantContext`, `ResolvedConfigEntry`, `ResolvedPermission`, `CreateTenantInput`, `SetConfigInput`, `AuditEntry`, `ConsentRecord`, `Region`, `AbacPolicy`, and more.
|
|
50
|
+
- **Enums**: `IsolationStrategy` (`SHARED_RLS`, `SCHEMA_PER_TENANT`, `DB_PER_TENANT`), `PermissionMode` (`LOCKED`, `INHERITED`, `DELEGATED`), `RevocationMode` (`CASCADE`, `SOFT`, `PERMANENT`), `TenantStatus`.
|
|
51
|
+
- **Zod schemas**: `SlugSchema`, `UUIDSchema`, `PaginationSchema`, `CreateTenantInputSchema`, `SetConfigInputSchema`, `CreatePermissionInputSchema`, `AuditLogQuerySchema`, and their input types.
|
|
52
|
+
- **Ancestry utilities**: `buildAncestryPath`, `parseAncestryPath`, `getDepth`, `isAncestorOf`, `isDescendantOf`, `getAncestorIds`.
|
|
53
|
+
- **Errors**: `StratumError` plus `TenantNotFoundError`, `ConfigLockedError`, `PermissionRevocationDeniedError`, `IsolationViolationError`, `UnauthorizedError`, `ForbiddenError`, and others.
|
|
54
|
+
- **Constants**: `MAX_SLUG_LENGTH` (63), `DEFAULT_CACHE_TTL_MS`, `DEFAULT_PAGE_SIZE`, `MAX_PAGE_SIZE`, `API_KEY_PREFIX`, `TENANT_HEADER`.
|
|
53
55
|
|
|
54
56
|
## Links
|
|
55
57
|
|
package/dist/types/usage.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { z } from "zod";
|
|
|
3
3
|
* Input to record a single usage event for a tenant.
|
|
4
4
|
*
|
|
5
5
|
* `quantity` defaults to 1 (one countable unit) and must be a non-negative
|
|
6
|
-
* integer
|
|
6
|
+
* integer: metering counts up; credits / adjustments are out of scope.
|
|
7
7
|
* `occurred_at` is when the usage happened (ISO 8601); it defaults to insert
|
|
8
8
|
* time and is the timestamp aggregation windows filter on, so a back-dated
|
|
9
9
|
* import still lands in the right billing window. `idempotency_key`, when
|
package/dist/types/usage.js
CHANGED
|
@@ -7,7 +7,7 @@ const timestamptz_js_1 = require("../utils/timestamptz.js");
|
|
|
7
7
|
* Input to record a single usage event for a tenant.
|
|
8
8
|
*
|
|
9
9
|
* `quantity` defaults to 1 (one countable unit) and must be a non-negative
|
|
10
|
-
* integer
|
|
10
|
+
* integer: metering counts up; credits / adjustments are out of scope.
|
|
11
11
|
* `occurred_at` is when the usage happened (ISO 8601); it defaults to insert
|
|
12
12
|
* time and is the timestamp aggregation windows filter on, so a back-dated
|
|
13
13
|
* import still lands in the right billing window. `idempotency_key`, when
|
package/dist/utils/ancestry.d.ts
CHANGED
|
@@ -50,7 +50,7 @@ export declare function appendToPath(parentPath: string, childId: string): strin
|
|
|
50
50
|
*/
|
|
51
51
|
export declare function getAncestorIds(path: string): string[];
|
|
52
52
|
/**
|
|
53
|
-
* Get the last ID in an ancestry path
|
|
53
|
+
* Get the last ID in an ancestry path: the tenant's direct parent
|
|
54
54
|
* (ancestry paths exclude self). Returns null for a root tenant ("/").
|
|
55
55
|
*/
|
|
56
56
|
export declare function getSelfId(path: string): string | null;
|
package/dist/utils/ancestry.js
CHANGED
|
@@ -92,7 +92,7 @@ function getAncestorIds(path) {
|
|
|
92
92
|
return parseAncestryPath(path);
|
|
93
93
|
}
|
|
94
94
|
/**
|
|
95
|
-
* Get the last ID in an ancestry path
|
|
95
|
+
* Get the last ID in an ancestry path: the tenant's direct parent
|
|
96
96
|
* (ancestry paths exclude self). Returns null for a root tenant ("/").
|
|
97
97
|
*/
|
|
98
98
|
function getSelfId(path) {
|
package/package.json
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stratum-hq/core",
|
|
3
|
-
"version": "1.5.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "1.5.1",
|
|
4
|
+
"description": "Shared types, Zod schemas, and errors for the Stratum multi-tenancy packages",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"multi-tenancy",
|
|
7
|
+
"multitenancy",
|
|
7
8
|
"multi-tenant",
|
|
8
9
|
"saas",
|
|
9
10
|
"tenant",
|
|
11
|
+
"tenant-isolation",
|
|
12
|
+
"zod",
|
|
10
13
|
"typescript",
|
|
11
14
|
"validation",
|
|
12
15
|
"schemas",
|
|
@@ -45,7 +48,7 @@
|
|
|
45
48
|
},
|
|
46
49
|
"license": "MIT",
|
|
47
50
|
"author": "Christian Crank",
|
|
48
|
-
"homepage": "https://
|
|
51
|
+
"homepage": "https://docs.stratum-hq.org/packages/core/",
|
|
49
52
|
"bugs": "https://github.com/stratum-hq/Stratum/issues",
|
|
50
53
|
"engines": {
|
|
51
54
|
"node": ">=20.0.0"
|