@fabricorg/platform 0.3.1 → 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/CHANGELOG.md +24 -0
- package/README.md +1 -1
- package/dist/{chunk-PZT7TUG4.js → chunk-CSZXUX5V.js} +3 -3
- package/dist/{chunk-PZT7TUG4.js.map → chunk-CSZXUX5V.js.map} +1 -1
- package/dist/{chunk-SDXDHVTV.cjs → chunk-DBZRPM72.cjs} +33 -3
- package/dist/chunk-DBZRPM72.cjs.map +1 -0
- package/dist/{chunk-KOC4A7A4.js → chunk-I3BMSYDF.js} +33 -3
- package/dist/chunk-I3BMSYDF.js.map +1 -0
- package/dist/{chunk-GLUBIGV2.cjs → chunk-P76WWJIJ.cjs} +4 -4
- package/dist/{chunk-GLUBIGV2.cjs.map → chunk-P76WWJIJ.cjs.map} +1 -1
- package/dist/index.cjs +19 -19
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/modules/index.cjs +9 -9
- package/dist/modules/index.js +2 -2
- package/dist/policies/index.cjs +11 -11
- package/dist/policies/index.d.cts +50 -1
- package/dist/policies/index.d.ts +50 -1
- package/dist/policies/index.js +1 -1
- package/package.json +197 -196
- package/dist/chunk-KOC4A7A4.js.map +0 -1
- package/dist/chunk-SDXDHVTV.cjs.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../modules/index.ts"],"names":["isValidEventType","registerObjectType","registerSubjectType","registerEventType","registerPolicyIfMissing","registerStateMachineIfMissing","registerActionIfMissing","registerDisplayRenderer"],"mappings":";;;;;;;;;;AAsFA,IAAM,0BAAA,uBAAiC,GAAA,EAAY;AAE5C,SAAS,6BAA6B,UAAA,EAA2C;AACvF,EAAA,OAAO,OAAO,UAAA,KAAe,QAAA,GAAW,UAAA,GAAa,UAAA,CAAW,SAAA;AACjE;AAEO,SAAS,kBAAkB,UAAA,EAAiD;AAClF,EAAA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CAAiB,MAAA,EAAQ,EAAE,mBAAA,EAAqB,iBAAA,EAAmB,CAAA;AAAA,EACpE;AAEA,EAAA,MAAM,aAAA,GAAgB,wBAAwB,OAAO,CAAA;AACrD,EAAA,KAAA,MAAW,UAAU,aAAA,EAAe;AACnC,IAAA,oBAAA,CAAqB,MAAM,CAAA;AAAA,EAC5B;AAEA,EAAA,OAAO,aAAA;AACR","file":"chunk-GLUBIGV2.cjs","sourcesContent":["import { registerActionIfMissing, type ActionDefinition } from \"../actions\";\nimport { registerDisplayRenderer, type DisplayRenderer } from \"../displays\";\nimport { isValidEventType, registerEventType, registerSubjectType } from \"../events\";\nimport { registerObjectType } from \"../objects\";\nimport { registerPolicyIfMissing, type PolicyEvaluator } from \"../policies\";\nimport { registerStateMachineIfMissing, type StateMachineDefinition } from \"../state-machines\";\n\nexport interface ModuleDependency {\n\tnamespace: string;\n\tversion?: string;\n\toptional?: boolean;\n}\n\nexport type ModuleDependencyInput = string | ModuleDependency;\n\nexport interface IdPrefixRegistration {\n\tprefix: string;\n\tname: string;\n\tmodule: string;\n}\n\nexport interface EventTypeRegistration {\n\teventType: string;\n\tschemaVersion: number;\n\tdescription?: string;\n}\n\nexport type EventTypeRegistrationInput = string | EventTypeRegistration;\n\nexport interface ObjectTypeRegistration {\n\ttype: string;\n\tdisplayName?: string;\n\tidPrefix?: string;\n\tisCoreModuleType?: boolean;\n}\n\nexport type ObjectTypeRegistrationInput = string | ObjectTypeRegistration;\n\nexport interface ModuleDisplayRendererRegistration {\n\teventType: string;\n\trenderer: DisplayRenderer;\n}\n\nexport interface PolicyRegistration {\n\tid: string;\n\tversion?: string;\n\tdescription?: string;\n}\n\nexport interface StateMachineRegistration {\n\tentityType: string;\n\tstates: string[];\n}\n\nexport interface FabricModule<TDb = unknown> {\n\tnamespace: string;\n\tversion?: string;\n\tdisplayName?: string;\n\tdescription?: string;\n\tdependencies?: ModuleDependencyInput[];\n\tobjectTypes?: ObjectTypeRegistrationInput[];\n\tsubjectTypes?: string[];\n\tidPrefixes?: IdPrefixRegistration[];\n\teventTypes?: EventTypeRegistrationInput[];\n\tactions?: ActionDefinition<TDb>[];\n\tpolicies?: unknown[];\n\tstateMachines?: unknown[];\n\tdisplayRenderers?: ModuleDisplayRendererRegistration[];\n\tadapterDefinitions?: unknown[];\n\tpermissions?: unknown[];\n\troles?: unknown[];\n\tredactionRules?: unknown[];\n\tdataClassifications?: unknown[];\n\tretentionRules?: unknown[];\n\tevidenceRenderers?: unknown[];\n}\n\nexport interface ModuleRegistry<TDb = unknown> {\n\tmodules: ReadonlyMap<string, FabricModule<TDb>>;\n}\n\ninterface ModuleValidationContext {\n\tavailableNamespaces?: Set<string>;\n\tplannedEventTypes?: Set<string>;\n}\n\nconst registeredModuleNamespaces = new Set<string>();\n\nexport function getModuleDependencyNamespace(dependency: ModuleDependencyInput): string {\n\treturn typeof dependency === \"string\" ? dependency : dependency.namespace;\n}\n\nexport function getObjectTypeName(objectType: ObjectTypeRegistrationInput): string {\n\treturn typeof objectType === \"string\" ? objectType : objectType.type;\n}\n\nexport function getEventTypeName(eventType: EventTypeRegistrationInput): string {\n\treturn typeof eventType === \"string\" ? eventType : eventType.eventType;\n}\n\nexport function validateModuleNamespace(namespace: string): void {\n\tif (!namespace) {\n\t\tthrow new Error(\"Module namespace cannot be empty\");\n\t}\n\tif (!/^[a-z][a-z0-9-]*$/.test(namespace)) {\n\t\tthrow new Error(\n\t\t\t`Invalid module namespace: \"${namespace}\". Must be lowercase letters, numbers, and hyphens only.`,\n\t\t);\n\t}\n}\n\nexport function createModuleRegistry<TDb = unknown>(\n\tmodules: FabricModule<TDb>[] = [],\n): ModuleRegistry<TDb> {\n\tconst registered = new Map<string, FabricModule<TDb>>();\n\tfor (const module of modules) {\n\t\tvalidateModuleNamespace(module.namespace);\n\t\tif (registered.has(module.namespace)) {\n\t\t\tthrow new Error(`Duplicate FabricModule namespace \"${module.namespace}\".`);\n\t\t}\n\t\tregistered.set(module.namespace, module);\n\t}\n\treturn { modules: registered };\n}\n\nfunction validateIdentifierList(\n\tvalues: string[] | undefined,\n\tlabel: string,\n\tnamespace: string,\n): void {\n\tfor (const value of values ?? []) {\n\t\tif (!value) {\n\t\t\tthrow new Error(`Module \"${namespace}\" has an empty ${label} entry.`);\n\t\t}\n\t}\n}\n\nfunction validateManifest(module: FabricModule<unknown>, context: ModuleValidationContext = {}): void {\n\tvalidateModuleNamespace(module.namespace);\n\n\tconst dependencies = (module.dependencies ?? []).map(getModuleDependencyNamespace);\n\tconst objectTypes = (module.objectTypes ?? []).map(getObjectTypeName);\n\tconst eventTypes = (module.eventTypes ?? []).map(getEventTypeName);\n\n\tfor (const dependency of dependencies) {\n\t\tvalidateModuleNamespace(dependency);\n\t\tif (dependency === module.namespace) {\n\t\t\tthrow new Error(`Module \"${module.namespace}\" cannot depend on itself.`);\n\t\t}\n\t\tif (context.availableNamespaces && !context.availableNamespaces.has(dependency)) {\n\t\t\tthrow new Error(`Module \"${module.namespace}\" depends on missing module \"${dependency}\".`);\n\t\t}\n\t}\n\n\tvalidateIdentifierList(objectTypes, \"objectTypes\", module.namespace);\n\tvalidateIdentifierList(module.subjectTypes, \"subjectTypes\", module.namespace);\n\tvalidateIdentifierList(eventTypes, \"eventTypes\", module.namespace);\n\n\tfor (const objectType of objectTypes) {\n\t\tif (!/^[A-Z][a-zA-Z0-9]*$/.test(objectType)) {\n\t\t\tthrow new Error(\n\t\t\t\t`Invalid object type: \"${objectType}\". Object types must be PascalCase alphanumeric.`,\n\t\t\t);\n\t\t}\n\t}\n\n\tfor (const action of module.actions ?? []) {\n\t\tif (!/^[a-z][a-z0-9-]*\\.[a-z][a-z0-9_]*$/.test(action.actionId)) {\n\t\t\tthrow new Error(`Invalid action ID: ${action.actionId}`);\n\t\t}\n\n\t\tif (action.namespace !== module.namespace) {\n\t\t\tthrow new Error(\n\t\t\t\t`Action \"${action.actionId}\" declares namespace \"${action.namespace}\" ` +\n\t\t\t\t\t`but is registered by module \"${module.namespace}\".`,\n\t\t\t);\n\t\t}\n\n\t\tif (!action.actionId.startsWith(`${module.namespace}.`)) {\n\t\t\tthrow new Error(\n\t\t\t\t`Action \"${action.actionId}\" must start with module namespace \"${module.namespace}.\"`,\n\t\t\t);\n\t\t}\n\n\t\tif (action.mutatesDomain && action.emitsEvents.length === 0) {\n\t\t\tthrow new Error(\n\t\t\t\t`Action \"${action.actionId}\" mutates domain but emits no events. ` +\n\t\t\t\t\t`Every mutating action must emit at least one AssetEvent.`,\n\t\t\t);\n\t\t}\n\t}\n\n\tfor (const descriptor of module.displayRenderers ?? []) {\n\t\tconst isPlannedEventType = context.plannedEventTypes?.has(descriptor.eventType) ?? false;\n\t\tconst isModuleEventType = eventTypes.includes(descriptor.eventType);\n\t\tif (!isValidEventType(descriptor.eventType) && !isModuleEventType && !isPlannedEventType) {\n\t\t\tthrow new Error(\n\t\t\t\t`Display renderer registered for unknown event type \"${descriptor.eventType}\". ` +\n\t\t\t\t\t`Register the event type before adding a display renderer.`,\n\t\t\t);\n\t\t}\n\t}\n}\n\nfunction sortModulesByDependency(\n\tmodules: FabricModule<unknown>[],\n\tregisteredNamespaces = registeredModuleNamespaces,\n): FabricModule<unknown>[] {\n\tconst modulesByNamespace = new Map<string, FabricModule<unknown>>();\n\n\tfor (const module of modules) {\n\t\tvalidateModuleNamespace(module.namespace);\n\t\tif (modulesByNamespace.has(module.namespace)) {\n\t\t\tthrow new Error(`Duplicate Fabric module namespace \"${module.namespace}\".`);\n\t\t}\n\t\tmodulesByNamespace.set(module.namespace, module);\n\t}\n\n\tconst sorted: FabricModule<unknown>[] = [];\n\tconst visiting = new Set<string>();\n\tconst visited = new Set<string>();\n\n\tfunction visit(module: FabricModule<unknown>, path: string[]): void {\n\t\tif (visited.has(module.namespace)) {\n\t\t\treturn;\n\t\t}\n\t\tif (visiting.has(module.namespace)) {\n\t\t\tthrow new Error(\n\t\t\t\t`Cyclic Fabric module dependency detected: ${[...path, module.namespace].join(\" -> \")}`,\n\t\t\t);\n\t\t}\n\n\t\tvisiting.add(module.namespace);\n\t\tfor (const dependency of (module.dependencies ?? []).map(getModuleDependencyNamespace)) {\n\t\t\tconst dependencyModule = modulesByNamespace.get(dependency);\n\t\t\tif (!dependencyModule) {\n\t\t\t\tif (registeredNamespaces.has(dependency)) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tthrow new Error(`Module \"${module.namespace}\" depends on missing module \"${dependency}\".`);\n\t\t\t}\n\t\t\tvisit(dependencyModule, [...path, module.namespace]);\n\t\t}\n\t\tvisiting.delete(module.namespace);\n\t\tvisited.add(module.namespace);\n\t\tsorted.push(module);\n\t}\n\n\tfor (const module of modules) {\n\t\tvisit(module, []);\n\t}\n\n\treturn sorted;\n}\n\nexport function registerFabricModule(module: FabricModule<unknown>): void {\n\tvalidateManifest(module, { availableNamespaces: registeredModuleNamespaces });\n\n\tfor (const objectType of module.objectTypes ?? []) {\n\t\tregisterObjectType(getObjectTypeName(objectType));\n\t}\n\n\tfor (const subjectType of module.subjectTypes ?? []) {\n\t\tregisterSubjectType(subjectType);\n\t}\n\n\tfor (const eventType of module.eventTypes ?? []) {\n\t\tregisterEventType(getEventTypeName(eventType));\n\t}\n\n\tfor (const policy of module.policies ?? []) {\n\t\tregisterPolicyIfMissing(policy as PolicyEvaluator);\n\t}\n\n\tfor (const machine of module.stateMachines ?? []) {\n\t\tregisterStateMachineIfMissing(machine as StateMachineDefinition);\n\t}\n\n\tfor (const action of module.actions ?? []) {\n\t\tregisterActionIfMissing(action);\n\t}\n\n\tfor (const descriptor of module.displayRenderers ?? []) {\n\t\tregisterDisplayRenderer(descriptor.eventType, descriptor.renderer as DisplayRenderer);\n\t}\n\n\tregisteredModuleNamespaces.add(module.namespace);\n}\n\nexport function registerFabricModules(modules: FabricModule<unknown>[]): FabricModule<unknown>[] {\n\tconst availableNamespaces = new Set([\n\t\t...registeredModuleNamespaces,\n\t\t...modules.map((module) => module.namespace),\n\t]);\n\tconst plannedEventTypes = new Set(\n\t\tmodules.flatMap((module) => (module.eventTypes ?? []).map(getEventTypeName)),\n\t);\n\n\tfor (const module of modules) {\n\t\tvalidateManifest(module, { availableNamespaces, plannedEventTypes });\n\t}\n\n\tconst sortedModules = sortModulesByDependency(modules);\n\tfor (const module of sortedModules) {\n\t\tregisterFabricModule(module);\n\t}\n\n\treturn sortedModules;\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../modules/index.ts"],"names":["isValidEventType","registerObjectType","registerSubjectType","registerEventType","registerPolicyIfMissing","registerStateMachineIfMissing","registerActionIfMissing","registerDisplayRenderer"],"mappings":";;;;;;;;;;AAsFA,IAAM,0BAAA,uBAAiC,GAAA,EAAY;AAE5C,SAAS,6BAA6B,UAAA,EAA2C;AACvF,EAAA,OAAO,OAAO,UAAA,KAAe,QAAA,GAAW,UAAA,GAAa,UAAA,CAAW,SAAA;AACjE;AAEO,SAAS,kBAAkB,UAAA,EAAiD;AAClF,EAAA,OAAO,OAAO,UAAA,KAAe,QAAA,GAAW,UAAA,GAAa,UAAA,CAAW,IAAA;AACjE;AAEO,SAAS,iBAAiB,SAAA,EAA+C;AAC/E,EAAA,OAAO,OAAO,SAAA,KAAc,QAAA,GAAW,SAAA,GAAY,SAAA,CAAU,SAAA;AAC9D;AAEO,SAAS,wBAAwB,SAAA,EAAyB;AAChE,EAAA,IAAI,CAAC,SAAA,EAAW;AACf,IAAA,MAAM,IAAI,MAAM,kCAAkC,CAAA;AAAA,EACnD;AACA,EAAA,IAAI,CAAC,mBAAA,CAAoB,IAAA,CAAK,SAAS,CAAA,EAAG;AACzC,IAAA,MAAM,IAAI,KAAA;AAAA,MACT,8BAA8B,SAAS,CAAA,wDAAA;AAAA,KACxC;AAAA,EACD;AACD;AAEO,SAAS,oBAAA,CACf,OAAA,GAA+B,EAAC,EACV;AACtB,EAAA,MAAM,UAAA,uBAAiB,GAAA,EAA+B;AACtD,EAAA,KAAA,MAAW,UAAU,OAAA,EAAS;AAC7B,IAAA,uBAAA,CAAwB,OAAO,SAAS,CA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AC,yCAAA,CAAwB,UAAA,CAAW,SAAA,EAAW,UAAA,CAAW,QAA2B,CAAA;AAAA,EACrF;AAEA,EAAA,0BAAA,CAA2B,GAAA,CAAI,OAAO,SAAS,CAAA;AAChD;AAEO,SAAS,sBAAsB,OAAA,EAA2D;AAChG,EAAA,MAAM,mBAAA,uBAA0B,GAAA,CAAI;AAAA,IACnC,GAAG,0BAAA;AAAA,IACH,GAAG,OAAA,CAAQ,GAAA,CAAI,CAAC,MAAA,KAAW,OAAO,SAAS;AAAA,GAC3C,CAAA;AACD,EAAA,MAAM,oBAAoB,IAAI,GAAA;AAAA,IAC7B,OAAA,CAAQ,OAAA,CAAQ,CAAC,MAAA,KAAA,CAAY,MAAA,CAAO,cAAc,EAAC,EAAG,GAAA,CAAI,gBAAgB,CAAC;AAAA,GAC5E;AAEA,EAAA,KAAA,MAAW,UAAU,OAAA,EAAS;AAC7B,IAAA,gBAAA,CAAiB,MAAA,EAAQ,EAAE,mBAAA,EAAqB,iBAAA,EAAmB,CAAA;AAAA,EACpE;AAEA,EAAA,MAAM,aAAA,GAAgB,wBAAwB,OAAO,CAAA;AACrD,EAAA,KAAA,MAAW,UAAU,aAAA,EAAe;AACnC,IAAA,oBAAA,CAAqB,MAAM,CAAA;AAAA,EAC5B;AAEA,EAAA,OAAO,aAAA;AACR","file":"chunk-P76WWJIJ.cjs","sourcesContent":["import { registerActionIfMissing, type ActionDefinition } from \"../actions\";\nimport { registerDisplayRenderer, type DisplayRenderer } from \"../displays\";\nimport { isValidEventType, registerEventType, registerSubjectType } from \"../events\";\nimport { registerObjectType } from \"../objects\";\nimport { registerPolicyIfMissing, type PolicyEvaluator } from \"../policies\";\nimport { registerStateMachineIfMissing, type StateMachineDefinition } from \"../state-machines\";\n\nexport interface ModuleDependency {\n\tnamespace: string;\n\tversion?: string;\n\toptional?: boolean;\n}\n\nexport type ModuleDependencyInput = string | ModuleDependency;\n\nexport interface IdPrefixRegistration {\n\tprefix: string;\n\tname: string;\n\tmodule: string;\n}\n\nexport interface EventTypeRegistration {\n\teventType: string;\n\tschemaVersion: number;\n\tdescription?: string;\n}\n\nexport type EventTypeRegistrationInput = string | EventTypeRegistration;\n\nexport interface ObjectTypeRegistration {\n\ttype: string;\n\tdisplayName?: string;\n\tidPrefix?: string;\n\tisCoreModuleType?: boolean;\n}\n\nexport type ObjectTypeRegistrationInput = string | ObjectTypeRegistration;\n\nexport interface ModuleDisplayRendererRegistration {\n\teventType: string;\n\trenderer: DisplayRenderer;\n}\n\nexport interface PolicyRegistration {\n\tid: string;\n\tversion?: string;\n\tdescription?: string;\n}\n\nexport interface StateMachineRegistration {\n\tentityType: string;\n\tstates: string[];\n}\n\nexport interface FabricModule<TDb = unknown> {\n\tnamespace: string;\n\tversion?: string;\n\tdisplayName?: string;\n\tdescription?: string;\n\tdependencies?: ModuleDependencyInput[];\n\tobjectTypes?: ObjectTypeRegistrationInput[];\n\tsubjectTypes?: string[];\n\tidPrefixes?: IdPrefixRegistration[];\n\teventTypes?: EventTypeRegistrationInput[];\n\tactions?: ActionDefinition<TDb>[];\n\tpolicies?: unknown[];\n\tstateMachines?: unknown[];\n\tdisplayRenderers?: ModuleDisplayRendererRegistration[];\n\tadapterDefinitions?: unknown[];\n\tpermissions?: unknown[];\n\troles?: unknown[];\n\tredactionRules?: unknown[];\n\tdataClassifications?: unknown[];\n\tretentionRules?: unknown[];\n\tevidenceRenderers?: unknown[];\n}\n\nexport interface ModuleRegistry<TDb = unknown> {\n\tmodules: ReadonlyMap<string, FabricModule<TDb>>;\n}\n\ninterface ModuleValidationContext {\n\tavailableNamespaces?: Set<string>;\n\tplannedEventTypes?: Set<string>;\n}\n\nconst registeredModuleNamespaces = new Set<string>();\n\nexport function getModuleDependencyNamespace(dependency: ModuleDependencyInput): string {\n\treturn typeof dependency === \"string\" ? dependency : dependency.namespace;\n}\n\nexport function getObjectTypeName(objectType: ObjectTypeRegistrationInput): string {\n\treturn typeof objectType === \"string\" ? objectType : objectType.type;\n}\n\nexport function getEventTypeName(eventType: EventTypeRegistrationInput): string {\n\treturn typeof eventType === \"string\" ? eventType : eventType.eventType;\n}\n\nexport function validateModuleNamespace(namespace: string): void {\n\tif (!namespace) {\n\t\tthrow new Error(\"Module namespace cannot be empty\");\n\t}\n\tif (!/^[a-z][a-z0-9-]*$/.test(namespace)) {\n\t\tthrow new Error(\n\t\t\t`Invalid module namespace: \"${namespace}\". Must be lowercase letters, numbers, and hyphens only.`,\n\t\t);\n\t}\n}\n\nexport function createModuleRegistry<TDb = unknown>(\n\tmodules: FabricModule<TDb>[] = [],\n): ModuleRegistry<TDb> {\n\tconst registered = new Map<string, FabricModule<TDb>>();\n\tfor (const module of modules) {\n\t\tvalidateModuleNamespace(module.namespace);\n\t\tif (registered.has(module.namespace)) {\n\t\t\tthrow new Error(`Duplicate FabricModule namespace \"${module.namespace}\".`);\n\t\t}\n\t\tregistered.set(module.namespace, module);\n\t}\n\treturn { modules: registered };\n}\n\nfunction validateIdentifierList(\n\tvalues: string[] | undefined,\n\tlabel: string,\n\tnamespace: string,\n): void {\n\tfor (const value of values ?? []) {\n\t\tif (!value) {\n\t\t\tthrow new Error(`Module \"${namespace}\" has an empty ${label} entry.`);\n\t\t}\n\t}\n}\n\nfunction validateManifest(module: FabricModule<unknown>, context: ModuleValidationContext = {}): void {\n\tvalidateModuleNamespace(module.namespace);\n\n\tconst dependencies = (module.dependencies ?? []).map(getModuleDependencyNamespace);\n\tconst objectTypes = (module.objectTypes ?? []).map(getObjectTypeName);\n\tconst eventTypes = (module.eventTypes ?? []).map(getEventTypeName);\n\n\tfor (const dependency of dependencies) {\n\t\tvalidateModuleNamespace(dependency);\n\t\tif (dependency === module.namespace) {\n\t\t\tthrow new Error(`Module \"${module.namespace}\" cannot depend on itself.`);\n\t\t}\n\t\tif (context.availableNamespaces && !context.availableNamespaces.has(dependency)) {\n\t\t\tthrow new Error(`Module \"${module.namespace}\" depends on missing module \"${dependency}\".`);\n\t\t}\n\t}\n\n\tvalidateIdentifierList(objectTypes, \"objectTypes\", module.namespace);\n\tvalidateIdentifierList(module.subjectTypes, \"subjectTypes\", module.namespace);\n\tvalidateIdentifierList(eventTypes, \"eventTypes\", module.namespace);\n\n\tfor (const objectType of objectTypes) {\n\t\tif (!/^[A-Z][a-zA-Z0-9]*$/.test(objectType)) {\n\t\t\tthrow new Error(\n\t\t\t\t`Invalid object type: \"${objectType}\". Object types must be PascalCase alphanumeric.`,\n\t\t\t);\n\t\t}\n\t}\n\n\tfor (const action of module.actions ?? []) {\n\t\tif (!/^[a-z][a-z0-9-]*\\.[a-z][a-z0-9_]*$/.test(action.actionId)) {\n\t\t\tthrow new Error(`Invalid action ID: ${action.actionId}`);\n\t\t}\n\n\t\tif (action.namespace !== module.namespace) {\n\t\t\tthrow new Error(\n\t\t\t\t`Action \"${action.actionId}\" declares namespace \"${action.namespace}\" ` +\n\t\t\t\t\t`but is registered by module \"${module.namespace}\".`,\n\t\t\t);\n\t\t}\n\n\t\tif (!action.actionId.startsWith(`${module.namespace}.`)) {\n\t\t\tthrow new Error(\n\t\t\t\t`Action \"${action.actionId}\" must start with module namespace \"${module.namespace}.\"`,\n\t\t\t);\n\t\t}\n\n\t\tif (action.mutatesDomain && action.emitsEvents.length === 0) {\n\t\t\tthrow new Error(\n\t\t\t\t`Action \"${action.actionId}\" mutates domain but emits no events. ` +\n\t\t\t\t\t`Every mutating action must emit at least one AssetEvent.`,\n\t\t\t);\n\t\t}\n\t}\n\n\tfor (const descriptor of module.displayRenderers ?? []) {\n\t\tconst isPlannedEventType = context.plannedEventTypes?.has(descriptor.eventType) ?? false;\n\t\tconst isModuleEventType = eventTypes.includes(descriptor.eventType);\n\t\tif (!isValidEventType(descriptor.eventType) && !isModuleEventType && !isPlannedEventType) {\n\t\t\tthrow new Error(\n\t\t\t\t`Display renderer registered for unknown event type \"${descriptor.eventType}\". ` +\n\t\t\t\t\t`Register the event type before adding a display renderer.`,\n\t\t\t);\n\t\t}\n\t}\n}\n\nfunction sortModulesByDependency(\n\tmodules: FabricModule<unknown>[],\n\tregisteredNamespaces = registeredModuleNamespaces,\n): FabricModule<unknown>[] {\n\tconst modulesByNamespace = new Map<string, FabricModule<unknown>>();\n\n\tfor (const module of modules) {\n\t\tvalidateModuleNamespace(module.namespace);\n\t\tif (modulesByNamespace.has(module.namespace)) {\n\t\t\tthrow new Error(`Duplicate Fabric module namespace \"${module.namespace}\".`);\n\t\t}\n\t\tmodulesByNamespace.set(module.namespace, module);\n\t}\n\n\tconst sorted: FabricModule<unknown>[] = [];\n\tconst visiting = new Set<string>();\n\tconst visited = new Set<string>();\n\n\tfunction visit(module: FabricModule<unknown>, path: string[]): void {\n\t\tif (visited.has(module.namespace)) {\n\t\t\treturn;\n\t\t}\n\t\tif (visiting.has(module.namespace)) {\n\t\t\tthrow new Error(\n\t\t\t\t`Cyclic Fabric module dependency detected: ${[...path, module.namespace].join(\" -> \")}`,\n\t\t\t);\n\t\t}\n\n\t\tvisiting.add(module.namespace);\n\t\tfor (const dependency of (module.dependencies ?? []).map(getModuleDependencyNamespace)) {\n\t\t\tconst dependencyModule = modulesByNamespace.get(dependency);\n\t\t\tif (!dependencyModule) {\n\t\t\t\tif (registeredNamespaces.has(dependency)) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tthrow new Error(`Module \"${module.namespace}\" depends on missing module \"${dependency}\".`);\n\t\t\t}\n\t\t\tvisit(dependencyModule, [...path, module.namespace]);\n\t\t}\n\t\tvisiting.delete(module.namespace);\n\t\tvisited.add(module.namespace);\n\t\tsorted.push(module);\n\t}\n\n\tfor (const module of modules) {\n\t\tvisit(module, []);\n\t}\n\n\treturn sorted;\n}\n\nexport function registerFabricModule(module: FabricModule<unknown>): void {\n\tvalidateManifest(module, { availableNamespaces: registeredModuleNamespaces });\n\n\tfor (const objectType of module.objectTypes ?? []) {\n\t\tregisterObjectType(getObjectTypeName(objectType));\n\t}\n\n\tfor (const subjectType of module.subjectTypes ?? []) {\n\t\tregisterSubjectType(subjectType);\n\t}\n\n\tfor (const eventType of module.eventTypes ?? []) {\n\t\tregisterEventType(getEventTypeName(eventType));\n\t}\n\n\tfor (const policy of module.policies ?? []) {\n\t\tregisterPolicyIfMissing(policy as PolicyEvaluator);\n\t}\n\n\tfor (const machine of module.stateMachines ?? []) {\n\t\tregisterStateMachineIfMissing(machine as StateMachineDefinition);\n\t}\n\n\tfor (const action of module.actions ?? []) {\n\t\tregisterActionIfMissing(action);\n\t}\n\n\tfor (const descriptor of module.displayRenderers ?? []) {\n\t\tregisterDisplayRenderer(descriptor.eventType, descriptor.renderer as DisplayRenderer);\n\t}\n\n\tregisteredModuleNamespaces.add(module.namespace);\n}\n\nexport function registerFabricModules(modules: FabricModule<unknown>[]): FabricModule<unknown>[] {\n\tconst availableNamespaces = new Set([\n\t\t...registeredModuleNamespaces,\n\t\t...modules.map((module) => module.namespace),\n\t]);\n\tconst plannedEventTypes = new Set(\n\t\tmodules.flatMap((module) => (module.eventTypes ?? []).map(getEventTypeName)),\n\t);\n\n\tfor (const module of modules) {\n\t\tvalidateManifest(module, { availableNamespaces, plannedEventTypes });\n\t}\n\n\tconst sortedModules = sortModulesByDependency(modules);\n\tfor (const module of sortedModules) {\n\t\tregisterFabricModule(module);\n\t}\n\n\treturn sortedModules;\n}\n"]}
|
package/dist/index.cjs
CHANGED
|
@@ -6,9 +6,9 @@ var chunkYZKUEC2J_cjs = require('./chunk-YZKUEC2J.cjs');
|
|
|
6
6
|
var chunkNPVIFZQV_cjs = require('./chunk-NPVIFZQV.cjs');
|
|
7
7
|
require('./chunk-PG5LYTUX.cjs');
|
|
8
8
|
var chunkLZSE6QGQ_cjs = require('./chunk-LZSE6QGQ.cjs');
|
|
9
|
-
var
|
|
9
|
+
var chunkP76WWJIJ_cjs = require('./chunk-P76WWJIJ.cjs');
|
|
10
10
|
var chunkQETQGAXJ_cjs = require('./chunk-QETQGAXJ.cjs');
|
|
11
|
-
var
|
|
11
|
+
var chunkDBZRPM72_cjs = require('./chunk-DBZRPM72.cjs');
|
|
12
12
|
var chunkUV252FLT_cjs = require('./chunk-UV252FLT.cjs');
|
|
13
13
|
var chunkRMI3BIND_cjs = require('./chunk-RMI3BIND.cjs');
|
|
14
14
|
var chunkEO4VSB2O_cjs = require('./chunk-EO4VSB2O.cjs');
|
|
@@ -74,31 +74,31 @@ Object.defineProperty(exports, "parseFabricId", {
|
|
|
74
74
|
});
|
|
75
75
|
Object.defineProperty(exports, "createModuleRegistry", {
|
|
76
76
|
enumerable: true,
|
|
77
|
-
get: function () { return
|
|
77
|
+
get: function () { return chunkP76WWJIJ_cjs.createModuleRegistry; }
|
|
78
78
|
});
|
|
79
79
|
Object.defineProperty(exports, "getEventTypeName", {
|
|
80
80
|
enumerable: true,
|
|
81
|
-
get: function () { return
|
|
81
|
+
get: function () { return chunkP76WWJIJ_cjs.getEventTypeName; }
|
|
82
82
|
});
|
|
83
83
|
Object.defineProperty(exports, "getModuleDependencyNamespace", {
|
|
84
84
|
enumerable: true,
|
|
85
|
-
get: function () { return
|
|
85
|
+
get: function () { return chunkP76WWJIJ_cjs.getModuleDependencyNamespace; }
|
|
86
86
|
});
|
|
87
87
|
Object.defineProperty(exports, "getObjectTypeName", {
|
|
88
88
|
enumerable: true,
|
|
89
|
-
get: function () { return
|
|
89
|
+
get: function () { return chunkP76WWJIJ_cjs.getObjectTypeName; }
|
|
90
90
|
});
|
|
91
91
|
Object.defineProperty(exports, "registerFabricModule", {
|
|
92
92
|
enumerable: true,
|
|
93
|
-
get: function () { return
|
|
93
|
+
get: function () { return chunkP76WWJIJ_cjs.registerFabricModule; }
|
|
94
94
|
});
|
|
95
95
|
Object.defineProperty(exports, "registerFabricModules", {
|
|
96
96
|
enumerable: true,
|
|
97
|
-
get: function () { return
|
|
97
|
+
get: function () { return chunkP76WWJIJ_cjs.registerFabricModules; }
|
|
98
98
|
});
|
|
99
99
|
Object.defineProperty(exports, "validateModuleNamespace", {
|
|
100
100
|
enumerable: true,
|
|
101
|
-
get: function () { return
|
|
101
|
+
get: function () { return chunkP76WWJIJ_cjs.validateModuleNamespace; }
|
|
102
102
|
});
|
|
103
103
|
Object.defineProperty(exports, "assertObjectType", {
|
|
104
104
|
enumerable: true,
|
|
@@ -118,43 +118,43 @@ Object.defineProperty(exports, "registerObjectType", {
|
|
|
118
118
|
});
|
|
119
119
|
Object.defineProperty(exports, "aggregatePolicyOutcomes", {
|
|
120
120
|
enumerable: true,
|
|
121
|
-
get: function () { return
|
|
121
|
+
get: function () { return chunkDBZRPM72_cjs.aggregatePolicyOutcomes; }
|
|
122
122
|
});
|
|
123
123
|
Object.defineProperty(exports, "assertPolicyId", {
|
|
124
124
|
enumerable: true,
|
|
125
|
-
get: function () { return
|
|
125
|
+
get: function () { return chunkDBZRPM72_cjs.assertPolicyId; }
|
|
126
126
|
});
|
|
127
127
|
Object.defineProperty(exports, "evaluatePolicyDefinition", {
|
|
128
128
|
enumerable: true,
|
|
129
|
-
get: function () { return
|
|
129
|
+
get: function () { return chunkDBZRPM72_cjs.evaluatePolicyDefinition; }
|
|
130
130
|
});
|
|
131
131
|
Object.defineProperty(exports, "evaluatePolicyDefinitions", {
|
|
132
132
|
enumerable: true,
|
|
133
|
-
get: function () { return
|
|
133
|
+
get: function () { return chunkDBZRPM72_cjs.evaluatePolicyDefinitions; }
|
|
134
134
|
});
|
|
135
135
|
Object.defineProperty(exports, "evaluateRegisteredPolicies", {
|
|
136
136
|
enumerable: true,
|
|
137
|
-
get: function () { return
|
|
137
|
+
get: function () { return chunkDBZRPM72_cjs.evaluateRegisteredPolicies; }
|
|
138
138
|
});
|
|
139
139
|
Object.defineProperty(exports, "getRegisteredPolicyIds", {
|
|
140
140
|
enumerable: true,
|
|
141
|
-
get: function () { return
|
|
141
|
+
get: function () { return chunkDBZRPM72_cjs.getRegisteredPolicyIds; }
|
|
142
142
|
});
|
|
143
143
|
Object.defineProperty(exports, "registerPolicy", {
|
|
144
144
|
enumerable: true,
|
|
145
|
-
get: function () { return
|
|
145
|
+
get: function () { return chunkDBZRPM72_cjs.registerPolicy; }
|
|
146
146
|
});
|
|
147
147
|
Object.defineProperty(exports, "registerPolicyIfMissing", {
|
|
148
148
|
enumerable: true,
|
|
149
|
-
get: function () { return
|
|
149
|
+
get: function () { return chunkDBZRPM72_cjs.registerPolicyIfMissing; }
|
|
150
150
|
});
|
|
151
151
|
Object.defineProperty(exports, "resolvePolicy", {
|
|
152
152
|
enumerable: true,
|
|
153
|
-
get: function () { return
|
|
153
|
+
get: function () { return chunkDBZRPM72_cjs.resolvePolicy; }
|
|
154
154
|
});
|
|
155
155
|
Object.defineProperty(exports, "validateDataPolicyDefinition", {
|
|
156
156
|
enumerable: true,
|
|
157
|
-
get: function () { return
|
|
157
|
+
get: function () { return chunkDBZRPM72_cjs.validateDataPolicyDefinition; }
|
|
158
158
|
});
|
|
159
159
|
Object.defineProperty(exports, "getAllowedTransitions", {
|
|
160
160
|
enumerable: true,
|
package/dist/index.d.cts
CHANGED
|
@@ -4,7 +4,7 @@ export { AssetEventActorType, AssetEventEnvelope, AssetEventSubjectType, AssetEv
|
|
|
4
4
|
export { FABRIC_ID_PREFIXES, FabricIdPrefix, createFabricId, isFabricId, parseFabricId } from './ids/index.cjs';
|
|
5
5
|
export { EventTypeRegistration, EventTypeRegistrationInput, FabricModule, IdPrefixRegistration, ModuleDependency, ModuleDependencyInput, ModuleDisplayRendererRegistration, ModuleRegistry, ObjectTypeRegistration, ObjectTypeRegistrationInput, PolicyRegistration, StateMachineRegistration, createModuleRegistry, getEventTypeName, getModuleDependencyNamespace, getObjectTypeName, registerFabricModule, registerFabricModules, validateModuleNamespace } from './modules/index.cjs';
|
|
6
6
|
export { FabricObjectType, assertObjectType, getRegisteredObjectTypes, isValidObjectType, registerObjectType } from './objects/index.cjs';
|
|
7
|
-
export { DataPolicyComparisonOperator, DataPolicyCondition, DataPolicyConditionResult, DataPolicyDefinition, DataPolicyLiteral, DataPolicySource, DataPolicySourceReference, DataPolicyValidationResult, PolicyContext, PolicyDispatchEvidence, PolicyEvaluationMode, PolicyEvaluationResult, PolicyEvaluator, PolicyFallbackDefinition, PolicyFallbackTrigger, PolicyId, PolicyKind, PolicyOutcome, RuntimePolicyDefinition, aggregatePolicyOutcomes, assertPolicyId, evaluatePolicyDefinition, evaluatePolicyDefinitions, evaluateRegisteredPolicies, getRegisteredPolicyIds, registerPolicy, registerPolicyIfMissing, resolvePolicy, validateDataPolicyDefinition } from './policies/index.cjs';
|
|
7
|
+
export { DataPolicyComparisonOperator, DataPolicyCondition, DataPolicyConditionResult, DataPolicyDefinition, DataPolicyLiteral, DataPolicySource, DataPolicySourceReference, DataPolicyValidationResult, PolicyContext, PolicyCorrectiveAction, PolicyDispatchEvidence, PolicyEvaluationMode, PolicyEvaluationResult, PolicyEvaluator, PolicyFact, PolicyFallbackDefinition, PolicyFallbackTrigger, PolicyGuidance, PolicyId, PolicyKind, PolicyOutcome, RuntimePolicyDefinition, aggregatePolicyOutcomes, assertPolicyId, evaluatePolicyDefinition, evaluatePolicyDefinitions, evaluateRegisteredPolicies, getRegisteredPolicyIds, registerPolicy, registerPolicyIfMissing, resolvePolicy, validateDataPolicyDefinition } from './policies/index.cjs';
|
|
8
8
|
export { StateClass, StateDefinition, StateMachineDatabaseClient, StateMachineDefinition, TransitionContext, getAllowedTransitions, getEntityStateClass, registerStateMachine, registerStateMachineIfMissing, resolveStateMachine, validateTransition } from './state-machines/index.cjs';
|
|
9
9
|
export { ReplayEventsOptions, ReplayEventsResult, ReplayScope, ReplaySnapshot, ReplayWarning, ReplayWarningCode, ReplayableAssetEvent, replayEvents } from './projections/index.cjs';
|
|
10
10
|
export { CachedDisplayDescriptor, DisplayContext, DisplayDatabaseClient, DisplayDescriptor, DisplayRenderer, DisplayRendererRegistration, denormalizeDisplaySnapshot, registerDisplayRenderer, renderEventDisplay, resolveDisplayRenderer } from './displays/index.cjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export { AssetEventActorType, AssetEventEnvelope, AssetEventSubjectType, AssetEv
|
|
|
4
4
|
export { FABRIC_ID_PREFIXES, FabricIdPrefix, createFabricId, isFabricId, parseFabricId } from './ids/index.js';
|
|
5
5
|
export { EventTypeRegistration, EventTypeRegistrationInput, FabricModule, IdPrefixRegistration, ModuleDependency, ModuleDependencyInput, ModuleDisplayRendererRegistration, ModuleRegistry, ObjectTypeRegistration, ObjectTypeRegistrationInput, PolicyRegistration, StateMachineRegistration, createModuleRegistry, getEventTypeName, getModuleDependencyNamespace, getObjectTypeName, registerFabricModule, registerFabricModules, validateModuleNamespace } from './modules/index.js';
|
|
6
6
|
export { FabricObjectType, assertObjectType, getRegisteredObjectTypes, isValidObjectType, registerObjectType } from './objects/index.js';
|
|
7
|
-
export { DataPolicyComparisonOperator, DataPolicyCondition, DataPolicyConditionResult, DataPolicyDefinition, DataPolicyLiteral, DataPolicySource, DataPolicySourceReference, DataPolicyValidationResult, PolicyContext, PolicyDispatchEvidence, PolicyEvaluationMode, PolicyEvaluationResult, PolicyEvaluator, PolicyFallbackDefinition, PolicyFallbackTrigger, PolicyId, PolicyKind, PolicyOutcome, RuntimePolicyDefinition, aggregatePolicyOutcomes, assertPolicyId, evaluatePolicyDefinition, evaluatePolicyDefinitions, evaluateRegisteredPolicies, getRegisteredPolicyIds, registerPolicy, registerPolicyIfMissing, resolvePolicy, validateDataPolicyDefinition } from './policies/index.js';
|
|
7
|
+
export { DataPolicyComparisonOperator, DataPolicyCondition, DataPolicyConditionResult, DataPolicyDefinition, DataPolicyLiteral, DataPolicySource, DataPolicySourceReference, DataPolicyValidationResult, PolicyContext, PolicyCorrectiveAction, PolicyDispatchEvidence, PolicyEvaluationMode, PolicyEvaluationResult, PolicyEvaluator, PolicyFact, PolicyFallbackDefinition, PolicyFallbackTrigger, PolicyGuidance, PolicyId, PolicyKind, PolicyOutcome, RuntimePolicyDefinition, aggregatePolicyOutcomes, assertPolicyId, evaluatePolicyDefinition, evaluatePolicyDefinitions, evaluateRegisteredPolicies, getRegisteredPolicyIds, registerPolicy, registerPolicyIfMissing, resolvePolicy, validateDataPolicyDefinition } from './policies/index.js';
|
|
8
8
|
export { StateClass, StateDefinition, StateMachineDatabaseClient, StateMachineDefinition, TransitionContext, getAllowedTransitions, getEntityStateClass, registerStateMachine, registerStateMachineIfMissing, resolveStateMachine, validateTransition } from './state-machines/index.js';
|
|
9
9
|
export { ReplayEventsOptions, ReplayEventsResult, ReplayScope, ReplaySnapshot, ReplayWarning, ReplayWarningCode, ReplayableAssetEvent, replayEvents } from './projections/index.js';
|
|
10
10
|
export { CachedDisplayDescriptor, DisplayContext, DisplayDatabaseClient, DisplayDescriptor, DisplayRenderer, DisplayRendererRegistration, denormalizeDisplaySnapshot, registerDisplayRenderer, renderEventDisplay, resolveDisplayRenderer } from './displays/index.js';
|
package/dist/index.js
CHANGED
|
@@ -4,9 +4,9 @@ export { createDeterministicIdFactory, createFakeActionContext, createInMemoryAd
|
|
|
4
4
|
export { AdapterRegistry, MissingAdapterRegistrationError, executeWithAdapterRetry, getRetryDelayMs, resolveAdapterRetryPolicy } from './chunk-3ZW5USXF.js';
|
|
5
5
|
import './chunk-OZLZHISS.js';
|
|
6
6
|
export { FABRIC_ID_PREFIXES, createFabricId, isFabricId, parseFabricId } from './chunk-RALMUSOX.js';
|
|
7
|
-
export { createModuleRegistry, getEventTypeName, getModuleDependencyNamespace, getObjectTypeName, registerFabricModule, registerFabricModules, validateModuleNamespace } from './chunk-
|
|
7
|
+
export { createModuleRegistry, getEventTypeName, getModuleDependencyNamespace, getObjectTypeName, registerFabricModule, registerFabricModules, validateModuleNamespace } from './chunk-CSZXUX5V.js';
|
|
8
8
|
export { assertObjectType, getRegisteredObjectTypes, isValidObjectType, registerObjectType } from './chunk-I35B576X.js';
|
|
9
|
-
export { aggregatePolicyOutcomes, assertPolicyId, evaluatePolicyDefinition, evaluatePolicyDefinitions, evaluateRegisteredPolicies, getRegisteredPolicyIds, registerPolicy, registerPolicyIfMissing, resolvePolicy, validateDataPolicyDefinition } from './chunk-
|
|
9
|
+
export { aggregatePolicyOutcomes, assertPolicyId, evaluatePolicyDefinition, evaluatePolicyDefinitions, evaluateRegisteredPolicies, getRegisteredPolicyIds, registerPolicy, registerPolicyIfMissing, resolvePolicy, validateDataPolicyDefinition } from './chunk-I3BMSYDF.js';
|
|
10
10
|
export { getAllowedTransitions, getEntityStateClass, registerStateMachine, registerStateMachineIfMissing, resolveStateMachine, validateTransition } from './chunk-T2JLSZN6.js';
|
|
11
11
|
export { ACTOR_TYPES, assertActionId, assertActorType, getRegisteredActionIds, isActorType, isRegisteredActionId, registerAction, registerActionIfMissing, resolveAction, resolveRegisteredAction } from './chunk-BJYRMUN2.js';
|
|
12
12
|
export { denormalizeDisplaySnapshot, registerDisplayRenderer, renderEventDisplay, resolveDisplayRenderer } from './chunk-O5WVBQ7P.js';
|
package/dist/modules/index.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkP76WWJIJ_cjs = require('../chunk-P76WWJIJ.cjs');
|
|
4
4
|
require('../chunk-QETQGAXJ.cjs');
|
|
5
|
-
require('../chunk-
|
|
5
|
+
require('../chunk-DBZRPM72.cjs');
|
|
6
6
|
require('../chunk-UV252FLT.cjs');
|
|
7
7
|
require('../chunk-RMI3BIND.cjs');
|
|
8
8
|
require('../chunk-EO4VSB2O.cjs');
|
|
@@ -12,31 +12,31 @@ require('../chunk-JAXDEK5Z.cjs');
|
|
|
12
12
|
|
|
13
13
|
Object.defineProperty(exports, "createModuleRegistry", {
|
|
14
14
|
enumerable: true,
|
|
15
|
-
get: function () { return
|
|
15
|
+
get: function () { return chunkP76WWJIJ_cjs.createModuleRegistry; }
|
|
16
16
|
});
|
|
17
17
|
Object.defineProperty(exports, "getEventTypeName", {
|
|
18
18
|
enumerable: true,
|
|
19
|
-
get: function () { return
|
|
19
|
+
get: function () { return chunkP76WWJIJ_cjs.getEventTypeName; }
|
|
20
20
|
});
|
|
21
21
|
Object.defineProperty(exports, "getModuleDependencyNamespace", {
|
|
22
22
|
enumerable: true,
|
|
23
|
-
get: function () { return
|
|
23
|
+
get: function () { return chunkP76WWJIJ_cjs.getModuleDependencyNamespace; }
|
|
24
24
|
});
|
|
25
25
|
Object.defineProperty(exports, "getObjectTypeName", {
|
|
26
26
|
enumerable: true,
|
|
27
|
-
get: function () { return
|
|
27
|
+
get: function () { return chunkP76WWJIJ_cjs.getObjectTypeName; }
|
|
28
28
|
});
|
|
29
29
|
Object.defineProperty(exports, "registerFabricModule", {
|
|
30
30
|
enumerable: true,
|
|
31
|
-
get: function () { return
|
|
31
|
+
get: function () { return chunkP76WWJIJ_cjs.registerFabricModule; }
|
|
32
32
|
});
|
|
33
33
|
Object.defineProperty(exports, "registerFabricModules", {
|
|
34
34
|
enumerable: true,
|
|
35
|
-
get: function () { return
|
|
35
|
+
get: function () { return chunkP76WWJIJ_cjs.registerFabricModules; }
|
|
36
36
|
});
|
|
37
37
|
Object.defineProperty(exports, "validateModuleNamespace", {
|
|
38
38
|
enumerable: true,
|
|
39
|
-
get: function () { return
|
|
39
|
+
get: function () { return chunkP76WWJIJ_cjs.validateModuleNamespace; }
|
|
40
40
|
});
|
|
41
41
|
//# sourceMappingURL=index.cjs.map
|
|
42
42
|
//# sourceMappingURL=index.cjs.map
|
package/dist/modules/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { createModuleRegistry, getEventTypeName, getModuleDependencyNamespace, getObjectTypeName, registerFabricModule, registerFabricModules, validateModuleNamespace } from '../chunk-
|
|
1
|
+
export { createModuleRegistry, getEventTypeName, getModuleDependencyNamespace, getObjectTypeName, registerFabricModule, registerFabricModules, validateModuleNamespace } from '../chunk-CSZXUX5V.js';
|
|
2
2
|
import '../chunk-I35B576X.js';
|
|
3
|
-
import '../chunk-
|
|
3
|
+
import '../chunk-I3BMSYDF.js';
|
|
4
4
|
import '../chunk-T2JLSZN6.js';
|
|
5
5
|
import '../chunk-BJYRMUN2.js';
|
|
6
6
|
import '../chunk-O5WVBQ7P.js';
|
package/dist/policies/index.cjs
CHANGED
|
@@ -1,48 +1,48 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkDBZRPM72_cjs = require('../chunk-DBZRPM72.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
Object.defineProperty(exports, "aggregatePolicyOutcomes", {
|
|
8
8
|
enumerable: true,
|
|
9
|
-
get: function () { return
|
|
9
|
+
get: function () { return chunkDBZRPM72_cjs.aggregatePolicyOutcomes; }
|
|
10
10
|
});
|
|
11
11
|
Object.defineProperty(exports, "assertPolicyId", {
|
|
12
12
|
enumerable: true,
|
|
13
|
-
get: function () { return
|
|
13
|
+
get: function () { return chunkDBZRPM72_cjs.assertPolicyId; }
|
|
14
14
|
});
|
|
15
15
|
Object.defineProperty(exports, "evaluatePolicyDefinition", {
|
|
16
16
|
enumerable: true,
|
|
17
|
-
get: function () { return
|
|
17
|
+
get: function () { return chunkDBZRPM72_cjs.evaluatePolicyDefinition; }
|
|
18
18
|
});
|
|
19
19
|
Object.defineProperty(exports, "evaluatePolicyDefinitions", {
|
|
20
20
|
enumerable: true,
|
|
21
|
-
get: function () { return
|
|
21
|
+
get: function () { return chunkDBZRPM72_cjs.evaluatePolicyDefinitions; }
|
|
22
22
|
});
|
|
23
23
|
Object.defineProperty(exports, "evaluateRegisteredPolicies", {
|
|
24
24
|
enumerable: true,
|
|
25
|
-
get: function () { return
|
|
25
|
+
get: function () { return chunkDBZRPM72_cjs.evaluateRegisteredPolicies; }
|
|
26
26
|
});
|
|
27
27
|
Object.defineProperty(exports, "getRegisteredPolicyIds", {
|
|
28
28
|
enumerable: true,
|
|
29
|
-
get: function () { return
|
|
29
|
+
get: function () { return chunkDBZRPM72_cjs.getRegisteredPolicyIds; }
|
|
30
30
|
});
|
|
31
31
|
Object.defineProperty(exports, "registerPolicy", {
|
|
32
32
|
enumerable: true,
|
|
33
|
-
get: function () { return
|
|
33
|
+
get: function () { return chunkDBZRPM72_cjs.registerPolicy; }
|
|
34
34
|
});
|
|
35
35
|
Object.defineProperty(exports, "registerPolicyIfMissing", {
|
|
36
36
|
enumerable: true,
|
|
37
|
-
get: function () { return
|
|
37
|
+
get: function () { return chunkDBZRPM72_cjs.registerPolicyIfMissing; }
|
|
38
38
|
});
|
|
39
39
|
Object.defineProperty(exports, "resolvePolicy", {
|
|
40
40
|
enumerable: true,
|
|
41
|
-
get: function () { return
|
|
41
|
+
get: function () { return chunkDBZRPM72_cjs.resolvePolicy; }
|
|
42
42
|
});
|
|
43
43
|
Object.defineProperty(exports, "validateDataPolicyDefinition", {
|
|
44
44
|
enumerable: true,
|
|
45
|
-
get: function () { return
|
|
45
|
+
get: function () { return chunkDBZRPM72_cjs.validateDataPolicyDefinition; }
|
|
46
46
|
});
|
|
47
47
|
//# sourceMappingURL=index.cjs.map
|
|
48
48
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { FabricRuntimeServices } from '../actions/index.cjs';
|
|
2
|
+
|
|
1
3
|
type PolicyEvaluationResult = "pass" | "warn" | "block";
|
|
2
4
|
type PolicyKind = "code" | "data" | "hybrid";
|
|
3
5
|
type PolicyId = `${string}.v${number}`;
|
|
@@ -12,6 +14,36 @@ interface PolicyContext<TDb = unknown> {
|
|
|
12
14
|
db: TDb;
|
|
13
15
|
now?: Date;
|
|
14
16
|
mode?: PolicyEvaluationMode;
|
|
17
|
+
/**
|
|
18
|
+
* Optional runtime services bag, mirroring {@link FabricRuntimeServices} on
|
|
19
|
+
* `ActionContext`. Lets the host inject dependencies (HTTP clients, secret
|
|
20
|
+
* managers, external policy engines such as OPA, feature flags, etc.) that
|
|
21
|
+
* a code policy evaluator may need without resorting to module-level
|
|
22
|
+
* globals. The shape is opaque to the platform — adapters narrow it.
|
|
23
|
+
*/
|
|
24
|
+
services?: FabricRuntimeServices;
|
|
25
|
+
}
|
|
26
|
+
interface PolicyFact {
|
|
27
|
+
name: string;
|
|
28
|
+
value: unknown;
|
|
29
|
+
label?: string;
|
|
30
|
+
}
|
|
31
|
+
interface PolicyCorrectiveAction {
|
|
32
|
+
label: string;
|
|
33
|
+
description?: string;
|
|
34
|
+
actionId?: string;
|
|
35
|
+
parameters?: Record<string, unknown>;
|
|
36
|
+
target?: {
|
|
37
|
+
surface?: string;
|
|
38
|
+
tab?: string;
|
|
39
|
+
field?: string;
|
|
40
|
+
};
|
|
41
|
+
requiresConfirmation?: boolean;
|
|
42
|
+
}
|
|
43
|
+
interface PolicyGuidance {
|
|
44
|
+
summary?: string;
|
|
45
|
+
factsUsed: PolicyFact[];
|
|
46
|
+
correctiveActions: PolicyCorrectiveAction[];
|
|
15
47
|
}
|
|
16
48
|
interface PolicyOutcome {
|
|
17
49
|
policyId: PolicyId;
|
|
@@ -19,6 +51,7 @@ interface PolicyOutcome {
|
|
|
19
51
|
policyKind?: PolicyKind;
|
|
20
52
|
result: PolicyEvaluationResult;
|
|
21
53
|
reason?: string;
|
|
54
|
+
guidance?: PolicyGuidance;
|
|
22
55
|
metadata?: Record<string, unknown>;
|
|
23
56
|
dispatchEvidence?: PolicyDispatchEvidence;
|
|
24
57
|
}
|
|
@@ -120,6 +153,8 @@ interface PolicyDispatchEvidence {
|
|
|
120
153
|
policyId: PolicyId;
|
|
121
154
|
version?: number;
|
|
122
155
|
registered: boolean;
|
|
156
|
+
skipped?: boolean;
|
|
157
|
+
skipReason?: string;
|
|
123
158
|
};
|
|
124
159
|
fallback?: {
|
|
125
160
|
used: boolean;
|
|
@@ -129,6 +164,20 @@ interface PolicyDispatchEvidence {
|
|
|
129
164
|
definitionVersion: number;
|
|
130
165
|
codeEvaluatorPolicyId: PolicyId;
|
|
131
166
|
};
|
|
167
|
+
/**
|
|
168
|
+
* Provenance for the engine that produced this decision when a code
|
|
169
|
+
* evaluator delegates to an external policy engine (OPA, Cedar, Cerbos,
|
|
170
|
+
* Topaz, etc.). Fabric's `policyId` / `policyVersion` remain canonical for
|
|
171
|
+
* audit; this block carries deployment provenance (decision path, bundle
|
|
172
|
+
* revision, decision ID, input hash). Adapters populate it; the platform
|
|
173
|
+
* keeps `metadata` open-ended so engine-specific typing can live in the
|
|
174
|
+
* adapter package.
|
|
175
|
+
*/
|
|
176
|
+
engine?: {
|
|
177
|
+
name: string;
|
|
178
|
+
version?: string;
|
|
179
|
+
metadata?: Record<string, unknown>;
|
|
180
|
+
};
|
|
132
181
|
}
|
|
133
182
|
declare function registerPolicy(evaluator: PolicyEvaluator): void;
|
|
134
183
|
declare function registerPolicyIfMissing(evaluator: PolicyEvaluator): void;
|
|
@@ -140,4 +189,4 @@ declare function evaluatePolicyDefinition(policy: RuntimePolicyDefinition, ctx:
|
|
|
140
189
|
declare function validateDataPolicyDefinition(definition: DataPolicyDefinition): DataPolicyValidationResult;
|
|
141
190
|
declare function aggregatePolicyOutcomes(outcomes: PolicyOutcome[]): PolicyOutcome | undefined;
|
|
142
191
|
|
|
143
|
-
export { type DataPolicyComparisonOperator, type DataPolicyCondition, type DataPolicyConditionResult, type DataPolicyDefinition, type DataPolicyLiteral, type DataPolicySource, type DataPolicySourceReference, type DataPolicyValidationResult, type PolicyContext, type PolicyDispatchEvidence, type PolicyEvaluationMode, type PolicyEvaluationResult, type PolicyEvaluator, type PolicyFallbackDefinition, type PolicyFallbackTrigger, type PolicyId, type PolicyKind, type PolicyOutcome, type RuntimePolicyDefinition, aggregatePolicyOutcomes, assertPolicyId, evaluatePolicyDefinition, evaluatePolicyDefinitions, evaluateRegisteredPolicies, getRegisteredPolicyIds, registerPolicy, registerPolicyIfMissing, resolvePolicy, validateDataPolicyDefinition };
|
|
192
|
+
export { type DataPolicyComparisonOperator, type DataPolicyCondition, type DataPolicyConditionResult, type DataPolicyDefinition, type DataPolicyLiteral, type DataPolicySource, type DataPolicySourceReference, type DataPolicyValidationResult, type PolicyContext, type PolicyCorrectiveAction, type PolicyDispatchEvidence, type PolicyEvaluationMode, type PolicyEvaluationResult, type PolicyEvaluator, type PolicyFact, type PolicyFallbackDefinition, type PolicyFallbackTrigger, type PolicyGuidance, type PolicyId, type PolicyKind, type PolicyOutcome, type RuntimePolicyDefinition, aggregatePolicyOutcomes, assertPolicyId, evaluatePolicyDefinition, evaluatePolicyDefinitions, evaluateRegisteredPolicies, getRegisteredPolicyIds, registerPolicy, registerPolicyIfMissing, resolvePolicy, validateDataPolicyDefinition };
|
package/dist/policies/index.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { FabricRuntimeServices } from '../actions/index.js';
|
|
2
|
+
|
|
1
3
|
type PolicyEvaluationResult = "pass" | "warn" | "block";
|
|
2
4
|
type PolicyKind = "code" | "data" | "hybrid";
|
|
3
5
|
type PolicyId = `${string}.v${number}`;
|
|
@@ -12,6 +14,36 @@ interface PolicyContext<TDb = unknown> {
|
|
|
12
14
|
db: TDb;
|
|
13
15
|
now?: Date;
|
|
14
16
|
mode?: PolicyEvaluationMode;
|
|
17
|
+
/**
|
|
18
|
+
* Optional runtime services bag, mirroring {@link FabricRuntimeServices} on
|
|
19
|
+
* `ActionContext`. Lets the host inject dependencies (HTTP clients, secret
|
|
20
|
+
* managers, external policy engines such as OPA, feature flags, etc.) that
|
|
21
|
+
* a code policy evaluator may need without resorting to module-level
|
|
22
|
+
* globals. The shape is opaque to the platform — adapters narrow it.
|
|
23
|
+
*/
|
|
24
|
+
services?: FabricRuntimeServices;
|
|
25
|
+
}
|
|
26
|
+
interface PolicyFact {
|
|
27
|
+
name: string;
|
|
28
|
+
value: unknown;
|
|
29
|
+
label?: string;
|
|
30
|
+
}
|
|
31
|
+
interface PolicyCorrectiveAction {
|
|
32
|
+
label: string;
|
|
33
|
+
description?: string;
|
|
34
|
+
actionId?: string;
|
|
35
|
+
parameters?: Record<string, unknown>;
|
|
36
|
+
target?: {
|
|
37
|
+
surface?: string;
|
|
38
|
+
tab?: string;
|
|
39
|
+
field?: string;
|
|
40
|
+
};
|
|
41
|
+
requiresConfirmation?: boolean;
|
|
42
|
+
}
|
|
43
|
+
interface PolicyGuidance {
|
|
44
|
+
summary?: string;
|
|
45
|
+
factsUsed: PolicyFact[];
|
|
46
|
+
correctiveActions: PolicyCorrectiveAction[];
|
|
15
47
|
}
|
|
16
48
|
interface PolicyOutcome {
|
|
17
49
|
policyId: PolicyId;
|
|
@@ -19,6 +51,7 @@ interface PolicyOutcome {
|
|
|
19
51
|
policyKind?: PolicyKind;
|
|
20
52
|
result: PolicyEvaluationResult;
|
|
21
53
|
reason?: string;
|
|
54
|
+
guidance?: PolicyGuidance;
|
|
22
55
|
metadata?: Record<string, unknown>;
|
|
23
56
|
dispatchEvidence?: PolicyDispatchEvidence;
|
|
24
57
|
}
|
|
@@ -120,6 +153,8 @@ interface PolicyDispatchEvidence {
|
|
|
120
153
|
policyId: PolicyId;
|
|
121
154
|
version?: number;
|
|
122
155
|
registered: boolean;
|
|
156
|
+
skipped?: boolean;
|
|
157
|
+
skipReason?: string;
|
|
123
158
|
};
|
|
124
159
|
fallback?: {
|
|
125
160
|
used: boolean;
|
|
@@ -129,6 +164,20 @@ interface PolicyDispatchEvidence {
|
|
|
129
164
|
definitionVersion: number;
|
|
130
165
|
codeEvaluatorPolicyId: PolicyId;
|
|
131
166
|
};
|
|
167
|
+
/**
|
|
168
|
+
* Provenance for the engine that produced this decision when a code
|
|
169
|
+
* evaluator delegates to an external policy engine (OPA, Cedar, Cerbos,
|
|
170
|
+
* Topaz, etc.). Fabric's `policyId` / `policyVersion` remain canonical for
|
|
171
|
+
* audit; this block carries deployment provenance (decision path, bundle
|
|
172
|
+
* revision, decision ID, input hash). Adapters populate it; the platform
|
|
173
|
+
* keeps `metadata` open-ended so engine-specific typing can live in the
|
|
174
|
+
* adapter package.
|
|
175
|
+
*/
|
|
176
|
+
engine?: {
|
|
177
|
+
name: string;
|
|
178
|
+
version?: string;
|
|
179
|
+
metadata?: Record<string, unknown>;
|
|
180
|
+
};
|
|
132
181
|
}
|
|
133
182
|
declare function registerPolicy(evaluator: PolicyEvaluator): void;
|
|
134
183
|
declare function registerPolicyIfMissing(evaluator: PolicyEvaluator): void;
|
|
@@ -140,4 +189,4 @@ declare function evaluatePolicyDefinition(policy: RuntimePolicyDefinition, ctx:
|
|
|
140
189
|
declare function validateDataPolicyDefinition(definition: DataPolicyDefinition): DataPolicyValidationResult;
|
|
141
190
|
declare function aggregatePolicyOutcomes(outcomes: PolicyOutcome[]): PolicyOutcome | undefined;
|
|
142
191
|
|
|
143
|
-
export { type DataPolicyComparisonOperator, type DataPolicyCondition, type DataPolicyConditionResult, type DataPolicyDefinition, type DataPolicyLiteral, type DataPolicySource, type DataPolicySourceReference, type DataPolicyValidationResult, type PolicyContext, type PolicyDispatchEvidence, type PolicyEvaluationMode, type PolicyEvaluationResult, type PolicyEvaluator, type PolicyFallbackDefinition, type PolicyFallbackTrigger, type PolicyId, type PolicyKind, type PolicyOutcome, type RuntimePolicyDefinition, aggregatePolicyOutcomes, assertPolicyId, evaluatePolicyDefinition, evaluatePolicyDefinitions, evaluateRegisteredPolicies, getRegisteredPolicyIds, registerPolicy, registerPolicyIfMissing, resolvePolicy, validateDataPolicyDefinition };
|
|
192
|
+
export { type DataPolicyComparisonOperator, type DataPolicyCondition, type DataPolicyConditionResult, type DataPolicyDefinition, type DataPolicyLiteral, type DataPolicySource, type DataPolicySourceReference, type DataPolicyValidationResult, type PolicyContext, type PolicyCorrectiveAction, type PolicyDispatchEvidence, type PolicyEvaluationMode, type PolicyEvaluationResult, type PolicyEvaluator, type PolicyFact, type PolicyFallbackDefinition, type PolicyFallbackTrigger, type PolicyGuidance, type PolicyId, type PolicyKind, type PolicyOutcome, type RuntimePolicyDefinition, aggregatePolicyOutcomes, assertPolicyId, evaluatePolicyDefinition, evaluatePolicyDefinitions, evaluateRegisteredPolicies, getRegisteredPolicyIds, registerPolicy, registerPolicyIfMissing, resolvePolicy, validateDataPolicyDefinition };
|
package/dist/policies/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { aggregatePolicyOutcomes, assertPolicyId, evaluatePolicyDefinition, evaluatePolicyDefinitions, evaluateRegisteredPolicies, getRegisteredPolicyIds, registerPolicy, registerPolicyIfMissing, resolvePolicy, validateDataPolicyDefinition } from '../chunk-
|
|
1
|
+
export { aggregatePolicyOutcomes, assertPolicyId, evaluatePolicyDefinition, evaluatePolicyDefinitions, evaluateRegisteredPolicies, getRegisteredPolicyIds, registerPolicy, registerPolicyIfMissing, resolvePolicy, validateDataPolicyDefinition } from '../chunk-I3BMSYDF.js';
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
3
3
|
//# sourceMappingURL=index.js.map
|