@girardmedia/bootspring 2.0.24 → 2.0.26

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.
@@ -1,14 +1,26 @@
1
- // @ts-nocheck
2
1
  /**
3
2
  * Policy Matrix
4
3
  * Comprehensive policy definitions for org-level gates
5
4
  * @package bootspring
6
5
  */
7
6
 
7
+ import type {
8
+ Tier,
9
+ PolicyProfile,
10
+ MemberRole,
11
+ PolicyScopes,
12
+ TierPolicy,
13
+ ProfilePolicy,
14
+ RolePermissions,
15
+ MemberOverrides,
16
+ EffectivePolicy,
17
+ PolicyAccessResult,
18
+ } from '../types/policy';
19
+
8
20
  /**
9
21
  * Policy scopes define what can be controlled
10
22
  */
11
- const POLICY_SCOPES = {
23
+ export const POLICY_SCOPES: PolicyScopes = {
12
24
  skills: {
13
25
  external: 'skills.external', // Third-party/external skills
14
26
  premium: 'skills.premium', // Premium skill categories
@@ -41,7 +53,7 @@ const POLICY_SCOPES = {
41
53
  * Default policy matrix by tier
42
54
  * Defines what's allowed/blocked per tier
43
55
  */
44
- const TIER_POLICY_DEFAULTS = {
56
+ export const TIER_POLICY_DEFAULTS: Record<Tier, TierPolicy> = {
45
57
  free: {
46
58
  allowed: [
47
59
  'skills.external',
@@ -119,7 +131,7 @@ const TIER_POLICY_DEFAULTS = {
119
131
  * Profile-specific policy overrides
120
132
  * Applied on top of tier defaults
121
133
  */
122
- const PROFILE_OVERRIDES = {
134
+ export const PROFILE_OVERRIDES: Record<PolicyProfile, ProfilePolicy> = {
123
135
  startup: {
124
136
  // Startup profile: permissive, fast iteration
125
137
  overrides: {},
@@ -152,7 +164,7 @@ const PROFILE_OVERRIDES = {
152
164
  * Member role permissions
153
165
  * What each role can do within an org
154
166
  */
155
- const ROLE_PERMISSIONS = {
167
+ export const ROLE_PERMISSIONS: Record<MemberRole, RolePermissions> = {
156
168
  owner: {
157
169
  canManageOrg: true,
158
170
  canManageMembers: true,
@@ -185,11 +197,8 @@ const ROLE_PERMISSIONS = {
185
197
 
186
198
  /**
187
199
  * Check if a scope matches a pattern
188
- * @param {string} scope - Specific scope (e.g., 'skills.external')
189
- * @param {string} pattern - Pattern to match (e.g., 'skills.*' or 'skills.external')
190
- * @returns {boolean}
191
200
  */
192
- function matchesScope(scope, pattern) {
201
+ export function matchesScope(scope: string, pattern: string): boolean {
193
202
  if (pattern === '*') return true;
194
203
  if (pattern === scope) return true;
195
204
  if (pattern.endsWith('.*')) {
@@ -201,12 +210,8 @@ function matchesScope(scope, pattern) {
201
210
 
202
211
  /**
203
212
  * Check if a scope is allowed by policy
204
- * @param {string} scope - Scope to check
205
- * @param {string[]} allowed - Allowed patterns
206
- * @param {string[]} blocked - Blocked patterns
207
- * @returns {boolean}
208
213
  */
209
- function isScopeAllowed(scope, allowed, blocked) {
214
+ export function isScopeAllowed(scope: string, allowed: string[], blocked: string[]): boolean {
210
215
  // Check blocked first (blocked takes precedence)
211
216
  for (const pattern of blocked) {
212
217
  if (matchesScope(scope, pattern)) {
@@ -224,12 +229,12 @@ function isScopeAllowed(scope, allowed, blocked) {
224
229
 
225
230
  /**
226
231
  * Build effective policy for an org member
227
- * @param {string} tier - Org tier (free/pro/team/enterprise)
228
- * @param {string} profile - Policy profile (startup/regulated/enterprise)
229
- * @param {object} memberOverrides - Per-member policy overrides
230
- * @returns {object} Effective policy
231
232
  */
232
- function buildEffectivePolicy(tier, profile, memberOverrides = {}) {
233
+ export function buildEffectivePolicy(
234
+ tier: Tier,
235
+ profile: PolicyProfile,
236
+ memberOverrides: MemberOverrides = {}
237
+ ): EffectivePolicy {
233
238
  const tierDefaults = TIER_POLICY_DEFAULTS[tier] || TIER_POLICY_DEFAULTS.free;
234
239
  const profileOverrides = PROFILE_OVERRIDES[profile] || PROFILE_OVERRIDES.startup;
235
240
 
@@ -260,11 +265,8 @@ function buildEffectivePolicy(tier, profile, memberOverrides = {}) {
260
265
 
261
266
  /**
262
267
  * Check access against effective policy
263
- * @param {string} scope - Scope to check
264
- * @param {object} policy - Effective policy
265
- * @returns {object} Access result
266
268
  */
267
- function checkPolicyAccess(scope, policy) {
269
+ export function checkPolicyAccess(scope: string, policy: EffectivePolicy): PolicyAccessResult {
268
270
  const allowed = isScopeAllowed(scope, policy.allowed, policy.blocked);
269
271
 
270
272
  if (!allowed) {
@@ -291,14 +293,3 @@ function checkPolicyAccess(scope, policy) {
291
293
  scope
292
294
  };
293
295
  }
294
-
295
- module.exports = {
296
- POLICY_SCOPES,
297
- TIER_POLICY_DEFAULTS,
298
- PROFILE_OVERRIDES,
299
- ROLE_PERMISSIONS,
300
- matchesScope,
301
- isScopeAllowed,
302
- buildEffectivePolicy,
303
- checkPolicyAccess
304
- };
@@ -21,6 +21,9 @@ export * from './skills';
21
21
  // MCP types
22
22
  export * from './mcp';
23
23
 
24
+ // Policy types
25
+ export * from './policy';
26
+
24
27
  // Utility types
25
28
 
26
29
  /**
@@ -0,0 +1,216 @@
1
+ /**
2
+ * Bootspring Policy Types
3
+ * Type definitions for organization policies and access control
4
+ * @package bootspring
5
+ */
6
+
7
+ /**
8
+ * Subscription tiers
9
+ */
10
+ export type Tier = 'free' | 'pro' | 'team' | 'enterprise';
11
+
12
+ /**
13
+ * Policy profile types
14
+ */
15
+ export type PolicyProfile = 'startup' | 'regulated' | 'enterprise';
16
+
17
+ /**
18
+ * Member roles within an organization
19
+ */
20
+ export type MemberRole = 'owner' | 'admin' | 'member' | 'viewer';
21
+
22
+ /**
23
+ * Policy scope categories
24
+ */
25
+ export interface PolicyScopeCategory {
26
+ external?: string;
27
+ premium?: string;
28
+ ai?: string;
29
+ parallel?: string;
30
+ custom?: string;
31
+ technical?: string;
32
+ business?: string;
33
+ enterprise?: string;
34
+ telemetry?: string;
35
+ cloudSync?: string;
36
+ teamSharing?: string;
37
+ auditLogs?: string;
38
+ apiAccess?: string;
39
+ all: string;
40
+ }
41
+
42
+ /**
43
+ * All policy scopes
44
+ */
45
+ export interface PolicyScopes {
46
+ skills: PolicyScopeCategory;
47
+ workflows: PolicyScopeCategory;
48
+ agents: PolicyScopeCategory;
49
+ features: PolicyScopeCategory;
50
+ }
51
+
52
+ /**
53
+ * Usage limits per tier
54
+ */
55
+ export interface PolicyLimits {
56
+ skillsPerDay: number;
57
+ workflowsPerDay: number;
58
+ agentInvocationsPerDay: number;
59
+ teamMembers?: number;
60
+ }
61
+
62
+ /**
63
+ * Tier policy defaults
64
+ */
65
+ export interface TierPolicy {
66
+ allowed: string[];
67
+ blocked: string[];
68
+ limits: PolicyLimits;
69
+ }
70
+
71
+ /**
72
+ * Profile override settings
73
+ */
74
+ export interface ProfileOverrides {
75
+ requireApproval?: string[];
76
+ auditAll?: boolean;
77
+ dataResidency?: boolean;
78
+ ssoRequired?: boolean;
79
+ approvalWorkflow?: boolean;
80
+ }
81
+
82
+ /**
83
+ * Profile policy configuration
84
+ */
85
+ export interface ProfilePolicy {
86
+ overrides: ProfileOverrides;
87
+ additionalBlocked: string[];
88
+ }
89
+
90
+ /**
91
+ * Role permissions
92
+ */
93
+ export interface RolePermissions {
94
+ canManageOrg: boolean;
95
+ canManageMembers: boolean;
96
+ canManagePolicies: boolean;
97
+ canManageBilling: boolean;
98
+ canUseAllFeatures: boolean;
99
+ }
100
+
101
+ /**
102
+ * Member policy overrides
103
+ */
104
+ export interface MemberOverrides {
105
+ additionalAllowed?: string[];
106
+ additionalBlocked?: string[];
107
+ limits?: Partial<PolicyLimits>;
108
+ overrides?: ProfileOverrides;
109
+ }
110
+
111
+ /**
112
+ * Effective policy after merging tier, profile, and member overrides
113
+ */
114
+ export interface EffectivePolicy {
115
+ tier: Tier;
116
+ profile: PolicyProfile;
117
+ allowed: string[];
118
+ blocked: string[];
119
+ limits: PolicyLimits;
120
+ overrides: ProfileOverrides;
121
+ }
122
+
123
+ /**
124
+ * Policy access check result
125
+ */
126
+ export interface PolicyAccessResult {
127
+ allowed: boolean;
128
+ scope: string;
129
+ code?: string;
130
+ reason?: string;
131
+ requiresApproval?: boolean;
132
+ }
133
+
134
+ /**
135
+ * Organization member
136
+ */
137
+ export interface OrgMember {
138
+ userId: string;
139
+ email?: string;
140
+ role: MemberRole;
141
+ policyOverrides?: MemberOverrides;
142
+ }
143
+
144
+ /**
145
+ * Organization
146
+ */
147
+ export interface Organization {
148
+ id: string;
149
+ name: string;
150
+ tier: Tier;
151
+ policyProfile: PolicyProfile;
152
+ settings?: Record<string, unknown>;
153
+ members?: OrgMember[];
154
+ memberCount?: number;
155
+ createdAt?: string;
156
+ policy?: {
157
+ allowExternalSkills?: boolean;
158
+ blockedWorkflows?: string[];
159
+ };
160
+ }
161
+
162
+ /**
163
+ * Organization context with resolved policy
164
+ */
165
+ export interface OrgContext {
166
+ hasOrg: boolean;
167
+ orgId: string | null;
168
+ org: Organization | null;
169
+ member: OrgMember | null;
170
+ policy: EffectivePolicy | null;
171
+ role?: MemberRole;
172
+ }
173
+
174
+ /**
175
+ * Organization policy access result
176
+ */
177
+ export interface OrgPolicyAccessResult extends PolicyAccessResult {
178
+ hasOrgPolicy: boolean;
179
+ orgId?: string;
180
+ tier?: Tier;
181
+ profile?: PolicyProfile;
182
+ }
183
+
184
+ /**
185
+ * Organization policy summary
186
+ */
187
+ export interface OrgPolicySummary {
188
+ hasOrg: boolean;
189
+ message?: string;
190
+ orgId?: string;
191
+ orgName?: string;
192
+ tier?: Tier;
193
+ profile?: PolicyProfile;
194
+ role?: MemberRole;
195
+ allowedScopes?: number;
196
+ blockedScopes?: number;
197
+ limits?: PolicyLimits;
198
+ overrides?: string[];
199
+ }
200
+
201
+ /**
202
+ * Options for organization operations
203
+ */
204
+ export interface OrgOptions {
205
+ orgId?: string | undefined;
206
+ userId?: string | undefined;
207
+ apiKey?: string | undefined;
208
+ }
209
+
210
+ /**
211
+ * Cache entry structure
212
+ */
213
+ export interface CacheEntry<T> {
214
+ data: T;
215
+ timestamp: number;
216
+ }
package/src/version.ts CHANGED
@@ -2,5 +2,5 @@
2
2
  * Bootspring Version
3
3
  * Auto-updated during build process
4
4
  */
5
- export const VERSION = '2.0.24';
5
+ export const VERSION = '2.0.26';
6
6
  export const PACKAGE_NAME = '@girardmedia/bootspring';