@stratum-hq/core 0.1.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.
Files changed (81) hide show
  1. package/dist/__tests__/ancestry.test.d.ts +2 -0
  2. package/dist/__tests__/ancestry.test.d.ts.map +1 -0
  3. package/dist/__tests__/ancestry.test.js +132 -0
  4. package/dist/__tests__/ancestry.test.js.map +1 -0
  5. package/dist/__tests__/config-types.test.d.ts +2 -0
  6. package/dist/__tests__/config-types.test.d.ts.map +1 -0
  7. package/dist/__tests__/config-types.test.js +143 -0
  8. package/dist/__tests__/config-types.test.js.map +1 -0
  9. package/dist/__tests__/errors.test.d.ts +2 -0
  10. package/dist/__tests__/errors.test.d.ts.map +1 -0
  11. package/dist/__tests__/errors.test.js +113 -0
  12. package/dist/__tests__/errors.test.js.map +1 -0
  13. package/dist/__tests__/isolation.test.d.ts +2 -0
  14. package/dist/__tests__/isolation.test.d.ts.map +1 -0
  15. package/dist/__tests__/isolation.test.js +34 -0
  16. package/dist/__tests__/isolation.test.js.map +1 -0
  17. package/dist/__tests__/validation.test.d.ts +2 -0
  18. package/dist/__tests__/validation.test.d.ts.map +1 -0
  19. package/dist/__tests__/validation.test.js +100 -0
  20. package/dist/__tests__/validation.test.js.map +1 -0
  21. package/dist/__tests__/webhook.test.d.ts +2 -0
  22. package/dist/__tests__/webhook.test.d.ts.map +1 -0
  23. package/dist/__tests__/webhook.test.js +165 -0
  24. package/dist/__tests__/webhook.test.js.map +1 -0
  25. package/dist/constants.d.ts +9 -0
  26. package/dist/constants.d.ts.map +1 -0
  27. package/dist/constants.js +12 -0
  28. package/dist/constants.js.map +1 -0
  29. package/dist/index.d.ts +14 -0
  30. package/dist/index.d.ts.map +1 -0
  31. package/dist/index.js +102 -0
  32. package/dist/index.js.map +1 -0
  33. package/dist/types/api-key.d.ts +5 -0
  34. package/dist/types/api-key.d.ts.map +1 -0
  35. package/dist/types/api-key.js +7 -0
  36. package/dist/types/api-key.js.map +1 -0
  37. package/dist/types/audit.d.ts +81 -0
  38. package/dist/types/audit.d.ts.map +1 -0
  39. package/dist/types/audit.js +30 -0
  40. package/dist/types/audit.js.map +1 -0
  41. package/dist/types/config.d.ts +93 -0
  42. package/dist/types/config.d.ts.map +1 -0
  43. package/dist/types/config.js +22 -0
  44. package/dist/types/config.js.map +1 -0
  45. package/dist/types/consent.d.ts +63 -0
  46. package/dist/types/consent.d.ts.map +1 -0
  47. package/dist/types/consent.js +30 -0
  48. package/dist/types/consent.js.map +1 -0
  49. package/dist/types/isolation.d.ts +9 -0
  50. package/dist/types/isolation.d.ts.map +1 -0
  51. package/dist/types/isolation.js +20 -0
  52. package/dist/types/isolation.js.map +1 -0
  53. package/dist/types/permission.d.ts +101 -0
  54. package/dist/types/permission.d.ts.map +1 -0
  55. package/dist/types/permission.js +41 -0
  56. package/dist/types/permission.js.map +1 -0
  57. package/dist/types/region.d.ts +90 -0
  58. package/dist/types/region.d.ts.map +1 -0
  59. package/dist/types/region.js +39 -0
  60. package/dist/types/region.js.map +1 -0
  61. package/dist/types/tenant.d.ts +148 -0
  62. package/dist/types/tenant.d.ts.map +1 -0
  63. package/dist/types/tenant.js +55 -0
  64. package/dist/types/tenant.js.map +1 -0
  65. package/dist/types/webhook.d.ts +181 -0
  66. package/dist/types/webhook.d.ts.map +1 -0
  67. package/dist/types/webhook.js +65 -0
  68. package/dist/types/webhook.js.map +1 -0
  69. package/dist/utils/ancestry.d.ts +53 -0
  70. package/dist/utils/ancestry.d.ts.map +1 -0
  71. package/dist/utils/ancestry.js +100 -0
  72. package/dist/utils/ancestry.js.map +1 -0
  73. package/dist/utils/errors.d.ts +88 -0
  74. package/dist/utils/errors.d.ts.map +1 -0
  75. package/dist/utils/errors.js +173 -0
  76. package/dist/utils/errors.js.map +1 -0
  77. package/dist/utils/validation.d.ts +21 -0
  78. package/dist/utils/validation.d.ts.map +1 -0
  79. package/dist/utils/validation.js +19 -0
  80. package/dist/utils/validation.js.map +1 -0
  81. package/package.json +35 -0
