@lucern/sdk 0.2.0-alpha.6 → 0.2.0-alpha.8
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 +13 -0
- package/dist/{lib/platform/sdk/adminClient.d.ts → adminClient.d.ts} +56 -51
- package/dist/adminClient.js +755 -0
- package/dist/adminClient.js.map +1 -0
- package/dist/answersClient.d.ts +23 -0
- package/dist/answersClient.js +333 -0
- package/dist/answersClient.js.map +1 -0
- package/dist/{lib/platform/sdk/audiencesClient.d.ts → audiencesClient.d.ts} +24 -18
- package/dist/audiencesClient.js +472 -0
- package/dist/audiencesClient.js.map +1 -0
- package/dist/auditClient.d.ts +29 -0
- package/dist/auditClient.js +386 -0
- package/dist/auditClient.js.map +1 -0
- package/dist/{lib/platform/sdk/beliefsClient.d.ts → beliefsClient.d.ts} +32 -27
- package/dist/beliefsClient.js +477 -0
- package/dist/beliefsClient.js.map +1 -0
- package/dist/{lib/platform/sdk/client.d.ts → client.d.ts} +404 -395
- package/dist/client.js +6134 -0
- package/dist/client.js.map +1 -0
- package/dist/{lib/platform/sdk/contextClient.d.ts → contextClient.d.ts} +13 -7
- package/dist/contextClient.js +396 -0
- package/dist/contextClient.js.map +1 -0
- package/dist/contextFacade.d.ts +2 -0
- package/dist/contextFacade.js +73 -0
- package/dist/contextFacade.js.map +1 -0
- package/dist/{lib/platform/sdk/contextPackCompiler.d.ts → contextPackCompiler.d.ts} +11 -9
- package/dist/contextPackCompiler.js +1091 -0
- package/dist/contextPackCompiler.js.map +1 -0
- package/dist/contextPackPolicy.d.ts +84 -0
- package/dist/contextPackPolicy.js +347 -0
- package/dist/contextPackPolicy.js.map +1 -0
- package/dist/contextPackSchema.d.ts +7 -0
- package/dist/contextPackSchema.js +203 -0
- package/dist/contextPackSchema.js.map +1 -0
- package/dist/{lib/platform/sdk/contextTypes.d.ts → contextTypes.d.ts} +15 -13
- package/dist/contextTypes.js +3 -0
- package/dist/contextTypes.js.map +1 -0
- package/dist/contracts/api-enums.contract.d.ts +81 -0
- package/dist/contracts/api-enums.contract.js +92 -0
- package/dist/contracts/api-enums.contract.js.map +1 -0
- package/dist/contracts/auth-session.contract.d.ts +55 -0
- package/dist/contracts/auth-session.contract.js +48 -0
- package/dist/contracts/auth-session.contract.js.map +1 -0
- package/dist/{lucern/contracts/src → contracts}/context-pack.contract.d.ts +56 -58
- package/dist/contracts/context-pack.contract.js +98 -0
- package/dist/contracts/context-pack.contract.js.map +1 -0
- package/dist/contracts/contextPack.d.ts +1 -0
- package/dist/contracts/contextPack.js +98 -0
- package/dist/contracts/contextPack.js.map +1 -0
- package/dist/contracts/index.d.ts +9 -0
- package/dist/contracts/index.js +4892 -0
- package/dist/contracts/index.js.map +1 -0
- package/dist/{lucern/contracts/src → contracts}/lens-filter.contract.d.ts +10 -8
- package/dist/contracts/lens-filter.contract.js +71 -0
- package/dist/contracts/lens-filter.contract.js.map +1 -0
- package/dist/contracts/lens-workflow.contract.d.ts +87 -0
- package/dist/contracts/lens-workflow.contract.js +123 -0
- package/dist/contracts/lens-workflow.contract.js.map +1 -0
- package/dist/contracts/lensFilter.d.ts +1 -0
- package/dist/contracts/lensFilter.js +71 -0
- package/dist/contracts/lensFilter.js.map +1 -0
- package/dist/contracts/lensWorkflow.d.ts +2 -0
- package/dist/contracts/lensWorkflow.js +123 -0
- package/dist/contracts/lensWorkflow.js.map +1 -0
- package/dist/contracts/mcp-tools.contract.d.ts +1 -0
- package/dist/contracts/mcp-tools.contract.js +2986 -0
- package/dist/contracts/mcp-tools.contract.js.map +1 -0
- package/dist/contracts/mcpTools.d.ts +1 -0
- package/dist/contracts/mcpTools.js +2986 -0
- package/dist/contracts/mcpTools.js.map +1 -0
- package/dist/{lucern/contracts/src → contracts}/prompt.contract.d.ts +5 -3
- package/dist/contracts/prompt.contract.js +12 -0
- package/dist/contracts/prompt.contract.js.map +1 -0
- package/dist/contracts/prompt.d.ts +1 -0
- package/dist/contracts/prompt.js +12 -0
- package/dist/contracts/prompt.js.map +1 -0
- package/dist/contracts/sdk-tools.contract.d.ts +2 -0
- package/dist/contracts/sdk-tools.contract.js +4134 -0
- package/dist/contracts/sdk-tools.contract.js.map +1 -0
- package/dist/contracts/sdkTools.d.ts +2 -0
- package/dist/contracts/sdkTools.js +4134 -0
- package/dist/contracts/sdkTools.js.map +1 -0
- package/dist/contracts/workflow-runtime.contract.d.ts +163 -0
- package/dist/contracts/workflow-runtime.contract.js +245 -0
- package/dist/contracts/workflow-runtime.contract.js.map +1 -0
- package/dist/contracts/workflowRuntime.d.ts +1 -0
- package/dist/contracts/workflowRuntime.js +245 -0
- package/dist/contracts/workflowRuntime.js.map +1 -0
- package/dist/{lib/platform/sdk/controlObjectOwnership.d.ts → controlObjectOwnership.d.ts} +20 -18
- package/dist/controlObjectOwnership.js +215 -0
- package/dist/controlObjectOwnership.js.map +1 -0
- package/dist/{lib/platform/sdk/coreClient.d.ts → coreClient.d.ts} +19 -14
- package/dist/coreClient.js +339 -0
- package/dist/coreClient.js.map +1 -0
- package/dist/{lib/platform/sdk/customTools.d.ts → customTools.d.ts} +21 -16
- package/dist/customTools.js +248 -0
- package/dist/customTools.js.map +1 -0
- package/dist/{lib/platform/sdk/decisionsClient.d.ts → decisionsClient.d.ts} +29 -24
- package/dist/decisionsClient.js +522 -0
- package/dist/decisionsClient.js.map +1 -0
- package/dist/domainContext.d.ts +1 -0
- package/dist/domainContext.js +3 -0
- package/dist/domainContext.js.map +1 -0
- package/dist/events.d.ts +178 -0
- package/dist/events.js +249 -0
- package/dist/events.js.map +1 -0
- package/dist/eventsCore.d.ts +49 -0
- package/dist/eventsCore.js +429 -0
- package/dist/eventsCore.js.map +1 -0
- package/dist/facade/context.d.ts +18 -0
- package/dist/facade/context.js +73 -0
- package/dist/facade/context.js.map +1 -0
- package/dist/{lib/platform/sdk/gatewayFacades.d.ts → gatewayFacades.d.ts} +31 -26
- package/dist/gatewayFacades.js +1953 -0
- package/dist/gatewayFacades.js.map +1 -0
- package/dist/{lib/platform/sdk/graphClient.d.ts → graphClient.d.ts} +57 -52
- package/dist/graphClient.js +698 -0
- package/dist/graphClient.js.map +1 -0
- package/dist/{lib/platform/sdk/harnessClient.d.ts → harnessClient.d.ts} +44 -39
- package/dist/harnessClient.js +607 -0
- package/dist/harnessClient.js.map +1 -0
- package/dist/{lib/platform/sdk/identityClient.d.ts → identityClient.d.ts} +17 -11
- package/dist/identityClient.js +497 -0
- package/dist/identityClient.js.map +1 -0
- package/dist/index.d.ts +42 -3
- package/dist/index.js +11381 -3
- package/dist/index.js.map +1 -0
- package/dist/{lib/platform/sdk/learningClient.d.ts → learningClient.d.ts} +13 -7
- package/dist/learningClient.js +409 -0
- package/dist/learningClient.js.map +1 -0
- package/dist/{lib/platform/sdk/mcpParityClient.d.ts → mcpParityClient.d.ts} +10 -5
- package/dist/mcpParityClient.js +516 -0
- package/dist/mcpParityClient.js.map +1 -0
- package/dist/mcpParitySurface.d.ts +12 -0
- package/dist/mcpParitySurface.js +65 -0
- package/dist/mcpParitySurface.js.map +1 -0
- package/dist/mcpTools-DPZxowDX.d.ts +254 -0
- package/dist/{lib/platform/sdk/ontologyClient.d.ts → ontologyClient.d.ts} +28 -22
- package/dist/ontologyClient.js +513 -0
- package/dist/ontologyClient.js.map +1 -0
- package/dist/packRuntime.d.ts +2 -0
- package/dist/packRuntime.js +3 -0
- package/dist/packRuntime.js.map +1 -0
- package/dist/{lib/platform/sdk/packsClient.d.ts → packsClient.d.ts} +34 -29
- package/dist/packsClient.js +525 -0
- package/dist/packsClient.js.map +1 -0
- package/dist/{lib/platform/sdk/policyClient.d.ts → policyClient.d.ts} +26 -20
- package/dist/policyClient.js +625 -0
- package/dist/policyClient.js.map +1 -0
- package/dist/realtime/index.d.ts +29 -0
- package/dist/realtime/index.js +23 -0
- package/dist/realtime/index.js.map +1 -0
- package/dist/realtime/refs.d.ts +17 -0
- package/dist/realtime/refs.js +9 -0
- package/dist/realtime/refs.js.map +1 -0
- package/dist/reportsClient.d.ts +41 -0
- package/dist/reportsClient.js +418 -0
- package/dist/reportsClient.js.map +1 -0
- package/dist/{lib/platform/sdk/schemaClient.d.ts → schemaClient.d.ts} +20 -15
- package/dist/schemaClient.js +434 -0
- package/dist/schemaClient.js.map +1 -0
- package/dist/sdkSurface.d.ts +61 -0
- package/dist/sdkSurface.js +112 -0
- package/dist/sdkSurface.js.map +1 -0
- package/dist/sdkTools-CwXJDACb.d.ts +150 -0
- package/dist/{lib/platform/sdk/topicsClient.d.ts → topicsClient.d.ts} +24 -18
- package/dist/topicsClient.js +492 -0
- package/dist/topicsClient.js.map +1 -0
- package/dist/{lib/platform/sdk/types.d.ts → types.d.ts} +84 -80
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/dist/version.d.ts +4 -0
- package/dist/version.js +6 -0
- package/dist/version.js.map +1 -0
- package/dist/{lib/platform/sdk/workflowClient.d.ts → workflowClient.d.ts} +60 -57
- package/dist/workflowClient.js +830 -0
- package/dist/workflowClient.js.map +1 -0
- package/package.json +25 -43
- package/dist/.generated +0 -2
- package/dist/lib/platform/auth/credentials.d.ts +0 -5
- package/dist/lib/platform/auth/credentials.js +0 -40
- package/dist/lib/platform/sdk/adminClient.js +0 -384
- package/dist/lib/platform/sdk/answersClient.d.ts +0 -16
- package/dist/lib/platform/sdk/answersClient.js +0 -21
- package/dist/lib/platform/sdk/audiencesClient.js +0 -111
- package/dist/lib/platform/sdk/auditClient.d.ts +0 -24
- package/dist/lib/platform/sdk/auditClient.js +0 -21
- package/dist/lib/platform/sdk/beliefsClient.js +0 -124
- package/dist/lib/platform/sdk/client.js +0 -1831
- package/dist/lib/platform/sdk/contextClient.js +0 -86
- package/dist/lib/platform/sdk/contextFacade.d.ts +0 -10
- package/dist/lib/platform/sdk/contextFacade.js +0 -10
- package/dist/lib/platform/sdk/contextPackCompiler.js +0 -534
- package/dist/lib/platform/sdk/contextTypes.js +0 -1
- package/dist/lib/platform/sdk/controlObjectOwnership.js +0 -220
- package/dist/lib/platform/sdk/coreClient.js +0 -366
- package/dist/lib/platform/sdk/customTools.js +0 -247
- package/dist/lib/platform/sdk/decisionsClient.js +0 -129
- package/dist/lib/platform/sdk/domainContext.d.ts +0 -1
- package/dist/lib/platform/sdk/domainContext.js +0 -1
- package/dist/lib/platform/sdk/events.d.ts +0 -176
- package/dist/lib/platform/sdk/events.js +0 -261
- package/dist/lib/platform/sdk/eventsCore.d.ts +0 -13
- package/dist/lib/platform/sdk/eventsCore.js +0 -13
- package/dist/lib/platform/sdk/gatewayFacades.js +0 -845
- package/dist/lib/platform/sdk/graphClient.js +0 -235
- package/dist/lib/platform/sdk/harnessClient.js +0 -219
- package/dist/lib/platform/sdk/identityClient.js +0 -131
- package/dist/lib/platform/sdk/index.d.ts +0 -49
- package/dist/lib/platform/sdk/index.js +0 -49
- package/dist/lib/platform/sdk/learningClient.js +0 -53
- package/dist/lib/platform/sdk/mcpParityClient.js +0 -196
- package/dist/lib/platform/sdk/mcpParitySurface.d.ts +0 -10
- package/dist/lib/platform/sdk/mcpParitySurface.js +0 -57
- package/dist/lib/platform/sdk/ontologyClient.js +0 -161
- package/dist/lib/platform/sdk/packRuntime.d.ts +0 -1
- package/dist/lib/platform/sdk/packRuntime.js +0 -1
- package/dist/lib/platform/sdk/packsClient.js +0 -157
- package/dist/lib/platform/sdk/policyClient.js +0 -277
- package/dist/lib/platform/sdk/promptCatalog.d.ts +0 -1
- package/dist/lib/platform/sdk/promptCatalog.js +0 -1
- package/dist/lib/platform/sdk/reportsClient.d.ts +0 -34
- package/dist/lib/platform/sdk/reportsClient.js +0 -64
- package/dist/lib/platform/sdk/schemaClient.js +0 -71
- package/dist/lib/platform/sdk/sdkSurface.d.ts +0 -56
- package/dist/lib/platform/sdk/sdkSurface.js +0 -140
- package/dist/lib/platform/sdk/topicsClient.js +0 -118
- package/dist/lib/platform/sdk/types.js +0 -1
- package/dist/lib/platform/sdk/version.d.ts +0 -2
- package/dist/lib/platform/sdk/version.js +0 -2
- package/dist/lib/platform/sdk/workflowClient.js +0 -366
- package/dist/lucern/contracts/src/api-enums.contract.d.ts +0 -58
- package/dist/lucern/contracts/src/api-enums.contract.js +0 -147
- package/dist/lucern/contracts/src/auth-context.contract.d.ts +0 -8
- package/dist/lucern/contracts/src/auth-context.contract.js +0 -8
- package/dist/lucern/contracts/src/auth-session.contract.d.ts +0 -8
- package/dist/lucern/contracts/src/auth-session.contract.js +0 -8
- package/dist/lucern/contracts/src/auth.contract.d.ts +0 -88
- package/dist/lucern/contracts/src/auth.contract.js +0 -57
- package/dist/lucern/contracts/src/context-pack.contract.js +0 -169
- package/dist/lucern/contracts/src/convex-admin.contract.d.ts +0 -5
- package/dist/lucern/contracts/src/convex-admin.contract.js +0 -1
- package/dist/lucern/contracts/src/events-types.contract.d.ts +0 -8
- package/dist/lucern/contracts/src/events-types.contract.js +0 -8
- package/dist/lucern/contracts/src/events.contract.d.ts +0 -176
- package/dist/lucern/contracts/src/events.contract.js +0 -159
- package/dist/lucern/contracts/src/gateway.contract.d.ts +0 -74
- package/dist/lucern/contracts/src/gateway.contract.js +0 -19
- package/dist/lucern/contracts/src/ids.contract.d.ts +0 -7
- package/dist/lucern/contracts/src/ids.contract.js +0 -24
- package/dist/lucern/contracts/src/index.d.ts +0 -29
- package/dist/lucern/contracts/src/index.js +0 -29
- package/dist/lucern/contracts/src/lens-filter.contract.js +0 -95
- package/dist/lucern/contracts/src/lens-workflow.contract.d.ts +0 -84
- package/dist/lucern/contracts/src/lens-workflow.contract.js +0 -54
- package/dist/lucern/contracts/src/mcp-tools.contract.d.ts +0 -151
- package/dist/lucern/contracts/src/mcp-tools.contract.js +0 -3281
- package/dist/lucern/contracts/src/ontology-matching.contract.d.ts +0 -8
- package/dist/lucern/contracts/src/ontology-matching.contract.js +0 -8
- package/dist/lucern/contracts/src/prompt.contract.js +0 -24
- package/dist/lucern/contracts/src/sdk-methods.contract.d.ts +0 -358
- package/dist/lucern/contracts/src/sdk-methods.contract.js +0 -19
- package/dist/lucern/contracts/src/sdk-tools.contract.d.ts +0 -92
- package/dist/lucern/contracts/src/sdk-tools.contract.js +0 -1398
- package/dist/lucern/contracts/src/text-matching.contract.d.ts +0 -53
- package/dist/lucern/contracts/src/text-matching.contract.js +0 -277
- package/dist/lucern/contracts/src/topic-scope.contract.d.ts +0 -8
- package/dist/lucern/contracts/src/topic-scope.contract.js +0 -8
- package/dist/lucern/contracts/src/workflow-runtime.contract.d.ts +0 -161
- package/dist/lucern/contracts/src/workflow-runtime.contract.js +0 -257
- package/dist/realtime-refs.d.ts +0 -1
- package/dist/realtime-refs.js +0 -1
- package/dist/realtime.d.ts +0 -1
- package/dist/realtime.js +0 -1
|
@@ -1,220 +0,0 @@
|
|
|
1
|
-
/** All recognized control object kinds in the ownership model. */
|
|
2
|
-
export const CONTROL_OBJECT_KINDS = [
|
|
3
|
-
"tenant",
|
|
4
|
-
"workspace",
|
|
5
|
-
"principal",
|
|
6
|
-
"tool",
|
|
7
|
-
"pack",
|
|
8
|
-
"ontology",
|
|
9
|
-
"belief",
|
|
10
|
-
"policy_rule",
|
|
11
|
-
];
|
|
12
|
-
/** Canonical ownership scopes: platform, tenant, workspace, or resource. */
|
|
13
|
-
export const CONTROL_OBJECT_OWNER_SCOPES = [
|
|
14
|
-
"platform",
|
|
15
|
-
"tenant",
|
|
16
|
-
"workspace",
|
|
17
|
-
"resource",
|
|
18
|
-
];
|
|
19
|
-
/** UI surfaces authorized to edit control objects. */
|
|
20
|
-
export const CONTROL_OBJECT_EDIT_SURFACES = [
|
|
21
|
-
"platform_admin",
|
|
22
|
-
"tenant_admin",
|
|
23
|
-
"workspace_admin",
|
|
24
|
-
"graph_worktree",
|
|
25
|
-
];
|
|
26
|
-
/** Rules governing how control object configuration flows through the scope hierarchy. */
|
|
27
|
-
export const CONTROL_OBJECT_INHERITANCE_RULES = [
|
|
28
|
-
"none",
|
|
29
|
-
"platform_seed_to_tenant",
|
|
30
|
-
"tenant_default_to_workspace",
|
|
31
|
-
"workspace_narrowing_only",
|
|
32
|
-
"pack_overlay_to_tenant",
|
|
33
|
-
"topic_lineage_to_resource",
|
|
34
|
-
];
|
|
35
|
-
/** Scope of impact when a control object is modified. */
|
|
36
|
-
export const CONTROL_OBJECT_BLAST_RADII = [
|
|
37
|
-
"platform",
|
|
38
|
-
"tenant",
|
|
39
|
-
"workspace",
|
|
40
|
-
"resource",
|
|
41
|
-
];
|
|
42
|
-
function defineCases(cases) {
|
|
43
|
-
return cases;
|
|
44
|
-
}
|
|
45
|
-
/** Static ownership matrix mapping each control object kind to its ownership cases. */
|
|
46
|
-
export const CONTROL_OBJECT_OWNERSHIP_MATRIX = {
|
|
47
|
-
tenant: defineCases([
|
|
48
|
-
{
|
|
49
|
-
caseKey: "platform-record",
|
|
50
|
-
caseLabel: "Platform Record",
|
|
51
|
-
kind: "tenant",
|
|
52
|
-
canonicalOwnerScope: "platform",
|
|
53
|
-
editSurface: "platform_admin",
|
|
54
|
-
inheritanceRule: "none",
|
|
55
|
-
blastRadius: "tenant",
|
|
56
|
-
},
|
|
57
|
-
]),
|
|
58
|
-
workspace: defineCases([
|
|
59
|
-
{
|
|
60
|
-
caseKey: "tenant-workspace",
|
|
61
|
-
caseLabel: "Tenant Workspace",
|
|
62
|
-
kind: "workspace",
|
|
63
|
-
canonicalOwnerScope: "tenant",
|
|
64
|
-
editSurface: "tenant_admin",
|
|
65
|
-
inheritanceRule: "tenant_default_to_workspace",
|
|
66
|
-
blastRadius: "workspace",
|
|
67
|
-
},
|
|
68
|
-
]),
|
|
69
|
-
principal: defineCases([
|
|
70
|
-
{
|
|
71
|
-
caseKey: "tenant-principal",
|
|
72
|
-
caseLabel: "Tenant Principal",
|
|
73
|
-
kind: "principal",
|
|
74
|
-
canonicalOwnerScope: "tenant",
|
|
75
|
-
editSurface: "tenant_admin",
|
|
76
|
-
inheritanceRule: "workspace_narrowing_only",
|
|
77
|
-
blastRadius: "resource",
|
|
78
|
-
},
|
|
79
|
-
]),
|
|
80
|
-
tool: defineCases([
|
|
81
|
-
{
|
|
82
|
-
caseKey: "platform-core",
|
|
83
|
-
caseLabel: "Platform Core",
|
|
84
|
-
kind: "tool",
|
|
85
|
-
canonicalOwnerScope: "platform",
|
|
86
|
-
editSurface: "platform_admin",
|
|
87
|
-
inheritanceRule: "platform_seed_to_tenant",
|
|
88
|
-
blastRadius: "platform",
|
|
89
|
-
},
|
|
90
|
-
{
|
|
91
|
-
caseKey: "tenant-custom",
|
|
92
|
-
caseLabel: "Tenant Custom",
|
|
93
|
-
kind: "tool",
|
|
94
|
-
canonicalOwnerScope: "tenant",
|
|
95
|
-
editSurface: "tenant_admin",
|
|
96
|
-
inheritanceRule: "tenant_default_to_workspace",
|
|
97
|
-
blastRadius: "tenant",
|
|
98
|
-
},
|
|
99
|
-
]),
|
|
100
|
-
pack: defineCases([
|
|
101
|
-
{
|
|
102
|
-
caseKey: "platform-definition",
|
|
103
|
-
caseLabel: "Platform Definition",
|
|
104
|
-
kind: "pack",
|
|
105
|
-
canonicalOwnerScope: "platform",
|
|
106
|
-
editSurface: "platform_admin",
|
|
107
|
-
inheritanceRule: "platform_seed_to_tenant",
|
|
108
|
-
blastRadius: "platform",
|
|
109
|
-
},
|
|
110
|
-
{
|
|
111
|
-
caseKey: "tenant-installation",
|
|
112
|
-
caseLabel: "Tenant Installation",
|
|
113
|
-
kind: "pack",
|
|
114
|
-
canonicalOwnerScope: "tenant",
|
|
115
|
-
editSurface: "tenant_admin",
|
|
116
|
-
inheritanceRule: "platform_seed_to_tenant",
|
|
117
|
-
blastRadius: "tenant",
|
|
118
|
-
},
|
|
119
|
-
]),
|
|
120
|
-
ontology: defineCases([
|
|
121
|
-
{
|
|
122
|
-
caseKey: "platform-base",
|
|
123
|
-
caseLabel: "Platform Base",
|
|
124
|
-
kind: "ontology",
|
|
125
|
-
canonicalOwnerScope: "platform",
|
|
126
|
-
editSurface: "platform_admin",
|
|
127
|
-
inheritanceRule: "platform_seed_to_tenant",
|
|
128
|
-
blastRadius: "platform",
|
|
129
|
-
},
|
|
130
|
-
{
|
|
131
|
-
caseKey: "pack-overlay",
|
|
132
|
-
caseLabel: "Pack Overlay",
|
|
133
|
-
kind: "ontology",
|
|
134
|
-
canonicalOwnerScope: "platform",
|
|
135
|
-
editSurface: "platform_admin",
|
|
136
|
-
inheritanceRule: "pack_overlay_to_tenant",
|
|
137
|
-
blastRadius: "platform",
|
|
138
|
-
},
|
|
139
|
-
{
|
|
140
|
-
caseKey: "tenant-extension",
|
|
141
|
-
caseLabel: "Tenant Extension",
|
|
142
|
-
kind: "ontology",
|
|
143
|
-
canonicalOwnerScope: "tenant",
|
|
144
|
-
editSurface: "tenant_admin",
|
|
145
|
-
inheritanceRule: "topic_lineage_to_resource",
|
|
146
|
-
blastRadius: "tenant",
|
|
147
|
-
},
|
|
148
|
-
]),
|
|
149
|
-
belief: defineCases([
|
|
150
|
-
{
|
|
151
|
-
caseKey: "topic-resource",
|
|
152
|
-
caseLabel: "Topic Resource",
|
|
153
|
-
kind: "belief",
|
|
154
|
-
canonicalOwnerScope: "resource",
|
|
155
|
-
editSurface: "graph_worktree",
|
|
156
|
-
inheritanceRule: "topic_lineage_to_resource",
|
|
157
|
-
blastRadius: "resource",
|
|
158
|
-
},
|
|
159
|
-
]),
|
|
160
|
-
policy_rule: defineCases([
|
|
161
|
-
{
|
|
162
|
-
caseKey: "platform-baseline",
|
|
163
|
-
caseLabel: "Platform Baseline",
|
|
164
|
-
kind: "policy_rule",
|
|
165
|
-
canonicalOwnerScope: "platform",
|
|
166
|
-
editSurface: "platform_admin",
|
|
167
|
-
inheritanceRule: "platform_seed_to_tenant",
|
|
168
|
-
blastRadius: "platform",
|
|
169
|
-
},
|
|
170
|
-
{
|
|
171
|
-
caseKey: "tenant-bundle",
|
|
172
|
-
caseLabel: "Tenant Bundle",
|
|
173
|
-
kind: "policy_rule",
|
|
174
|
-
canonicalOwnerScope: "tenant",
|
|
175
|
-
editSurface: "tenant_admin",
|
|
176
|
-
inheritanceRule: "tenant_default_to_workspace",
|
|
177
|
-
blastRadius: "tenant",
|
|
178
|
-
},
|
|
179
|
-
{
|
|
180
|
-
caseKey: "workspace-override",
|
|
181
|
-
caseLabel: "Workspace Override",
|
|
182
|
-
kind: "policy_rule",
|
|
183
|
-
canonicalOwnerScope: "workspace",
|
|
184
|
-
editSurface: "workspace_admin",
|
|
185
|
-
inheritanceRule: "none",
|
|
186
|
-
blastRadius: "workspace",
|
|
187
|
-
},
|
|
188
|
-
]),
|
|
189
|
-
};
|
|
190
|
-
function flattenOwnershipMatrix(matrix) {
|
|
191
|
-
return CONTROL_OBJECT_KINDS.flatMap((kind) => [...matrix[kind]]);
|
|
192
|
-
}
|
|
193
|
-
/** Flattened array of all ownership cases across all control object kinds. */
|
|
194
|
-
export const CONTROL_OBJECT_OWNERSHIP_ROWS = Object.freeze(flattenOwnershipMatrix(CONTROL_OBJECT_OWNERSHIP_MATRIX));
|
|
195
|
-
/** The canonical ownership contract exposed by the SDK. */
|
|
196
|
-
export const CONTROL_OBJECT_OWNERSHIP_CONTRACT = {
|
|
197
|
-
version: "1.0.0",
|
|
198
|
-
kinds: CONTROL_OBJECT_KINDS,
|
|
199
|
-
ownerScopes: CONTROL_OBJECT_OWNER_SCOPES,
|
|
200
|
-
editSurfaces: CONTROL_OBJECT_EDIT_SURFACES,
|
|
201
|
-
inheritanceRules: CONTROL_OBJECT_INHERITANCE_RULES,
|
|
202
|
-
blastRadii: CONTROL_OBJECT_BLAST_RADII,
|
|
203
|
-
matrix: CONTROL_OBJECT_OWNERSHIP_MATRIX,
|
|
204
|
-
rows: CONTROL_OBJECT_OWNERSHIP_ROWS,
|
|
205
|
-
};
|
|
206
|
-
/**
|
|
207
|
-
* List ownership cases for one control-object kind or the full matrix.
|
|
208
|
-
*/
|
|
209
|
-
export function listControlObjectOwnershipCases(kind) {
|
|
210
|
-
if (!kind) {
|
|
211
|
-
return CONTROL_OBJECT_OWNERSHIP_ROWS;
|
|
212
|
-
}
|
|
213
|
-
return CONTROL_OBJECT_OWNERSHIP_MATRIX[kind];
|
|
214
|
-
}
|
|
215
|
-
/**
|
|
216
|
-
* Get a specific ownership case by kind and case key.
|
|
217
|
-
*/
|
|
218
|
-
export function getControlObjectOwnershipCase(kind, caseKey) {
|
|
219
|
-
return CONTROL_OBJECT_OWNERSHIP_MATRIX[kind].find((ownershipCase) => ownershipCase.caseKey === caseKey);
|
|
220
|
-
}
|
|
@@ -1,366 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Structured error thrown when a platform API request fails.
|
|
3
|
-
*
|
|
4
|
-
* Includes HTTP status, machine-readable error code, optional invariant
|
|
5
|
-
* reference, and actionable suggestions for common failure modes.
|
|
6
|
-
*/
|
|
7
|
-
export class LucernApiError extends Error {
|
|
8
|
-
code;
|
|
9
|
-
status;
|
|
10
|
-
invariant;
|
|
11
|
-
suggestion;
|
|
12
|
-
details;
|
|
13
|
-
requestId;
|
|
14
|
-
correlationId;
|
|
15
|
-
policyTraceId;
|
|
16
|
-
constructor(args) {
|
|
17
|
-
super(args.message);
|
|
18
|
-
this.name = "LucernApiError";
|
|
19
|
-
this.code = args.code;
|
|
20
|
-
this.status = args.status;
|
|
21
|
-
this.invariant = args.invariant;
|
|
22
|
-
this.suggestion = args.suggestion;
|
|
23
|
-
this.details = args.details;
|
|
24
|
-
this.requestId = args.requestId;
|
|
25
|
-
this.correlationId = args.correlationId;
|
|
26
|
-
this.policyTraceId = args.policyTraceId;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Serialize a gateway query object into a URL query string.
|
|
31
|
-
*/
|
|
32
|
-
export function toQueryString(scope) {
|
|
33
|
-
const params = new URLSearchParams();
|
|
34
|
-
if (scope.tenantId) {
|
|
35
|
-
params.set("tenantId", scope.tenantId);
|
|
36
|
-
}
|
|
37
|
-
if (scope.workspaceId) {
|
|
38
|
-
params.set("workspaceId", scope.workspaceId);
|
|
39
|
-
}
|
|
40
|
-
for (const [key, value] of Object.entries(scope)) {
|
|
41
|
-
if (key === "tenantId" || key === "workspaceId") {
|
|
42
|
-
continue;
|
|
43
|
-
}
|
|
44
|
-
if (value === undefined) {
|
|
45
|
-
continue;
|
|
46
|
-
}
|
|
47
|
-
params.set(key, String(value));
|
|
48
|
-
}
|
|
49
|
-
const serialized = params.toString();
|
|
50
|
-
return serialized.length > 0 ? `?${serialized}` : "";
|
|
51
|
-
}
|
|
52
|
-
function fillRandomBytes(length) {
|
|
53
|
-
const bytes = new Uint8Array(length);
|
|
54
|
-
if (typeof globalThis.crypto?.getRandomValues === "function") {
|
|
55
|
-
globalThis.crypto.getRandomValues(bytes);
|
|
56
|
-
return bytes;
|
|
57
|
-
}
|
|
58
|
-
for (let index = 0; index < length; index += 1) {
|
|
59
|
-
bytes[index] = Math.floor(Math.random() * 256);
|
|
60
|
-
}
|
|
61
|
-
return bytes;
|
|
62
|
-
}
|
|
63
|
-
function generatePortableRequestId() {
|
|
64
|
-
if (typeof globalThis.crypto?.randomUUID === "function") {
|
|
65
|
-
return globalThis.crypto.randomUUID();
|
|
66
|
-
}
|
|
67
|
-
const bytes = fillRandomBytes(16);
|
|
68
|
-
bytes[6] = (bytes[6] & 0x0f) | 0x40;
|
|
69
|
-
bytes[8] = (bytes[8] & 0x3f) | 0x80;
|
|
70
|
-
const hex = Array.from(bytes, (value) => value.toString(16).padStart(2, "0"));
|
|
71
|
-
return `${hex.slice(0, 4).join("")}-${hex.slice(4, 6).join("")}-${hex.slice(6, 8).join("")}-${hex.slice(8, 10).join("")}-${hex.slice(10).join("")}`;
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* Generate a random idempotency key for retry-safe writes.
|
|
75
|
-
*/
|
|
76
|
-
export function randomIdempotencyKey() {
|
|
77
|
-
return generatePortableRequestId();
|
|
78
|
-
}
|
|
79
|
-
function isRetryableStatus(status) {
|
|
80
|
-
return status >= 500 || status === 408 || status === 429;
|
|
81
|
-
}
|
|
82
|
-
function fallbackErrorCode(status) {
|
|
83
|
-
if (status === 401) {
|
|
84
|
-
return "AUTHENTICATION_REQUIRED";
|
|
85
|
-
}
|
|
86
|
-
if (status === 403) {
|
|
87
|
-
return "FORBIDDEN";
|
|
88
|
-
}
|
|
89
|
-
if (status === 404) {
|
|
90
|
-
return "NOT_FOUND";
|
|
91
|
-
}
|
|
92
|
-
if (status === 408) {
|
|
93
|
-
return "UPSTREAM_ERROR";
|
|
94
|
-
}
|
|
95
|
-
if (status === 409) {
|
|
96
|
-
return "CONFLICT";
|
|
97
|
-
}
|
|
98
|
-
if (status === 429) {
|
|
99
|
-
return "RATE_LIMIT_EXCEEDED";
|
|
100
|
-
}
|
|
101
|
-
if (status >= 500) {
|
|
102
|
-
return "UPSTREAM_ERROR";
|
|
103
|
-
}
|
|
104
|
-
return "INTERNAL_ERROR";
|
|
105
|
-
}
|
|
106
|
-
function delay(ms) {
|
|
107
|
-
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
108
|
-
}
|
|
109
|
-
function parseRetryAfterMs(value) {
|
|
110
|
-
if (!value) {
|
|
111
|
-
return null;
|
|
112
|
-
}
|
|
113
|
-
const trimmed = value.trim();
|
|
114
|
-
if (!trimmed) {
|
|
115
|
-
return null;
|
|
116
|
-
}
|
|
117
|
-
const numeric = Number(trimmed);
|
|
118
|
-
if (Number.isFinite(numeric)) {
|
|
119
|
-
return Math.max(0, Math.round(numeric * 1000));
|
|
120
|
-
}
|
|
121
|
-
const parsedDate = Date.parse(trimmed);
|
|
122
|
-
if (Number.isFinite(parsedDate)) {
|
|
123
|
-
return Math.max(0, parsedDate - Date.now());
|
|
124
|
-
}
|
|
125
|
-
return null;
|
|
126
|
-
}
|
|
127
|
-
function computeRetryDelayMs(args) {
|
|
128
|
-
const baseDelay = args.status === 429
|
|
129
|
-
? Math.max(args.retryAfterMs ?? 0, Math.min(1000 * 2 ** args.attempt, 10_000))
|
|
130
|
-
: Math.min(1000 * 2 ** args.attempt, 4000);
|
|
131
|
-
if (args.status !== 429) {
|
|
132
|
-
return baseDelay;
|
|
133
|
-
}
|
|
134
|
-
const jitterWindow = Math.max(250, Math.round(baseDelay * 0.25));
|
|
135
|
-
return baseDelay + Math.round(Math.random() * jitterWindow);
|
|
136
|
-
}
|
|
137
|
-
function timeoutError(timeoutMs) {
|
|
138
|
-
const error = new Error(`Request timed out after ${timeoutMs}ms`);
|
|
139
|
-
error.name = "AbortError";
|
|
140
|
-
return error;
|
|
141
|
-
}
|
|
142
|
-
function readPolicySummaryFromDetails(details) {
|
|
143
|
-
if (!details || typeof details !== "object" || Array.isArray(details)) {
|
|
144
|
-
return null;
|
|
145
|
-
}
|
|
146
|
-
const directSummary = details.summary;
|
|
147
|
-
if (typeof directSummary === "string" && directSummary.trim().length > 0) {
|
|
148
|
-
return directSummary.trim();
|
|
149
|
-
}
|
|
150
|
-
const policy = details.policy;
|
|
151
|
-
if (!policy || typeof policy !== "object" || Array.isArray(policy)) {
|
|
152
|
-
return null;
|
|
153
|
-
}
|
|
154
|
-
const explanation = policy.explanation;
|
|
155
|
-
if (!explanation || typeof explanation !== "object" || Array.isArray(explanation)) {
|
|
156
|
-
return null;
|
|
157
|
-
}
|
|
158
|
-
const nestedSummary = explanation.summary;
|
|
159
|
-
if (typeof nestedSummary === "string" && nestedSummary.trim().length > 0) {
|
|
160
|
-
return nestedSummary.trim();
|
|
161
|
-
}
|
|
162
|
-
return null;
|
|
163
|
-
}
|
|
164
|
-
/**
|
|
165
|
-
* Create the transport client used by all SDK modules.
|
|
166
|
-
*/
|
|
167
|
-
export function createGatewayRequestClient(config = {}) {
|
|
168
|
-
const fetchImpl = config.fetchImpl ?? fetch;
|
|
169
|
-
const baseUrl = config.baseUrl?.replace(/\/+$/, "") ?? "";
|
|
170
|
-
const maxRetries = config.maxRetries ?? 2;
|
|
171
|
-
const requestIdFactory = config.requestIdFactory ?? (() => generatePortableRequestId());
|
|
172
|
-
async function resolveAuthHeaders() {
|
|
173
|
-
if (!config.getAuthHeaders) {
|
|
174
|
-
return {};
|
|
175
|
-
}
|
|
176
|
-
return await config.getAuthHeaders();
|
|
177
|
-
}
|
|
178
|
-
async function fetchWithTimeout(url, init, timeoutMs) {
|
|
179
|
-
const controller = new AbortController();
|
|
180
|
-
const timer = setTimeout(() => controller.abort(), timeoutMs);
|
|
181
|
-
try {
|
|
182
|
-
return await fetchImpl(url, { ...init, signal: controller.signal });
|
|
183
|
-
}
|
|
184
|
-
catch (error) {
|
|
185
|
-
if (controller.signal.aborted) {
|
|
186
|
-
throw timeoutError(timeoutMs);
|
|
187
|
-
}
|
|
188
|
-
throw error;
|
|
189
|
-
}
|
|
190
|
-
finally {
|
|
191
|
-
clearTimeout(timer);
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
async function parsePayload(response) {
|
|
195
|
-
const text = await response.text();
|
|
196
|
-
if (!text) {
|
|
197
|
-
return null;
|
|
198
|
-
}
|
|
199
|
-
try {
|
|
200
|
-
return JSON.parse(text);
|
|
201
|
-
}
|
|
202
|
-
catch {
|
|
203
|
-
return null;
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
function resolveTimeoutMs(method, requestTimeoutMs) {
|
|
207
|
-
if (typeof requestTimeoutMs === "number") {
|
|
208
|
-
return requestTimeoutMs;
|
|
209
|
-
}
|
|
210
|
-
const methodTimeoutMs = config.timeoutMsByMethod?.[method];
|
|
211
|
-
if (typeof methodTimeoutMs === "number") {
|
|
212
|
-
return methodTimeoutMs;
|
|
213
|
-
}
|
|
214
|
-
return config.timeoutMs ?? 15_000;
|
|
215
|
-
}
|
|
216
|
-
function buildApiError(args) {
|
|
217
|
-
const failure = args.failure;
|
|
218
|
-
const legacyError = failure && typeof failure.error === "object" && failure.error !== null
|
|
219
|
-
? failure.error
|
|
220
|
-
: failure?.legacyError;
|
|
221
|
-
const correlationId = failure?.correlationId ??
|
|
222
|
-
args.response.headers.get("x-lucern-correlation-id")?.trim() ??
|
|
223
|
-
args.requestId;
|
|
224
|
-
const policyTraceId = failure?.policyTraceId ??
|
|
225
|
-
args.response.headers.get("x-lucern-policy-trace-id")?.trim() ??
|
|
226
|
-
null;
|
|
227
|
-
const details = failure?.details ?? legacyError?.details;
|
|
228
|
-
const policySummary = readPolicySummaryFromDetails(details);
|
|
229
|
-
return new LucernApiError({
|
|
230
|
-
code: failure?.code ?? legacyError?.code ?? fallbackErrorCode(args.response.status),
|
|
231
|
-
message: policySummary ??
|
|
232
|
-
(typeof failure?.error === "string"
|
|
233
|
-
? failure.error
|
|
234
|
-
: legacyError?.message ??
|
|
235
|
-
(args.response.ok
|
|
236
|
-
? "Platform API returned an invalid success payload."
|
|
237
|
-
: "Platform API request failed.")),
|
|
238
|
-
status: args.response.status,
|
|
239
|
-
invariant: failure?.invariant,
|
|
240
|
-
suggestion: failure?.suggestion,
|
|
241
|
-
details,
|
|
242
|
-
requestId: args.requestId,
|
|
243
|
-
correlationId,
|
|
244
|
-
policyTraceId,
|
|
245
|
-
});
|
|
246
|
-
}
|
|
247
|
-
async function request(args) {
|
|
248
|
-
const authHeaders = await resolveAuthHeaders();
|
|
249
|
-
const method = args.method ?? "GET";
|
|
250
|
-
const timeoutMs = resolveTimeoutMs(method, args.timeoutMs);
|
|
251
|
-
const headers = new Headers({
|
|
252
|
-
"content-type": "application/json",
|
|
253
|
-
...authHeaders,
|
|
254
|
-
});
|
|
255
|
-
if (args.idempotencyKey) {
|
|
256
|
-
headers.set("idempotency-key", args.idempotencyKey);
|
|
257
|
-
}
|
|
258
|
-
const requestId = headers.get("x-correlation-id")?.trim() ||
|
|
259
|
-
headers.get("x-request-id")?.trim() ||
|
|
260
|
-
args.requestId ||
|
|
261
|
-
requestIdFactory();
|
|
262
|
-
if (!headers.has("x-correlation-id") && !headers.has("x-request-id")) {
|
|
263
|
-
headers.set("x-correlation-id", requestId);
|
|
264
|
-
}
|
|
265
|
-
const url = `${baseUrl}${args.path}`;
|
|
266
|
-
const serializedBody = args.body ? JSON.stringify(args.body) : undefined;
|
|
267
|
-
const init = {
|
|
268
|
-
method,
|
|
269
|
-
headers,
|
|
270
|
-
body: serializedBody,
|
|
271
|
-
};
|
|
272
|
-
let lastError;
|
|
273
|
-
for (let attempt = 0; attempt <= maxRetries; attempt++) {
|
|
274
|
-
const hookRequestContext = {
|
|
275
|
-
requestId,
|
|
276
|
-
attempt,
|
|
277
|
-
maxRetries,
|
|
278
|
-
method,
|
|
279
|
-
path: args.path,
|
|
280
|
-
url,
|
|
281
|
-
headers: new Headers(headers),
|
|
282
|
-
body: serializedBody,
|
|
283
|
-
timeoutMs,
|
|
284
|
-
};
|
|
285
|
-
await config.onRequest?.(hookRequestContext);
|
|
286
|
-
const startedAt = Date.now();
|
|
287
|
-
try {
|
|
288
|
-
const response = await fetchWithTimeout(url, init, timeoutMs);
|
|
289
|
-
const responseClone = response.clone();
|
|
290
|
-
const payload = await parsePayload(response);
|
|
291
|
-
const retryAfterMs = parseRetryAfterMs(response.headers.get("Retry-After"));
|
|
292
|
-
if (!response.ok || !payload?.success) {
|
|
293
|
-
const failure = payload && !payload.success ? payload : null;
|
|
294
|
-
const apiError = buildApiError({
|
|
295
|
-
requestId,
|
|
296
|
-
response,
|
|
297
|
-
failure,
|
|
298
|
-
});
|
|
299
|
-
const willRetry = attempt < maxRetries && isRetryableStatus(response.status);
|
|
300
|
-
await config.onResponse?.({
|
|
301
|
-
...hookRequestContext,
|
|
302
|
-
durationMs: Date.now() - startedAt,
|
|
303
|
-
status: response.status,
|
|
304
|
-
response: responseClone,
|
|
305
|
-
error: apiError,
|
|
306
|
-
correlationId: apiError.correlationId ?? requestId,
|
|
307
|
-
policyTraceId: apiError.policyTraceId ?? null,
|
|
308
|
-
retryAfterMs,
|
|
309
|
-
willRetry,
|
|
310
|
-
});
|
|
311
|
-
if (willRetry) {
|
|
312
|
-
lastError = apiError;
|
|
313
|
-
await delay(computeRetryDelayMs({
|
|
314
|
-
attempt,
|
|
315
|
-
status: response.status,
|
|
316
|
-
retryAfterMs,
|
|
317
|
-
}));
|
|
318
|
-
continue;
|
|
319
|
-
}
|
|
320
|
-
throw apiError;
|
|
321
|
-
}
|
|
322
|
-
const successPayload = payload;
|
|
323
|
-
await config.onResponse?.({
|
|
324
|
-
...hookRequestContext,
|
|
325
|
-
durationMs: Date.now() - startedAt,
|
|
326
|
-
status: response.status,
|
|
327
|
-
response: responseClone,
|
|
328
|
-
correlationId: successPayload.correlationId ??
|
|
329
|
-
response.headers.get("x-lucern-correlation-id")?.trim() ??
|
|
330
|
-
requestId,
|
|
331
|
-
policyTraceId: successPayload.policyTraceId ??
|
|
332
|
-
response.headers.get("x-lucern-policy-trace-id")?.trim() ??
|
|
333
|
-
null,
|
|
334
|
-
idempotentReplay: successPayload.idempotentReplay,
|
|
335
|
-
retryAfterMs,
|
|
336
|
-
willRetry: false,
|
|
337
|
-
});
|
|
338
|
-
return successPayload;
|
|
339
|
-
}
|
|
340
|
-
catch (fetchError) {
|
|
341
|
-
if (fetchError instanceof LucernApiError) {
|
|
342
|
-
throw fetchError;
|
|
343
|
-
}
|
|
344
|
-
const willRetry = attempt < maxRetries;
|
|
345
|
-
await config.onResponse?.({
|
|
346
|
-
...hookRequestContext,
|
|
347
|
-
durationMs: Date.now() - startedAt,
|
|
348
|
-
error: fetchError,
|
|
349
|
-
correlationId: requestId,
|
|
350
|
-
policyTraceId: null,
|
|
351
|
-
willRetry,
|
|
352
|
-
});
|
|
353
|
-
lastError = fetchError;
|
|
354
|
-
if (willRetry) {
|
|
355
|
-
await delay(computeRetryDelayMs({ attempt }));
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
|
-
}
|
|
359
|
-
throw lastError instanceof Error
|
|
360
|
-
? lastError
|
|
361
|
-
: new Error("Platform API request failed after retries.");
|
|
362
|
-
}
|
|
363
|
-
return {
|
|
364
|
-
request,
|
|
365
|
-
};
|
|
366
|
-
}
|