@@ -0,0 +1,181 @@
1
+ import { z } from "zod";
2
+ export declare const TenantEvent: {
3
+ readonly TENANT_CREATED: "tenant.created";
4
+ readonly TENANT_UPDATED: "tenant.updated";
5
+ readonly TENANT_DELETED: "tenant.deleted";
6
+ readonly TENANT_MOVED: "tenant.moved";
7
+ readonly CONFIG_UPDATED: "config.updated";
8
+ readonly CONFIG_DELETED: "config.deleted";
9
+ readonly PERMISSION_CREATED: "permission.created";
10
+ readonly PERMISSION_UPDATED: "permission.updated";
11
+ readonly PERMISSION_DELETED: "permission.deleted";
12
+ };
13
+ export type TenantEvent = (typeof TenantEvent)[keyof typeof TenantEvent];
14
+ export declare const WebhookSchema: z.ZodObject<{
15
+ id: z.ZodString;
16
+ tenant_id: z.ZodNullable<z.ZodString>;
17
+ url: z.ZodString;
18
+ secret_hash: z.ZodString;
19
+ events: z.ZodArray<z.ZodString, "many">;
20
+ active: z.ZodDefault<z.ZodBoolean>;
21
+ description: z.ZodOptional<z.ZodString>;
22
+ created_at: z.ZodString;
23
+ updated_at: z.ZodString;
24
+ }, "strip", z.ZodTypeAny, {
25
+ id: string;
26
+ tenant_id: string | null;
27
+ created_at: string;
28
+ updated_at: string;
29
+ url: string;
30
+ secret_hash: string;
31
+ events: string[];
32
+ active: boolean;
33
+ description?: string | undefined;
34
+ }, {
35
+ id: string;
36
+ tenant_id: string | null;
37
+ created_at: string;
38
+ updated_at: string;
39
+ url: string;
40
+ secret_hash: string;
41
+ events: string[];
42
+ active?: boolean | undefined;
43
+ description?: string | undefined;
44
+ }>;
45
+ export type Webhook = z.infer<typeof WebhookSchema>;
46
+ export declare const CreateWebhookInputSchema: z.ZodObject<{
47
+ tenant_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
48
+ url: z.ZodString;
49
+ secret: z.ZodString;
50
+ events: z.ZodArray<z.ZodNativeEnum<{
51
+ readonly TENANT_CREATED: "tenant.created";
52
+ readonly TENANT_UPDATED: "tenant.updated";
53
+ readonly TENANT_DELETED: "tenant.deleted";
54
+ readonly TENANT_MOVED: "tenant.moved";
55
+ readonly CONFIG_UPDATED: "config.updated";
56
+ readonly CONFIG_DELETED: "config.deleted";
57
+ readonly PERMISSION_CREATED: "permission.created";
58
+ readonly PERMISSION_UPDATED: "permission.updated";
59
+ readonly PERMISSION_DELETED: "permission.deleted";
60
+ }>, "many">;
61
+ description: z.ZodOptional<z.ZodString>;
62
+ }, "strip", z.ZodTypeAny, {
63
+ tenant_id: string | null;
64
+ url: string;
65
+ events: ("tenant.created" | "tenant.updated" | "tenant.deleted" | "tenant.moved" | "config.updated" | "config.deleted" | "permission.created" | "permission.updated" | "permission.deleted")[];
66
+ secret: string;
67
+ description?: string | undefined;
68
+ }, {
69
+ url: string;
70
+ events: ("tenant.created" | "tenant.updated" | "tenant.deleted" | "tenant.moved" | "config.updated" | "config.deleted" | "permission.created" | "permission.updated" | "permission.deleted")[];
71
+ secret: string;
72
+ tenant_id?: string | null | undefined;
73
+ description?: string | undefined;
74
+ }>;
75
+ export type CreateWebhookInput = z.infer<typeof CreateWebhookInputSchema>;
76
+ export declare const UpdateWebhookInputSchema: z.ZodObject<{
77
+ url: z.ZodOptional<z.ZodString>;
78
+ secret: z.ZodOptional<z.ZodString>;
79
+ events: z.ZodOptional<z.ZodArray<z.ZodNativeEnum<{
80
+ readonly TENANT_CREATED: "tenant.created";
81
+ readonly TENANT_UPDATED: "tenant.updated";
82
+ readonly TENANT_DELETED: "tenant.deleted";
83
+ readonly TENANT_MOVED: "tenant.moved";
84
+ readonly CONFIG_UPDATED: "config.updated";
85
+ readonly CONFIG_DELETED: "config.deleted";
86
+ readonly PERMISSION_CREATED: "permission.created";
87
+ readonly PERMISSION_UPDATED: "permission.updated";
88
+ readonly PERMISSION_DELETED: "permission.deleted";
89
+ }>, "many">>;
90
+ active: z.ZodOptional<z.ZodBoolean>;
91
+ description: z.ZodOptional<z.ZodString>;
92
+ }, "strip", z.ZodTypeAny, {
93
+ url?: string | undefined;
94
+ events?: ("tenant.created" | "tenant.updated" | "tenant.deleted" | "tenant.moved" | "config.updated" | "config.deleted" | "permission.created" | "permission.updated" | "permission.deleted")[] | undefined;
95
+ active?: boolean | undefined;
96
+ description?: string | undefined;
97
+ secret?: string | undefined;
98
+ }, {
99
+ url?: string | undefined;
100
+ events?: ("tenant.created" | "tenant.updated" | "tenant.deleted" | "tenant.moved" | "config.updated" | "config.deleted" | "permission.created" | "permission.updated" | "permission.deleted")[] | undefined;
101
+ active?: boolean | undefined;
102
+ description?: string | undefined;
103
+ secret?: string | undefined;
104
+ }>;
105
+ export type UpdateWebhookInput = z.infer<typeof UpdateWebhookInputSchema>;
106
+ export declare const WebhookEventSchema: z.ZodObject<{
107
+ id: z.ZodString;
108
+ type: z.ZodNativeEnum<{
109
+ readonly TENANT_CREATED: "tenant.created";
110
+ readonly TENANT_UPDATED: "tenant.updated";
111
+ readonly TENANT_DELETED: "tenant.deleted";
112
+ readonly TENANT_MOVED: "tenant.moved";
113
+ readonly CONFIG_UPDATED: "config.updated";
114
+ readonly CONFIG_DELETED: "config.deleted";
115
+ readonly PERMISSION_CREATED: "permission.created";
116
+ readonly PERMISSION_UPDATED: "permission.updated";
117
+ readonly PERMISSION_DELETED: "permission.deleted";
118
+ }>;
119
+ tenant_id: z.ZodString;
120
+ data: z.ZodRecord<z.ZodString, z.ZodUnknown>;
121
+ created_at: z.ZodString;
122
+ }, "strip", z.ZodTypeAny, {
123
+ id: string;
124
+ tenant_id: string;
125
+ type: "tenant.created" | "tenant.updated" | "tenant.deleted" | "tenant.moved" | "config.updated" | "config.deleted" | "permission.created" | "permission.updated" | "permission.deleted";
126
+ created_at: string;
127
+ data: Record<string, unknown>;
128
+ }, {
129
+ id: string;
130
+ tenant_id: string;
131
+ type: "tenant.created" | "tenant.updated" | "tenant.deleted" | "tenant.moved" | "config.updated" | "config.deleted" | "permission.created" | "permission.updated" | "permission.deleted";
132
+ created_at: string;
133
+ data: Record<string, unknown>;
134
+ }>;
135
+ export type WebhookEvent = z.infer<typeof WebhookEventSchema>;
136
+ export declare const WebhookDeliveryStatus: {
137
+ readonly PENDING: "pending";
138
+ readonly SUCCESS: "success";
139
+ readonly FAILED: "failed";
140
+ };
141
+ export type WebhookDeliveryStatus = (typeof WebhookDeliveryStatus)[keyof typeof WebhookDeliveryStatus];
142
+ export declare const WebhookDeliverySchema: z.ZodObject<{
143
+ id: z.ZodString;
144
+ webhook_id: z.ZodString;
145
+ event_id: z.ZodString;
146
+ status: z.ZodNativeEnum<{
147
+ readonly PENDING: "pending";
148
+ readonly SUCCESS: "success";
149
+ readonly FAILED: "failed";
150
+ }>;
151
+ attempts: z.ZodNumber;
152
+ next_retry_at: z.ZodNullable<z.ZodString>;
153
+ last_error: z.ZodNullable<z.ZodString>;
154
+ response_code: z.ZodNullable<z.ZodNumber>;
155
+ created_at: z.ZodString;
156
+ completed_at: z.ZodNullable<z.ZodString>;
157
+ }, "strip", z.ZodTypeAny, {
158
+ id: string;
159
+ status: "pending" | "success" | "failed";
160
+ created_at: string;
161
+ webhook_id: string;
162
+ event_id: string;
163
+ attempts: number;
164
+ next_retry_at: string | null;
165
+ last_error: string | null;
166
+ response_code: number | null;
167
+ completed_at: string | null;
168
+ }, {
169
+ id: string;
170
+ status: "pending" | "success" | "failed";
171
+ created_at: string;
172
+ webhook_id: string;
173
+ event_id: string;
174
+ attempts: number;
175
+ next_retry_at: string | null;
176
+ last_error: string | null;
177
+ response_code: number | null;
178
+ completed_at: string | null;
179
+ }>;
180
+ export type WebhookDelivery = z.infer<typeof WebhookDeliverySchema>;
181
+ //# sourceMappingURL=webhook.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webhook.d.ts","sourceRoot":"","sources":["../../src/types/webhook.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,WAAW;;;;;;;;;;CAUd,CAAC;AACX,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,WAAW,CAAC,CAAC,MAAM,OAAO,WAAW,CAAC,CAAC;AAEzE,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAUxB,CAAC;AACH,MAAM,MAAM,OAAO,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC;AAEpD,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAMnC,CAAC;AACH,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAE1E,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAMnC,CAAC;AACH,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAE1E,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAM7B,CAAC;AACH,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAE9D,eAAO,MAAM,qBAAqB;;;;CAIxB,CAAC;AACX,MAAM,MAAM,qBAAqB,GAC/B,CAAC,OAAO,qBAAqB,CAAC,CAAC,MAAM,OAAO,qBAAqB,CAAC,CAAC;AAErE,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAWhC,CAAC;AACH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC"}
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.WebhookDeliverySchema = exports.WebhookDeliveryStatus = exports.WebhookEventSchema = exports.UpdateWebhookInputSchema = exports.CreateWebhookInputSchema = exports.WebhookSchema = exports.TenantEvent = void 0;
4
+ const zod_1 = require("zod");
5
+ exports.TenantEvent = {
6
+ TENANT_CREATED: "tenant.created",
7
+ TENANT_UPDATED: "tenant.updated",
8
+ TENANT_DELETED: "tenant.deleted",
9
+ TENANT_MOVED: "tenant.moved",
10
+ CONFIG_UPDATED: "config.updated",
11
+ CONFIG_DELETED: "config.deleted",
12
+ PERMISSION_CREATED: "permission.created",
13
+ PERMISSION_UPDATED: "permission.updated",
14
+ PERMISSION_DELETED: "permission.deleted",
15
+ };
16
+ exports.WebhookSchema = zod_1.z.object({
17
+ id: zod_1.z.string().uuid(),
18
+ tenant_id: zod_1.z.string().uuid().nullable(),
19
+ url: zod_1.z.string().url(),
20
+ secret_hash: zod_1.z.string(),
21
+ events: zod_1.z.array(zod_1.z.string()),
22
+ active: zod_1.z.boolean().default(true),
23
+ description: zod_1.z.string().max(255).optional(),
24
+ created_at: zod_1.z.string().datetime(),
25
+ updated_at: zod_1.z.string().datetime(),
26
+ });
27
+ exports.CreateWebhookInputSchema = zod_1.z.object({
28
+ tenant_id: zod_1.z.string().uuid().nullable().default(null),
29
+ url: zod_1.z.string().url(),
30
+ secret: zod_1.z.string().min(16).max(255),
31
+ events: zod_1.z.array(zod_1.z.nativeEnum(exports.TenantEvent)).min(1),
32
+ description: zod_1.z.string().max(255).optional(),
33
+ });
34
+ exports.UpdateWebhookInputSchema = zod_1.z.object({
35
+ url: zod_1.z.string().url().optional(),
36
+ secret: zod_1.z.string().min(16).max(255).optional(),
37
+ events: zod_1.z.array(zod_1.z.nativeEnum(exports.TenantEvent)).min(1).optional(),
38
+ active: zod_1.z.boolean().optional(),
39
+ description: zod_1.z.string().max(255).optional(),
40
+ });
41
+ exports.WebhookEventSchema = zod_1.z.object({
42
+ id: zod_1.z.string().uuid(),
43
+ type: zod_1.z.nativeEnum(exports.TenantEvent),
44
+ tenant_id: zod_1.z.string().uuid(),
45
+ data: zod_1.z.record(zod_1.z.unknown()),
46
+ created_at: zod_1.z.string().datetime(),
47
+ });
48
+ exports.WebhookDeliveryStatus = {
49
+ PENDING: "pending",
50
+ SUCCESS: "success",
51
+ FAILED: "failed",
52
+ };
53
+ exports.WebhookDeliverySchema = zod_1.z.object({
54
+ id: zod_1.z.string().uuid(),
55
+ webhook_id: zod_1.z.string().uuid(),
56
+ event_id: zod_1.z.string().uuid(),
57
+ status: zod_1.z.nativeEnum(exports.WebhookDeliveryStatus),
58
+ attempts: zod_1.z.number().int().min(0),
59
+ next_retry_at: zod_1.z.string().datetime().nullable(),
60
+ last_error: zod_1.z.string().nullable(),
61
+ response_code: zod_1.z.number().int().nullable(),
62
+ created_at: zod_1.z.string().datetime(),
63
+ completed_at: zod_1.z.string().datetime().nullable(),
64
+ });
65
+ //# sourceMappingURL=webhook.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webhook.js","sourceRoot":"","sources":["../../src/types/webhook.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AAEX,QAAA,WAAW,GAAG;IACzB,cAAc,EAAE,gBAAgB;IAChC,cAAc,EAAE,gBAAgB;IAChC,cAAc,EAAE,gBAAgB;IAChC,YAAY,EAAE,cAAc;IAC5B,cAAc,EAAE,gBAAgB;IAChC,cAAc,EAAE,gBAAgB;IAChC,kBAAkB,EAAE,oBAAoB;IACxC,kBAAkB,EAAE,oBAAoB;IACxC,kBAAkB,EAAE,oBAAoB;CAChC,CAAC;AAGE,QAAA,aAAa,GAAG,OAAC,CAAC,MAAM,CAAC;IACpC,EAAE,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE;IACrB,SAAS,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,QAAQ,EAAE;IACvC,GAAG,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE;IACrB,WAAW,EAAE,OAAC,CAAC,MAAM,EAAE;IACvB,MAAM,EAAE,OAAC,CAAC,KAAK,CAAC,OAAC,CAAC,MAAM,EAAE,CAAC;IAC3B,MAAM,EAAE,OAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC;IACjC,WAAW,EAAE,OAAC,CAAC,MAAM,EAAE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AE;IACjC,YAAY,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;CAC/C,CAAC,CAAC"}
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Ancestry path utilities for materialized path pattern.
3
+ * Format: "/uuid1/uuid2/uuid3" (leading slash, UUID segments)
4
+ */
5
+ /**
6
+ * Parse an ancestry path into an array of IDs.
7
+ * parseAncestryPath("/a/b/c") => ["a", "b", "c"]
8
+ */
9
+ export declare function parseAncestryPath(path: string): string[];
10
+ /**
11
+ * Build an ancestry path from an array of IDs.
12
+ * buildAncestryPath(["a", "b", "c"]) => "/a/b/c"
13
+ */
14
+ export declare function buildAncestryPath(ids: string[]): string;
15
+ /**
16
+ * Get the depth (number of segments) of an ancestry path.
17
+ * getDepth("/a/b/c") => 3
18
+ */
19
+ export declare function getDepth(path: string): number;
20
+ /**
21
+ * Check if ancestorPath is an ancestor of descendantPath.
22
+ * isAncestorOf("/a/b", "/a/b/c") => true
23
+ * isAncestorOf("/a/b/c", "/a/b") => false
24
+ * isAncestorOf("/a/b", "/a/b") => false (not ancestor of self)
25
+ */
26
+ export declare function isAncestorOf(ancestorPath: string, descendantPath: string): boolean;
27
+ /**
28
+ * Check if a path is a descendant of another path.
29
+ */
30
+ export declare function isDescendantOf(descendantPath: string, ancestorPath: string): boolean;
31
+ /**
32
+ * Get the parent path from an ancestry path.
33
+ * getParentPath("/a/b/c") => "/a/b"
34
+ * getParentPath("/a") => "/"
35
+ * getParentPath("/") => null
36
+ */
37
+ export declare function getParentPath(path: string): string | null;
38
+ /**
39
+ * Append a child ID to a parent ancestry path.
40
+ * appendToPath("/a/b", "c") => "/a/b/c"
41
+ */
42
+ export declare function appendToPath(parentPath: string, childId: string): string;
43
+ /**
44
+ * Get all ancestor IDs from an ancestry path (excluding self).
45
+ * getAncestorIds("/a/b/c") => ["a", "b"] (excludes "c")
46
+ */
47
+ export declare function getAncestorIds(path: string): string[];
48
+ /**
49
+ * Get the leaf (self) ID from an ancestry path.
50
+ * getSelfId("/a/b/c") => "c"
51
+ */
52
+ export declare function getSelfId(path: string): string | null;
53
+ //# sourceMappingURL=ancestry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ancestry.d.ts","sourceRoot":"","sources":["../../src/utils/ancestry.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAGxD;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,MAAM,CAGvD;AAED;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE7C;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAC1B,YAAY,EAAE,MAAM,EACpB,cAAc,EAAE,MAAM,GACrB,OAAO,CAMT;AAED;;GAEG;AACH,wBAAgB,cAAc,CAC5B,cAAc,EAAE,MAAM,EACtB,YAAY,EAAE,MAAM,GACnB,OAAO,CAET;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAKzD;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAGxE;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAGrD;AAED;;;GAGG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAGrD"}
@@ -0,0 +1,100 @@
1
+ "use strict";
2
+ /**
3
+ * Ancestry path utilities for materialized path pattern.
4
+ * Format: "/uuid1/uuid2/uuid3" (leading slash, UUID segments)
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.getSelfId = exports.getAncestorIds = exports.appendToPath = exports.getParentPath = exports.isDescendantOf = exports.isAncestorOf = exports.getDepth = exports.buildAncestryPath = exports.parseAncestryPath = void 0;
8
+ /**
9
+ * Parse an ancestry path into an array of IDs.
10
+ * parseAncestryPath("/a/b/c") => ["a", "b", "c"]
11
+ */
12
+ function parseAncestryPath(path) {
13
+ if (!path || path === "/")
14
+ return [];
15
+ return path.split("/").filter(Boolean);
16
+ }
17
+ exports.parseAncestryPath = parseAncestryPath;
18
+ /**
19
+ * Build an ancestry path from an array of IDs.
20
+ * buildAncestryPath(["a", "b", "c"]) => "/a/b/c"
21
+ */
22
+ function buildAncestryPath(ids) {
23
+ if (ids.length === 0)
24
+ return "/";
25
+ return "/" + ids.join("/");
26
+ }
27
+ exports.buildAncestryPath = buildAncestryPath;
28
+ /**
29
+ * Get the depth (number of segments) of an ancestry path.
30
+ * getDepth("/a/b/c") => 3
31
+ */
32
+ function getDepth(path) {
33
+ return parseAncestryPath(path).length;
34
+ }
35
+ exports.getDepth = getDepth;
36
+ /**
37
+ * Check if ancestorPath is an ancestor of descendantPath.
38
+ * isAncestorOf("/a/b", "/a/b/c") => true
39
+ * isAncestorOf("/a/b/c", "/a/b") => false
40
+ * isAncestorOf("/a/b", "/a/b") => false (not ancestor of self)
41
+ */
42
+ function isAncestorOf(ancestorPath, descendantPath) {
43
+ if (ancestorPath === descendantPath)
44
+ return false;
45
+ const normalizedAncestor = ancestorPath.endsWith("/")
46
+ ? ancestorPath
47
+ : ancestorPath + "/";
48
+ return descendantPath.startsWith(normalizedAncestor);
49
+ }
50
+ exports.isAncestorOf = isAncestorOf;
51
+ /**
52
+ * Check if a path is a descendant of another path.
53
+ */
54
+ function isDescendantOf(descendantPath, ancestorPath) {
55
+ return isAncestorOf(ancestorPath, descendantPath);
56
+ }
57
+ exports.isDescendantOf = isDescendantOf;
58
+ /**
59
+ * Get the parent path from an ancestry path.
60
+ * getParentPath("/a/b/c") => "/a/b"
61
+ * getParentPath("/a") => "/"
62
+ * getParentPath("/") => null
63
+ */
64
+ function getParentPath(path) {
65
+ const ids = parseAncestryPath(path);
66
+ if (ids.length === 0)
67
+ return null;
68
+ if (ids.length === 1)
69
+ return "/";
70
+ return buildAncestryPath(ids.slice(0, -1));
71
+ }
72
+ exports.getParentPath = getParentPath;
73
+ /**
74
+ * Append a child ID to a parent ancestry path.
75
+ * appendToPath("/a/b", "c") => "/a/b/c"
76
+ */
77
+ function appendToPath(parentPath, childId) {
78
+ const ids = parseAncestryPath(parentPath);
79
+ return buildAncestryPath([...ids, childId]);
80
+ }
81
+ exports.appendToPath = appendToPath;
82
+ /**
83
+ * Get all ancestor IDs from an ancestry path (excluding self).
84
+ * getAncestorIds("/a/b/c") => ["a", "b"] (excludes "c")
85
+ */
86
+ function getAncestorIds(path) {
87
+ const ids = parseAncestryPath(path);
88
+ return ids.slice(0, -1);
89
+ }
90
+ exports.getAncestorIds = getAncestorIds;
91
+ /**
92
+ * Get the leaf (self) ID from an ancestry path.
93
+ * getSelfId("/a/b/c") => "c"
94
+ */
95
+ function getSelfId(path) {
96
+ const ids = parseAncestryPath(path);
97
+ return ids.length > 0 ? ids[ids.length - 1] : null;
98
+ }
99
+ exports.getSelfId = getSelfId;
100
+ //# sourceMappingURL=ancestry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ancestry.js","sourceRoot":"","sources":["../../src/utils/ancestry.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH;;;GAGG;AACH,SAAgB,iBAAiB,CAAC,IAAY;IAC5C,IAAI,CAAC,IAAI,IAAI,IAAI,KAAK,GAAG;QAAE,OAAO,EAAE,CAAC;IACrC,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;AACzC,CAAC;AAHD,8CAGC;AAED;;;GAGG;AACH,SAAgB,iBAAiB,CAAC,GAAa;IAC7C,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,GAAG,CAAC;IACjC,OAAO,GAAG,GAAG,GAAG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G;AACH,SAAgB,cAAc,CAAC,IAAY;IACzC,MAAM,GAAG,GAAG,iBAAiB,CAAC,IAAI,CAAC,CAAC;IACpC,OAAO,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AAC1B,CAAC;AAHD,wCAGC;AAED;;;GAGG;AACH,SAAgB,SAAS,CAAC,IAAY;IACpC,MAAM,GAAG,GAAG,iBAAiB,CAAC,IAAI,CAAC,CAAC;IACpC,OAAO,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AACrD,CAAC;AAHD,8BAGC"}
@@ -0,0 +1,88 @@
1
+ export declare enum ErrorCode {
2
+ TENANT_NOT_FOUND = "TENANT_NOT_FOUND",
3
+ TENANT_ALREADY_EXISTS = "TENANT_ALREADY_EXISTS",
4
+ TENANT_HAS_CHILDREN = "TENANT_HAS_CHILDREN",
5
+ TENANT_CYCLE_DETECTED = "TENANT_CYCLE_DETECTED",
6
+ TENANT_ARCHIVED = "TENANT_ARCHIVED",
7
+ TENANT_CONTEXT_NOT_FOUND = "TENANT_CONTEXT_NOT_FOUND",
8
+ ISOLATION_VIOLATION = "ISOLATION_VIOLATION",
9
+ ISOLATION_STRATEGY_UNSUPPORTED = "ISOLATION_STRATEGY_UNSUPPORTED",
10
+ PERMISSION_LOCKED = "PERMISSION_LOCKED",
11
+ PERMISSION_NOT_FOUND = "PERMISSION_NOT_FOUND",
12
+ PERMISSION_REVOCATION_DENIED = "PERMISSION_REVOCATION_DENIED",
13
+ CONFIG_LOCKED = "CONFIG_LOCKED",
14
+ CONFIG_NOT_FOUND = "CONFIG_NOT_FOUND",
15
+ VALIDATION_ERROR = "VALIDATION_ERROR",
16
+ UNAUTHORIZED = "UNAUTHORIZED",
17
+ FORBIDDEN = "FORBIDDEN",
18
+ WEBHOOK_NOT_FOUND = "WEBHOOK_NOT_FOUND",
19
+ WEBHOOK_DELIVERY_FAILED = "WEBHOOK_DELIVERY_FAILED"
20
+ }
21
+ export declare class StratumError extends Error {
22
+ readonly code: ErrorCode;
23
+ readonly statusCode: number;
24
+ readonly details?: Record<string, unknown>;
25
+ constructor(code: ErrorCode, message: string, statusCode?: number, details?: Record<string, unknown>);
26
+ toJSON(): {
27
+ error: {
28
+ details?: Record<string, unknown> | undefined;
29
+ code: ErrorCode;
30
+ message: string;
31
+ };
32
+ };
33
+ }
34
+ export declare class TenantNotFoundError extends StratumError {
35
+ constructor(tenantId: string);
36
+ }
37
+ export declare class TenantAlreadyExistsError extends StratumError {
38
+ constructor(slug: string);
39
+ }
40
+ export declare class TenantHasChildrenError extends StratumError {
41
+ constructor(tenantId: string);
42
+ }
43
+ export declare class TenantCycleDetectedError extends StratumError {
44
+ constructor(tenantId: string, newParentId: string);
45
+ }
46
+ export declare class TenantArchivedError extends StratumError {
47
+ constructor(tenantId: string);
48
+ }
49
+ export declare class TenantContextNotFoundError extends StratumError {
50
+ constructor();
51
+ }
52
+ export declare class IsolationViolationError extends StratumError {
53
+ constructor(message: string);
54
+ }
55
+ export declare class IsolationStrategyUnsupportedError extends StratumError {
56
+ constructor(strategy: string);
57
+ }
58
+ export declare class PermissionLockedError extends StratumError {
59
+ constructor(key: string, sourceTenantId: string);
60
+ }
61
+ export declare class PermissionNotFoundError extends StratumError {
62
+ constructor(policyId: string);
63
+ }
64
+ export declare class PermissionRevocationDeniedError extends StratumError {
65
+ constructor(key: string);
66
+ }
67
+ export declare class ConfigLockedError extends StratumError {
68
+ constructor(key: string, sourceTenantId: string);
69
+ }
70
+ export declare class ConfigNotFoundError extends StratumError {
71
+ constructor(tenantId: string, key: string);
72
+ }
73
+ export declare class ValidationError extends StratumError {
74
+ constructor(message: string, details?: Record<string, unknown>);
75
+ }
76
+ export declare class UnauthorizedError extends StratumError {
77
+ constructor(message?: string);
78
+ }
79
+ export declare class ForbiddenError extends StratumError {
80
+ constructor(message?: string);
81
+ }
82
+ export declare class WebhookNotFoundError extends StratumError {
83
+ constructor(webhookId: string);
84
+ }
85
+ export declare class WebhookDeliveryError extends StratumError {
86
+ constructor(webhookId: string, message: string);
87
+ }
88
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/utils/errors.ts"],"names":[],"mappings":"AAAA,oBAAY,SAAS;IACnB,gBAAgB,qBAAqB;IACrC,qBAAqB,0BAA0B;IAC/C,mBAAmB,wBAAwB;IAC3C,qBAAqB,0BAA0B;IAC/C,eAAe,oBAAoB;IACnC,wBAAwB,6BAA6B;IACrD,mBAAmB,wBAAwB;IAC3C,8BAA8B,mCAAmC;IACjE,iBAAiB,sBAAsB;IACvC,oBAAoB,yBAAyB;IAC7C,4BAA4B,iCAAiC;IAC7D,aAAa,kBAAkB;IAC/B,gBAAgB,qBAAqB;IACrC,gBAAgB,qBAAqB;IACrC,YAAY,iBAAiB;IAC7B,SAAS,cAAc;IACvB,iBAAiB,sBAAsB;IACvC,uBAAuB,4BAA4B;CACpD;AAED,qBAAa,YAAa,SAAQ,KAAK;IACrC,SAAgB,IAAI,EAAE,SAAS,CAAC;IAChC,SAAgB,UAAU,EAAE,MAAM,CAAC;IACnC,SAAgB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;gBAGhD,IAAI,EAAE,SAAS,EACf,OAAO,EAAE,MAAM,EACf,UAAU,GAAE,MAAY,EACxB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IASnC,MAAM;;;;;;;CASP;AAED,qBAAa,mBAAoB,SAAQ,YAAY;gBACvC,QAAQ,EAAE,MAAM;CAQ7B;AAED,qBAAa,wBAAyB,SAAQ,YAAY;gBAC5C,IAAI,EAAE,MAAM;CAQzB;AAED,qBAAa,sBAAuB,SAAQ,YAAY;gBAC1C,QAAQ,EAAE,MAAM;CAQ7B;AAED,qB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