@inf-monkeys-tech/monkeys 1.1.16 → 1.1.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -0
- package/lib/contracts/action-program-http.d.ts +1021 -0
- package/lib/contracts/action-program-http.d.ts.map +1 -0
- package/lib/contracts/action-program-http.js +42 -0
- package/lib/contracts/action-program-http.js.map +1 -0
- package/lib/contracts/declarative-control-http.d.ts +11365 -18
- package/lib/contracts/declarative-control-http.d.ts.map +1 -1
- package/lib/contracts/declarative-control.d.ts +3263 -1022
- package/lib/contracts/declarative-control.d.ts.map +1 -1
- package/lib/contracts/declarative-control.js +278 -5
- package/lib/contracts/declarative-control.js.map +1 -1
- package/lib/contracts/declarative-publication-job.d.ts +3356 -8
- package/lib/contracts/declarative-publication-job.d.ts.map +1 -1
- package/lib/contracts/index.d.ts +1 -0
- package/lib/contracts/index.d.ts.map +1 -1
- package/lib/contracts/index.js +1 -0
- package/lib/contracts/index.js.map +1 -1
- package/lib/esm/contracts/index.mjs +342 -3
- package/lib/esm/contracts/index.mjs.map +1 -1
- package/lib/esm/index.mjs +689 -29
- package/lib/esm/index.mjs.map +1 -1
- package/lib/esm/runtime/index.mjs +639 -29
- package/lib/esm/runtime/index.mjs.map +1 -1
- package/lib/esm/schemas/index.mjs +4088 -3797
- package/lib/esm/schemas/index.mjs.map +1 -1
- package/lib/json-schema/action-program-artifact.schema.json +1226 -0
- package/lib/json-schema/action-program-definition.schema.json +1205 -0
- package/lib/json-schema/index.json +2 -0
- package/lib/json-schema/navigation-release.schema.json +1 -0
- package/lib/json-schema/navigation-runtime-bundle.schema.json +1 -0
- package/lib/json-schema/page-release.schema.json +1 -0
- package/lib/json-schema/page-runtime-bundle.schema.json +2436 -0
- package/lib/json-schema/page.schema.json +941 -0
- package/lib/json-schema/workbench-release.schema.json +1 -0
- package/lib/json-schema/workbench-runtime-bundle.schema.json +1 -0
- package/lib/runtime/action-program-author.d.ts +40 -0
- package/lib/runtime/action-program-author.d.ts.map +1 -0
- package/lib/runtime/action-program-author.js +178 -0
- package/lib/runtime/action-program-author.js.map +1 -0
- package/lib/runtime/declarative-control-compiler.d.ts +9 -1
- package/lib/runtime/declarative-control-compiler.d.ts.map +1 -1
- package/lib/runtime/declarative-control-compiler.js +123 -7
- package/lib/runtime/declarative-control-compiler.js.map +1 -1
- package/lib/runtime/declarative-runtime-contract.d.ts.map +1 -1
- package/lib/runtime/declarative-runtime-contract.js +40 -2
- package/lib/runtime/declarative-runtime-contract.js.map +1 -1
- package/lib/runtime/index.d.ts +1 -0
- package/lib/runtime/index.d.ts.map +1 -1
- package/lib/runtime/index.js +1 -0
- package/lib/runtime/index.js.map +1 -1
- package/lib/schemas/index.d.ts +2216 -1232
- package/lib/schemas/index.d.ts.map +1 -1
- package/lib/schemas/index.js +116 -111
- package/lib/schemas/index.js.map +1 -1
- package/package.json +4 -2
|
@@ -7321,7 +7321,7 @@ var require__ = __commonJS({
|
|
|
7321
7321
|
var discriminator_1 = require_discriminator();
|
|
7322
7322
|
var json_schema_2020_12_1 = require_json_schema_2020_12();
|
|
7323
7323
|
var META_SCHEMA_ID = "https://json-schema.org/draft/2020-12/schema";
|
|
7324
|
-
var
|
|
7324
|
+
var Ajv20203 = class extends core_1.default {
|
|
7325
7325
|
constructor(opts = {}) {
|
|
7326
7326
|
super({
|
|
7327
7327
|
...opts,
|
|
@@ -7348,11 +7348,11 @@ var require__ = __commonJS({
|
|
|
7348
7348
|
return this.opts.defaultMeta = super.defaultMeta() || (this.getSchema(META_SCHEMA_ID) ? META_SCHEMA_ID : void 0);
|
|
7349
7349
|
}
|
|
7350
7350
|
};
|
|
7351
|
-
exports.Ajv2020 =
|
|
7352
|
-
module.exports = exports =
|
|
7353
|
-
module.exports.Ajv2020 =
|
|
7351
|
+
exports.Ajv2020 = Ajv20203;
|
|
7352
|
+
module.exports = exports = Ajv20203;
|
|
7353
|
+
module.exports.Ajv2020 = Ajv20203;
|
|
7354
7354
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7355
|
-
exports.default =
|
|
7355
|
+
exports.default = Ajv20203;
|
|
7356
7356
|
var validate_1 = require_validate();
|
|
7357
7357
|
Object.defineProperty(exports, "KeywordCxt", { enumerable: true, get: function() {
|
|
7358
7358
|
return validate_1.KeywordCxt;
|
|
@@ -11198,6 +11198,7 @@ var ReleaseDependencyRoleSchema = z13.enum([
|
|
|
11198
11198
|
"view",
|
|
11199
11199
|
"projection",
|
|
11200
11200
|
"action",
|
|
11201
|
+
"action-program",
|
|
11201
11202
|
"token",
|
|
11202
11203
|
"schema",
|
|
11203
11204
|
"compiler",
|
|
@@ -11228,6 +11229,7 @@ var DependencyKindByRole = {
|
|
|
11228
11229
|
view: "view",
|
|
11229
11230
|
projection: "projection",
|
|
11230
11231
|
action: "domain-command",
|
|
11232
|
+
"action-program": "action-program",
|
|
11231
11233
|
token: "design-token",
|
|
11232
11234
|
schema: "schema",
|
|
11233
11235
|
compiler: "compiler",
|
|
@@ -12180,8 +12182,14 @@ var QueryBindingSchema = z13.object({
|
|
|
12180
12182
|
}).strict().superRefine((value, context) => {
|
|
12181
12183
|
if (value.draftRetention) {
|
|
12182
12184
|
const names = value.draftRetention.identityParameters;
|
|
12183
|
-
if (value.execution !== "server" || new Set(names).size !== names.length || names.some(
|
|
12184
|
-
|
|
12185
|
+
if (value.execution !== "server" || new Set(names).size !== names.length || names.some(
|
|
12186
|
+
(name) => !Object.prototype.hasOwnProperty.call(value.parameters, name)
|
|
12187
|
+
)) {
|
|
12188
|
+
context.addIssue({
|
|
12189
|
+
code: "custom",
|
|
12190
|
+
path: ["draftRetention"],
|
|
12191
|
+
message: "Draft retention requires distinct declared Server query identity parameters."
|
|
12192
|
+
});
|
|
12185
12193
|
}
|
|
12186
12194
|
}
|
|
12187
12195
|
if (value.targetProjection) {
|
|
@@ -12875,6 +12883,237 @@ var PageDataSchema = QueryBindingSchema.omit({
|
|
|
12875
12883
|
cursorWindow: PageCursorWindowSchema.optional(),
|
|
12876
12884
|
resultStateBindings: z13.array(PageResultStateBindingSchema).max(32).optional()
|
|
12877
12885
|
}).strict();
|
|
12886
|
+
var ACTION_PROGRAM_ABI = "monkeys.action-program/2";
|
|
12887
|
+
var ActionProgramBudgetsSchema = z13.object({
|
|
12888
|
+
rpcMs: z13.number().int().positive().max(3e4),
|
|
12889
|
+
concurrentCalls: z13.number().int().positive().max(4),
|
|
12890
|
+
calls: z13.number().int().positive().max(128),
|
|
12891
|
+
messageBytes: z13.number().int().positive().max(1048576),
|
|
12892
|
+
activeMs: z13.number().int().positive().max(12e4),
|
|
12893
|
+
formMs: z13.number().int().positive().max(3e5),
|
|
12894
|
+
wallMs: z13.number().int().positive().max(6e5)
|
|
12895
|
+
}).strict();
|
|
12896
|
+
var DEFAULT_ACTION_PROGRAM_BUDGETS = Object.freeze({
|
|
12897
|
+
rpcMs: 3e4,
|
|
12898
|
+
concurrentCalls: 4,
|
|
12899
|
+
calls: 128,
|
|
12900
|
+
messageBytes: 1048576,
|
|
12901
|
+
activeMs: 12e4,
|
|
12902
|
+
formMs: 3e5,
|
|
12903
|
+
wallMs: 6e5
|
|
12904
|
+
});
|
|
12905
|
+
var ProgramSchemaRefSchema = RevisionRefSchema.refine(
|
|
12906
|
+
(ref2) => ref2.kind === "schema",
|
|
12907
|
+
"Expected an exact Schema reference."
|
|
12908
|
+
);
|
|
12909
|
+
var ActionProgramDependencySchema = z13.object({
|
|
12910
|
+
kind: z13.enum(["query", "command"]),
|
|
12911
|
+
revisionRef: RevisionRefSchema,
|
|
12912
|
+
inputSchemaRevisionRef: ProgramSchemaRefSchema,
|
|
12913
|
+
resultSchemaRevisionRef: ProgramSchemaRefSchema,
|
|
12914
|
+
download: ActionBindingSchema.shape.success.shape.download,
|
|
12915
|
+
// Fixed/identity arguments are injected by the trusted caller, never by guest code.
|
|
12916
|
+
dynamicInputKeys: z13.array(ContractIdentifierSchema).max(128)
|
|
12917
|
+
}).strict().superRefine((value, context) => {
|
|
12918
|
+
const expected = value.kind === "query" ? "domain-query-definition" : "domain-command";
|
|
12919
|
+
if (value.revisionRef.kind !== expected)
|
|
12920
|
+
context.addIssue({
|
|
12921
|
+
code: "custom",
|
|
12922
|
+
path: ["revisionRef", "kind"],
|
|
12923
|
+
message: `Expected ${expected}.`
|
|
12924
|
+
});
|
|
12925
|
+
if (new Set(value.dynamicInputKeys).size !== value.dynamicInputKeys.length)
|
|
12926
|
+
context.addIssue({
|
|
12927
|
+
code: "custom",
|
|
12928
|
+
path: ["dynamicInputKeys"],
|
|
12929
|
+
message: "Dynamic input keys must be unique."
|
|
12930
|
+
});
|
|
12931
|
+
});
|
|
12932
|
+
var ActionProgramDefinitionSchema = z13.object({
|
|
12933
|
+
contract: z13.literal("ActionProgramDefinition"),
|
|
12934
|
+
schemaVersion: z13.literal(1),
|
|
12935
|
+
programId: ContractIdentifierSchema,
|
|
12936
|
+
ownerRepo: ContractIdentifierSchema,
|
|
12937
|
+
tenantScope: TenantScopeSchema,
|
|
12938
|
+
supportedSurface: z13.literal("studio"),
|
|
12939
|
+
inputSchemaRevisionRef: ProgramSchemaRefSchema,
|
|
12940
|
+
resultSchemaRevisionRef: ProgramSchemaRefSchema,
|
|
12941
|
+
entry: z13.literal("main"),
|
|
12942
|
+
abi: z13.literal(ACTION_PROGRAM_ABI),
|
|
12943
|
+
compiler: z13.string().trim().min(1).max(128),
|
|
12944
|
+
target: z13.literal("browser-worker-es2020"),
|
|
12945
|
+
sourceHash: Sha256Schema,
|
|
12946
|
+
compiledHash: Sha256Schema,
|
|
12947
|
+
sourceMapHash: Sha256Schema,
|
|
12948
|
+
dependencies: z13.array(ActionProgramDependencySchema).max(128),
|
|
12949
|
+
effects: z13.array(
|
|
12950
|
+
z13.enum([
|
|
12951
|
+
"form",
|
|
12952
|
+
"toast",
|
|
12953
|
+
"refresh",
|
|
12954
|
+
"download",
|
|
12955
|
+
"state.get",
|
|
12956
|
+
"state.set"
|
|
12957
|
+
])
|
|
12958
|
+
).max(6),
|
|
12959
|
+
refreshAliases: z13.array(ContractIdentifierSchema).max(128),
|
|
12960
|
+
stateAliases: z13.array(
|
|
12961
|
+
z13.object({
|
|
12962
|
+
alias: ContractIdentifierSchema,
|
|
12963
|
+
schemaRevisionRef: ProgramSchemaRefSchema
|
|
12964
|
+
}).strict()
|
|
12965
|
+
).max(128),
|
|
12966
|
+
budgets: ActionProgramBudgetsSchema
|
|
12967
|
+
}).strict().superRefine((value, context) => {
|
|
12968
|
+
for (const [name, keys] of [
|
|
12969
|
+
[
|
|
12970
|
+
"dependencies",
|
|
12971
|
+
value.dependencies.map((dep) => `${dep.kind}:${dep.revisionRef.id}`)
|
|
12972
|
+
],
|
|
12973
|
+
["effects", value.effects],
|
|
12974
|
+
["refreshAliases", value.refreshAliases],
|
|
12975
|
+
["stateAliases", value.stateAliases.map((entry) => entry.alias)]
|
|
12976
|
+
])
|
|
12977
|
+
if (new Set(keys).size !== keys.length)
|
|
12978
|
+
context.addIssue({
|
|
12979
|
+
code: "custom",
|
|
12980
|
+
path: [name],
|
|
12981
|
+
message: "Program declarations must be unique."
|
|
12982
|
+
});
|
|
12983
|
+
const refs = [
|
|
12984
|
+
value.inputSchemaRevisionRef,
|
|
12985
|
+
value.resultSchemaRevisionRef,
|
|
12986
|
+
...value.dependencies.flatMap((dep) => [
|
|
12987
|
+
dep.revisionRef,
|
|
12988
|
+
dep.inputSchemaRevisionRef,
|
|
12989
|
+
dep.resultSchemaRevisionRef
|
|
12990
|
+
]),
|
|
12991
|
+
...value.stateAliases.map((entry) => entry.schemaRevisionRef)
|
|
12992
|
+
];
|
|
12993
|
+
refs.forEach((ref2, index) => {
|
|
12994
|
+
if (ref2.visibility === "tenant" && ref2.tenantScope && tenantScopeKey(ref2.tenantScope) !== tenantScopeKey(value.tenantScope))
|
|
12995
|
+
context.addIssue({
|
|
12996
|
+
code: "custom",
|
|
12997
|
+
path: ["dependencies"],
|
|
12998
|
+
message: `Cross-tenant program reference ${index}.`
|
|
12999
|
+
});
|
|
13000
|
+
});
|
|
13001
|
+
});
|
|
13002
|
+
var ActionProgramArtifactSchema = z13.object({
|
|
13003
|
+
definition: ActionProgramDefinitionSchema,
|
|
13004
|
+
// Hashes use canonicalContentHash of the exact UTF-8 string, not engine bytecode.
|
|
13005
|
+
javascript: z13.string().min(1).max(262144).refine(
|
|
13006
|
+
(value) => new TextEncoder().encode(value).length <= 262144,
|
|
13007
|
+
"Program exceeds 256 KiB."
|
|
13008
|
+
),
|
|
13009
|
+
sourceMap: z13.string().min(1).max(524288).refine(
|
|
13010
|
+
(value) => new TextEncoder().encode(value).length <= 524288,
|
|
13011
|
+
"Source map exceeds 512 KiB."
|
|
13012
|
+
)
|
|
13013
|
+
}).strict();
|
|
13014
|
+
var ProgramInputSourceSchema = z13.discriminatedUnion("kind", [
|
|
13015
|
+
...BindingSourceSchema.options,
|
|
13016
|
+
ExpressionBindingSourceSchema
|
|
13017
|
+
]);
|
|
13018
|
+
var ProgramBindingShape = {
|
|
13019
|
+
bindingId: ContractIdentifierSchema,
|
|
13020
|
+
inputMapping: z13.record(ContractIdentifierSchema, ProgramInputSourceSchema),
|
|
13021
|
+
dependencyInputs: z13.record(
|
|
13022
|
+
ContractIdentifierSchema,
|
|
13023
|
+
z13.record(ContractIdentifierSchema, ProgramInputSourceSchema)
|
|
13024
|
+
),
|
|
13025
|
+
accessPolicy: AccessPolicySchema,
|
|
13026
|
+
confirmation: I18nTextSchema.optional(),
|
|
13027
|
+
when: PageExpressionSchema.optional(),
|
|
13028
|
+
concurrencyKeyPath: PageValuePathSchema.min(1),
|
|
13029
|
+
refreshAliases: z13.record(
|
|
13030
|
+
ContractIdentifierSchema,
|
|
13031
|
+
z13.array(ContractIdentifierSchema).min(1).max(128)
|
|
13032
|
+
),
|
|
13033
|
+
stateAliases: z13.record(ContractIdentifierSchema, ContractIdentifierSchema)
|
|
13034
|
+
};
|
|
13035
|
+
var PageProgramActionSchema = z13.object({
|
|
13036
|
+
...ProgramBindingShape,
|
|
13037
|
+
program: ContractIdentifierSchema,
|
|
13038
|
+
port: ContractIdentifierSchema
|
|
13039
|
+
}).strict();
|
|
13040
|
+
var ProgramBindingSchema = z13.object({
|
|
13041
|
+
...ProgramBindingShape,
|
|
13042
|
+
source: z13.object({
|
|
13043
|
+
capabilityInstanceId: ContractIdentifierSchema,
|
|
13044
|
+
port: ContractIdentifierSchema
|
|
13045
|
+
}).strict(),
|
|
13046
|
+
sourceIntentSchemaRevisionRef: ProgramSchemaRefSchema,
|
|
13047
|
+
programRevisionRef: RevisionRefSchema.refine(
|
|
13048
|
+
(ref2) => ref2.kind === "action-program",
|
|
13049
|
+
"Expected action-program reference."
|
|
13050
|
+
),
|
|
13051
|
+
definition: ActionProgramDefinitionSchema
|
|
13052
|
+
}).strict();
|
|
13053
|
+
function validateProgramBindingTargets(page, context) {
|
|
13054
|
+
const ids = new Set(page.actionBindings.map((binding) => binding.bindingId));
|
|
13055
|
+
const ports = new Set(
|
|
13056
|
+
page.actionBindings.map(
|
|
13057
|
+
(binding) => `${binding.source.capabilityInstanceId}:${binding.source.port}`
|
|
13058
|
+
)
|
|
13059
|
+
);
|
|
13060
|
+
const dataIds = new Set(
|
|
13061
|
+
[...page.ontologyBindings, ...page.queryBindings ?? []].map(
|
|
13062
|
+
(binding) => binding.bindingId
|
|
13063
|
+
)
|
|
13064
|
+
);
|
|
13065
|
+
for (const [index, binding] of (page.programBindings ?? []).entries()) {
|
|
13066
|
+
const issue = (message) => context.addIssue({
|
|
13067
|
+
code: "custom",
|
|
13068
|
+
path: ["programBindings", index],
|
|
13069
|
+
message
|
|
13070
|
+
});
|
|
13071
|
+
const port = `${binding.source.capabilityInstanceId}:${binding.source.port}`;
|
|
13072
|
+
if (ids.has(binding.bindingId) || ports.has(port))
|
|
13073
|
+
issue("Program binding id and event must be exclusive.");
|
|
13074
|
+
ids.add(binding.bindingId);
|
|
13075
|
+
ports.add(port);
|
|
13076
|
+
if (!page.capabilityInstances.some(
|
|
13077
|
+
(instance) => instance.instanceId === binding.source.capabilityInstanceId
|
|
13078
|
+
))
|
|
13079
|
+
issue("Program source instance is missing.");
|
|
13080
|
+
const exactKeys = (keys, expected) => keys.length === expected.length && keys.every((key) => expected.includes(key));
|
|
13081
|
+
if (!exactKeys(
|
|
13082
|
+
Object.keys(binding.refreshAliases),
|
|
13083
|
+
binding.definition.refreshAliases
|
|
13084
|
+
) || Object.values(binding.refreshAliases).some(
|
|
13085
|
+
(targets) => targets.some((target) => !dataIds.has(target))
|
|
13086
|
+
))
|
|
13087
|
+
issue(
|
|
13088
|
+
"Program refresh aliases must resolve exactly to declared data bindings."
|
|
13089
|
+
);
|
|
13090
|
+
if (!exactKeys(
|
|
13091
|
+
Object.keys(binding.stateAliases),
|
|
13092
|
+
binding.definition.stateAliases.map((entry) => entry.alias)
|
|
13093
|
+
))
|
|
13094
|
+
issue("Program state aliases must match its manifest.");
|
|
13095
|
+
for (const entry of binding.definition.stateAliases) {
|
|
13096
|
+
const state = page.stateDefinitions?.find(
|
|
13097
|
+
(state2) => state2.stateId === binding.stateAliases[entry.alias]
|
|
13098
|
+
);
|
|
13099
|
+
if (!state || !exactRevisionRef(state.schemaRevisionRef, entry.schemaRevisionRef))
|
|
13100
|
+
issue("Program state alias has an incompatible Schema.");
|
|
13101
|
+
}
|
|
13102
|
+
const dependencyIds = binding.definition.dependencies.map(
|
|
13103
|
+
(dep) => dep.revisionRef.id
|
|
13104
|
+
);
|
|
13105
|
+
if (!Object.keys(binding.dependencyInputs).every(
|
|
13106
|
+
(key) => dependencyIds.includes(key)
|
|
13107
|
+
))
|
|
13108
|
+
issue("Unknown program dependency input mapping.");
|
|
13109
|
+
for (const dep of binding.definition.dependencies) {
|
|
13110
|
+
if (Object.keys(binding.dependencyInputs[dep.revisionRef.id] ?? {}).some(
|
|
13111
|
+
(key) => dep.dynamicInputKeys.includes(key)
|
|
13112
|
+
))
|
|
13113
|
+
issue("Fixed dependency arguments cannot also be guest-writable.");
|
|
13114
|
+
}
|
|
13115
|
+
}
|
|
13116
|
+
}
|
|
12878
13117
|
var PageActionSchema = ActionBindingSchema.omit({
|
|
12879
13118
|
commandRevisionRef: true,
|
|
12880
13119
|
source: true,
|
|
@@ -12917,6 +13156,7 @@ var PageNodeSchema = z13.lazy(
|
|
|
12917
13156
|
}).strict().optional(),
|
|
12918
13157
|
data: z13.array(PageDataSchema).optional(),
|
|
12919
13158
|
actions: z13.array(PageActionSchema).optional(),
|
|
13159
|
+
programActions: z13.array(PageProgramActionSchema).max(128).optional(),
|
|
12920
13160
|
on: z13.array(PageInteractionSchema).optional(),
|
|
12921
13161
|
effects: z13.array(PageEventEffectSchema).optional(),
|
|
12922
13162
|
eventPayloads: z13.array(
|
|
@@ -12995,6 +13235,7 @@ var PageSchema = z13.object({
|
|
|
12995
13235
|
for (const [field, values, target] of [
|
|
12996
13236
|
["data", node.data ?? [], dataIds],
|
|
12997
13237
|
["actions", node.actions ?? [], actionIds],
|
|
13238
|
+
["programActions", node.programActions ?? [], actionIds],
|
|
12998
13239
|
["on", node.on ?? [], interactionIds]
|
|
12999
13240
|
])
|
|
13000
13241
|
for (const [index, value] of values.entries()) {
|
|
@@ -13048,6 +13289,7 @@ var ResolvedPageSchema = z13.object({
|
|
|
13048
13289
|
ontologyBindings: z13.array(PersistedOntologyBindingSchema),
|
|
13049
13290
|
queryBindings: z13.array(QueryBindingSchema).optional(),
|
|
13050
13291
|
actionBindings: z13.array(ActionBindingSchema),
|
|
13292
|
+
programBindings: z13.array(ProgramBindingSchema).max(128).optional(),
|
|
13051
13293
|
pageAccessPolicy: AccessPolicySchema,
|
|
13052
13294
|
managementAccess: ManagementAccessSchema,
|
|
13053
13295
|
tokenRevisionRefs: z13.array(RevisionRefSchema).min(1),
|
|
@@ -13060,6 +13302,7 @@ var ResolvedPageSchema = z13.object({
|
|
|
13060
13302
|
"restricted"
|
|
13061
13303
|
])
|
|
13062
13304
|
}).strict().superRefine((value, context) => {
|
|
13305
|
+
validateProgramBindingTargets(value, context);
|
|
13063
13306
|
validateDeclaredRouteSurfaces(
|
|
13064
13307
|
value.supportedSurfaces,
|
|
13065
13308
|
value.routeClaims,
|
|
@@ -13417,6 +13660,35 @@ var ResolvedPageSchema = z13.object({
|
|
|
13417
13660
|
)
|
|
13418
13661
|
);
|
|
13419
13662
|
}
|
|
13663
|
+
(value.programBindings ?? []).forEach((binding, index) => {
|
|
13664
|
+
const scopes = scopesForNode(
|
|
13665
|
+
instanceNodes.get(binding.source.capabilityInstanceId)
|
|
13666
|
+
);
|
|
13667
|
+
checkScopedSources(binding.inputMapping, scopes, [
|
|
13668
|
+
"programBindings",
|
|
13669
|
+
index,
|
|
13670
|
+
"inputMapping"
|
|
13671
|
+
]);
|
|
13672
|
+
for (const [id, mapping] of Object.entries(binding.dependencyInputs))
|
|
13673
|
+
checkScopedSources(mapping, scopes, [
|
|
13674
|
+
"programBindings",
|
|
13675
|
+
index,
|
|
13676
|
+
"dependencyInputs",
|
|
13677
|
+
id
|
|
13678
|
+
]);
|
|
13679
|
+
if (binding.when) {
|
|
13680
|
+
const reads = collectPageExpressionReads(binding.when);
|
|
13681
|
+
checkScopedReads(reads, scopes, ["programBindings", index, "when"]);
|
|
13682
|
+
if (reads.some(
|
|
13683
|
+
(read) => read.root === "state" && !stateIds.has(read.path[0])
|
|
13684
|
+
))
|
|
13685
|
+
context.addIssue({
|
|
13686
|
+
code: "custom",
|
|
13687
|
+
path: ["programBindings", index, "when"],
|
|
13688
|
+
message: "Program condition references an unknown Page state."
|
|
13689
|
+
});
|
|
13690
|
+
}
|
|
13691
|
+
});
|
|
13420
13692
|
value.actionBindings.forEach((binding, index) => {
|
|
13421
13693
|
const scopes = scopesForNode(
|
|
13422
13694
|
instanceNodes.get(binding.source.capabilityInstanceId)
|
|
@@ -13997,7 +14269,10 @@ var ResolvedPageSchema = z13.object({
|
|
|
13997
14269
|
const conflictingInteraction = interactionBindings.some(
|
|
13998
14270
|
(candidate) => candidate.source.capabilityInstanceId === sourceId && candidate.source.port === binding.cursorWindow.pageChangePort
|
|
13999
14271
|
);
|
|
14000
|
-
const conflictingAction =
|
|
14272
|
+
const conflictingAction = [
|
|
14273
|
+
...value.actionBindings,
|
|
14274
|
+
...value.programBindings ?? []
|
|
14275
|
+
].some(
|
|
14001
14276
|
(candidate) => candidate.source.capabilityInstanceId === sourceId && candidate.source.port === binding.cursorWindow.pageChangePort
|
|
14002
14277
|
);
|
|
14003
14278
|
if (conflictingInteraction || conflictingAction) {
|
|
@@ -14008,6 +14283,20 @@ var ResolvedPageSchema = z13.object({
|
|
|
14008
14283
|
});
|
|
14009
14284
|
}
|
|
14010
14285
|
});
|
|
14286
|
+
(value.programBindings ?? []).forEach((binding, index) => {
|
|
14287
|
+
validatePageStateSources(binding.inputMapping, [
|
|
14288
|
+
"programBindings",
|
|
14289
|
+
index,
|
|
14290
|
+
"inputMapping"
|
|
14291
|
+
]);
|
|
14292
|
+
for (const [id, mapping] of Object.entries(binding.dependencyInputs))
|
|
14293
|
+
validatePageStateSources(mapping, [
|
|
14294
|
+
"programBindings",
|
|
14295
|
+
index,
|
|
14296
|
+
"dependencyInputs",
|
|
14297
|
+
id
|
|
14298
|
+
]);
|
|
14299
|
+
});
|
|
14011
14300
|
value.actionBindings.forEach((binding, index) => {
|
|
14012
14301
|
if (!instanceIds.has(binding.source.capabilityInstanceId)) {
|
|
14013
14302
|
context.addIssue({
|
|
@@ -14848,6 +15137,7 @@ var CompatiblePageRuntimeBundleSchema = z13.object({
|
|
|
14848
15137
|
ontologyBindings: z13.array(PersistedOntologyBindingSchema),
|
|
14849
15138
|
queryBindings: z13.array(QueryBindingSchema).default([]),
|
|
14850
15139
|
actionBindings: z13.array(ActionBindingSchema),
|
|
15140
|
+
programBindings: z13.array(ProgramBindingSchema).max(128).optional(),
|
|
14851
15141
|
pageAccessPolicy: AccessPolicySchema,
|
|
14852
15142
|
tokenRevisionRefs: z13.array(RevisionRefSchema),
|
|
14853
15143
|
performanceBudgetRef: RevisionRefSchema,
|
|
@@ -14870,6 +15160,7 @@ var CompatiblePageRuntimeBundleSchema = z13.object({
|
|
|
14870
15160
|
message: "Denied capability identities must be unique declared instances."
|
|
14871
15161
|
});
|
|
14872
15162
|
}
|
|
15163
|
+
validateProgramBindingTargets(value, context);
|
|
14873
15164
|
validateRuntimeBundleBase(value, "page-release", context);
|
|
14874
15165
|
value.routeClaims.forEach((claim, index) => {
|
|
14875
15166
|
if (claim.surface !== value.surface) {
|
|
@@ -18493,6 +18784,17 @@ var pageDependencies = (page, compilerRevisionRef) => [
|
|
|
18493
18784
|
}
|
|
18494
18785
|
] : []
|
|
18495
18786
|
]),
|
|
18787
|
+
...(page.programBindings ?? []).flatMap((binding) => [
|
|
18788
|
+
{
|
|
18789
|
+
role: "action-program",
|
|
18790
|
+
revisionRef: binding.programRevisionRef
|
|
18791
|
+
},
|
|
18792
|
+
{
|
|
18793
|
+
role: "schema",
|
|
18794
|
+
revisionRef: binding.sourceIntentSchemaRevisionRef
|
|
18795
|
+
},
|
|
18796
|
+
...programDependencies(binding.definition)
|
|
18797
|
+
]),
|
|
18496
18798
|
...page.actionBindings.flatMap((binding) => [
|
|
18497
18799
|
{ role: "action", revisionRef: binding.commandRevisionRef },
|
|
18498
18800
|
{
|
|
@@ -18724,6 +19026,7 @@ var resolvePage = (input) => {
|
|
|
18724
19026
|
const capabilityInstances = [];
|
|
18725
19027
|
const queryBindings = [];
|
|
18726
19028
|
const actionBindings = [];
|
|
19029
|
+
const programBindings = [];
|
|
18727
19030
|
const interactionBindings = [];
|
|
18728
19031
|
const nodesById = /* @__PURE__ */ new Map();
|
|
18729
19032
|
const indexNode = (node) => {
|
|
@@ -18936,6 +19239,76 @@ var resolvePage = (input) => {
|
|
|
18936
19239
|
resultSchemaRevisionRef
|
|
18937
19240
|
});
|
|
18938
19241
|
}
|
|
19242
|
+
for (const [index, binding] of (node.programActions ?? []).entries()) {
|
|
19243
|
+
const path = `page.body.${node.id}.programActions[${index}]`;
|
|
19244
|
+
const matches = (input.programRegistry ?? []).filter(
|
|
19245
|
+
(entry) => entry.definition.programId === binding.program
|
|
19246
|
+
);
|
|
19247
|
+
if (matches.length !== 1)
|
|
19248
|
+
throw new DeclarativeControlCompilationError(
|
|
19249
|
+
"DEPENDENCY_MISSING",
|
|
19250
|
+
path,
|
|
19251
|
+
"Expected one exact program registration."
|
|
19252
|
+
);
|
|
19253
|
+
const program = matches[0];
|
|
19254
|
+
const definition = ActionProgramDefinitionSchema.parse(
|
|
19255
|
+
program.definition
|
|
19256
|
+
);
|
|
19257
|
+
assertProgramRegistration(program, page.tenantScope, page.surface, path);
|
|
19258
|
+
const port = registration.outputPorts.find(
|
|
19259
|
+
(candidate) => candidate.name === binding.port
|
|
19260
|
+
);
|
|
19261
|
+
if (!port)
|
|
19262
|
+
throw new DeclarativeControlCompilationError(
|
|
19263
|
+
"PORT_TYPE_MISMATCH",
|
|
19264
|
+
path,
|
|
19265
|
+
"Program source port is not registered."
|
|
19266
|
+
);
|
|
19267
|
+
if ((node.actions ?? []).some((action) => action.port === binding.port) || programBindings.some(
|
|
19268
|
+
(action) => action.source.capabilityInstanceId === node.id && action.source.port === binding.port
|
|
19269
|
+
))
|
|
19270
|
+
throw new DeclarativeControlCompilationError(
|
|
19271
|
+
"CAPABILITY_BINDING_MISMATCH",
|
|
19272
|
+
path,
|
|
19273
|
+
"A program output port must have one exclusive action binding."
|
|
19274
|
+
);
|
|
19275
|
+
for (const dep of definition.dependencies) {
|
|
19276
|
+
const registrations = dep.kind === "query" ? queryRegistrations : commandRegistrations;
|
|
19277
|
+
const actual = registrations.find(
|
|
19278
|
+
(entry) => sameRevisionRef(entry.revisionRef, dep.revisionRef)
|
|
19279
|
+
);
|
|
19280
|
+
if (!actual || canonicalContentHash(actual.definition) !== dep.revisionRef.contentHash || "sensitiveInputPaths" in actual.definition && !!actual.definition.sensitiveInputPaths?.length || "sensitiveResultPaths" in actual.definition && !!actual.definition.sensitiveResultPaths?.length || ("queryId" in actual.definition ? !sameRevisionRef(
|
|
19281
|
+
actual.definition.inputSchemaRevisionRef,
|
|
19282
|
+
dep.inputSchemaRevisionRef
|
|
19283
|
+
) || !sameRevisionRef(
|
|
19284
|
+
actual.definition.resultSchemaRevisionRef,
|
|
19285
|
+
dep.resultSchemaRevisionRef
|
|
19286
|
+
) : actual.definition.inputSchemaRef !== dep.inputSchemaRevisionRef.id || actual.definition.outputSchemaRef !== dep.resultSchemaRevisionRef.id))
|
|
19287
|
+
throw new DeclarativeControlCompilationError(
|
|
19288
|
+
"DEPENDENCY_MISSING",
|
|
19289
|
+
path,
|
|
19290
|
+
"Program capability/schema revision is not registered."
|
|
19291
|
+
);
|
|
19292
|
+
}
|
|
19293
|
+
for (const ref2 of programDependencies(definition).filter((dep) => dep.role === "schema").map((dep) => dep.revisionRef)) {
|
|
19294
|
+
if (!schemaRegistrations.some(
|
|
19295
|
+
(entry) => sameRevisionRef(entry.revisionRef, ref2)
|
|
19296
|
+
))
|
|
19297
|
+
throw new DeclarativeControlCompilationError(
|
|
19298
|
+
"SCHEMA_DEFINITION_MISMATCH",
|
|
19299
|
+
path,
|
|
19300
|
+
"Program requires an exact registered Schema."
|
|
19301
|
+
);
|
|
19302
|
+
}
|
|
19303
|
+
const { program: _program, port: _port, ...rest } = binding;
|
|
19304
|
+
programBindings.push({
|
|
19305
|
+
...rest,
|
|
19306
|
+
source: { capabilityInstanceId: node.id, port: binding.port },
|
|
19307
|
+
sourceIntentSchemaRevisionRef: port.schemaRevisionRef,
|
|
19308
|
+
programRevisionRef: program.definitionRevisionRef,
|
|
19309
|
+
definition
|
|
19310
|
+
});
|
|
19311
|
+
}
|
|
18939
19312
|
for (const [index, binding] of (node.on ?? []).entries()) {
|
|
18940
19313
|
const port = registration.outputPorts.find(
|
|
18941
19314
|
(candidate) => candidate.name === binding.port
|
|
@@ -19021,6 +19394,7 @@ var resolvePage = (input) => {
|
|
|
19021
19394
|
ontologyBindings: [],
|
|
19022
19395
|
...queryBindings.length ? { queryBindings } : {},
|
|
19023
19396
|
actionBindings,
|
|
19397
|
+
...programBindings.length ? { programBindings } : {},
|
|
19024
19398
|
pageAccessPolicy: page.access,
|
|
19025
19399
|
managementAccess: page.managementAccess,
|
|
19026
19400
|
tokenRevisionRefs,
|
|
@@ -19519,27 +19893,47 @@ var compilePageRuntimeBundleInternal = (input, legacy) => {
|
|
|
19519
19893
|
);
|
|
19520
19894
|
}
|
|
19521
19895
|
});
|
|
19522
|
-
page.
|
|
19523
|
-
const
|
|
19524
|
-
|
|
19525
|
-
|
|
19526
|
-
const registration = instance && registrationsByPair.get(
|
|
19527
|
-
`${revisionRefKey(instance.capabilityRevisionRef)}:${revisionRefKey(instance.providerRevisionRef)}`
|
|
19528
|
-
);
|
|
19529
|
-
const port = registration?.outputPorts.find(
|
|
19530
|
-
(candidate) => candidate.name === binding.source.port
|
|
19896
|
+
(page.programBindings ?? []).forEach((binding, index) => {
|
|
19897
|
+
const path = `programBindings[${index}]`;
|
|
19898
|
+
const registration = (input.programRegistry ?? []).find(
|
|
19899
|
+
(entry) => sameRevisionRef(entry.definitionRevisionRef, binding.programRevisionRef)
|
|
19531
19900
|
);
|
|
19532
|
-
if (!
|
|
19533
|
-
port.schemaRevisionRef,
|
|
19534
|
-
binding.sourceIntentSchemaRevisionRef
|
|
19535
|
-
)) {
|
|
19901
|
+
if (!registration || canonicalContentHash(registration.definition) !== canonicalContentHash(binding.definition))
|
|
19536
19902
|
throw new DeclarativeControlCompilationError(
|
|
19537
|
-
"
|
|
19538
|
-
|
|
19539
|
-
"
|
|
19903
|
+
"DEPENDENCY_MISSING",
|
|
19904
|
+
path,
|
|
19905
|
+
"Exact program registration does not match binding."
|
|
19540
19906
|
);
|
|
19541
|
-
|
|
19907
|
+
assertProgramRegistration(
|
|
19908
|
+
registration,
|
|
19909
|
+
page.tenantScope,
|
|
19910
|
+
release.target.surface,
|
|
19911
|
+
path
|
|
19912
|
+
);
|
|
19542
19913
|
});
|
|
19914
|
+
[...page.actionBindings, ...page.programBindings ?? []].forEach(
|
|
19915
|
+
(binding, index) => {
|
|
19916
|
+
const instance = page.capabilityInstances.find(
|
|
19917
|
+
(candidate) => candidate.instanceId === binding.source.capabilityInstanceId
|
|
19918
|
+
);
|
|
19919
|
+
const registration = instance && registrationsByPair.get(
|
|
19920
|
+
`${revisionRefKey(instance.capabilityRevisionRef)}:${revisionRefKey(instance.providerRevisionRef)}`
|
|
19921
|
+
);
|
|
19922
|
+
const port = registration?.outputPorts.find(
|
|
19923
|
+
(candidate) => candidate.name === binding.source.port
|
|
19924
|
+
);
|
|
19925
|
+
if (!port || !sameSchemaContract(
|
|
19926
|
+
port.schemaRevisionRef,
|
|
19927
|
+
binding.sourceIntentSchemaRevisionRef
|
|
19928
|
+
)) {
|
|
19929
|
+
throw new DeclarativeControlCompilationError(
|
|
19930
|
+
"PORT_TYPE_MISMATCH",
|
|
19931
|
+
`actionBindings[${index}].sourceIntentSchemaRevisionRef`,
|
|
19932
|
+
"Action source intent does not match the registered capability output port."
|
|
19933
|
+
);
|
|
19934
|
+
}
|
|
19935
|
+
}
|
|
19936
|
+
);
|
|
19543
19937
|
const routeClaims = compileRouteClaims({
|
|
19544
19938
|
claims: page.routeClaims,
|
|
19545
19939
|
routeSpaces: input.routeSpaces,
|
|
@@ -19693,6 +20087,7 @@ var compilePageRuntimeBundleInternal = (input, legacy) => {
|
|
|
19693
20087
|
ontologyBindings: page.ontologyBindings,
|
|
19694
20088
|
queryBindings: page.queryBindings,
|
|
19695
20089
|
actionBindings: page.actionBindings,
|
|
20090
|
+
...page.programBindings?.length ? { programBindings: page.programBindings } : {},
|
|
19696
20091
|
pageAccessPolicy: page.pageAccessPolicy,
|
|
19697
20092
|
tokenRevisionRefs: page.tokenRevisionRefs,
|
|
19698
20093
|
performanceBudgetRef: page.performanceBudgetRef,
|
|
@@ -20007,7 +20402,9 @@ var compileNavigationRuntimeBundle = (input) => {
|
|
|
20007
20402
|
input.compilerRevisionRef
|
|
20008
20403
|
);
|
|
20009
20404
|
const scope = TenantScopeSchema.parse(navigation.tenantScope);
|
|
20010
|
-
const verifiedKernelPageReferences = [
|
|
20405
|
+
const verifiedKernelPageReferences = [
|
|
20406
|
+
...input.verifiedKernelPageReferences ?? []
|
|
20407
|
+
].map((reference, index) => {
|
|
20011
20408
|
const parsed = RevisionRefSchema.parse(reference);
|
|
20012
20409
|
if (release.target.surface !== "kernel" || parsed.visibility !== "tenant" || !parsed.tenantScope?.teamRef?.id.startsWith("kernel-page.") || parsed.ownerRepo !== "monkeys-server" || !["page", "page-release"].includes(parsed.kind)) {
|
|
20013
20410
|
throw new DeclarativeControlCompilationError(
|
|
@@ -20221,8 +20618,14 @@ var compileNavigationRuntimeBundle = (input) => {
|
|
|
20221
20618
|
const released = releasedByNodeId.get(node.nodeId);
|
|
20222
20619
|
const unavailable = unavailableByNodeId.get(node.nodeId);
|
|
20223
20620
|
if (!registration && node.targetRef.kind === "page" && (unavailable && sameStableRef(unavailable.stableTargetRef, node.targetRef) || released && sameStableRef(released.stableTargetRef, node.targetRef))) {
|
|
20224
|
-
if (!released || !verifiedKernelPageReferenceKeys.has(
|
|
20225
|
-
|
|
20621
|
+
if (!released || !verifiedKernelPageReferenceKeys.has(
|
|
20622
|
+
revisionRefKey(released.targetRevisionRef)
|
|
20623
|
+
)) {
|
|
20624
|
+
assertTenantCompatible(
|
|
20625
|
+
node.targetRef,
|
|
20626
|
+
scope,
|
|
20627
|
+
`nodes[${index}].targetRef`
|
|
20628
|
+
);
|
|
20226
20629
|
}
|
|
20227
20630
|
if (unavailable?.accessPolicy && !accessPolicyChainImplies(
|
|
20228
20631
|
[...ancestors, node.audience],
|
|
@@ -20251,7 +20654,10 @@ var compileNavigationRuntimeBundle = (input) => {
|
|
|
20251
20654
|
if (!registration || !released && !(currentPage && unavailable && sameStableRef(unavailable.stableTargetRef, node.targetRef)) || !sameStableRef(
|
|
20252
20655
|
registration.stableTargetRef,
|
|
20253
20656
|
stableFromRevision(registration.targetRevisionRef)
|
|
20254
|
-
) || released && !sameStableRef(
|
|
20657
|
+
) || released && !sameStableRef(
|
|
20658
|
+
registration.stableTargetRef,
|
|
20659
|
+
released.stableTargetRef
|
|
20660
|
+
) || !currentPage && released && !sameRevisionRef(
|
|
20255
20661
|
registration.targetRevisionRef,
|
|
20256
20662
|
released.targetRevisionRef
|
|
20257
20663
|
) || !currentPage && released && registration.kind === "route" && (Boolean(registration.releaseRevisionRef) !== Boolean(released.releaseRevisionRef) || registration.releaseRevisionRef && released.releaseRevisionRef && !sameRevisionRef(
|
|
@@ -20513,6 +20919,33 @@ var resolveWorkbenchEntry = (input) => {
|
|
|
20513
20919
|
};
|
|
20514
20920
|
return { status: "forbidden", workbenchId: "" };
|
|
20515
20921
|
};
|
|
20922
|
+
var programDependencies = (definition) => [
|
|
20923
|
+
...[
|
|
20924
|
+
definition.inputSchemaRevisionRef,
|
|
20925
|
+
definition.resultSchemaRevisionRef,
|
|
20926
|
+
...definition.stateAliases.map((entry) => entry.schemaRevisionRef)
|
|
20927
|
+
].map((revisionRef) => ({ role: "schema", revisionRef })),
|
|
20928
|
+
...definition.dependencies.flatMap((dep) => [
|
|
20929
|
+
{
|
|
20930
|
+
role: dep.kind === "query" ? "query-definition" : "action",
|
|
20931
|
+
revisionRef: dep.revisionRef
|
|
20932
|
+
},
|
|
20933
|
+
{ role: "schema", revisionRef: dep.inputSchemaRevisionRef },
|
|
20934
|
+
{ role: "schema", revisionRef: dep.resultSchemaRevisionRef }
|
|
20935
|
+
])
|
|
20936
|
+
];
|
|
20937
|
+
function assertProgramRegistration(registration, scope, surface, path = "program") {
|
|
20938
|
+
const definition = ActionProgramDefinitionSchema.parse(
|
|
20939
|
+
registration.definition
|
|
20940
|
+
);
|
|
20941
|
+
const ref2 = RevisionRefSchema.parse(registration.definitionRevisionRef);
|
|
20942
|
+
if (ref2.kind !== "action-program" || ref2.id !== definition.programId || ref2.ownerRepo !== definition.ownerRepo || ref2.visibility !== "tenant" || canonicalContentHash(ref2.tenantScope) !== canonicalContentHash(scope) || canonicalContentHash(definition.tenantScope) !== canonicalContentHash(scope) || ref2.schemaVersion !== definition.schemaVersion || ref2.contentHash !== canonicalContentHash(definition) || definition.supportedSurface !== surface)
|
|
20943
|
+
throw new DeclarativeControlCompilationError(
|
|
20944
|
+
"CROSS_TENANT_REFERENCE",
|
|
20945
|
+
path,
|
|
20946
|
+
"Program identity, scope, surface or content hash does not match its exact reference."
|
|
20947
|
+
);
|
|
20948
|
+
}
|
|
20516
20949
|
|
|
20517
20950
|
// src/runtime/navigation-availability.ts
|
|
20518
20951
|
var NAVIGATION_UNAVAILABLE_CAPABILITY_HEADER = "x-monkeys-navigation-capabilities";
|
|
@@ -24698,6 +25131,19 @@ var assertDeclarativeCapabilityContract = (entry, request) => {
|
|
|
24698
25131
|
throw new TypeError("The historical capability snapshot is not supported by the current runtime contract.");
|
|
24699
25132
|
}
|
|
24700
25133
|
};
|
|
25134
|
+
var schemasCannotOverlap = (left, right) => {
|
|
25135
|
+
if (left === false || right === false) return true;
|
|
25136
|
+
if (!left || !right || typeof left !== "object" || typeof right !== "object" || Array.isArray(left) || Array.isArray(right)) return false;
|
|
25137
|
+
const a = left;
|
|
25138
|
+
const b = right;
|
|
25139
|
+
if (a.$ref || b.$ref) return false;
|
|
25140
|
+
const values = (schema2) => Object.prototype.hasOwnProperty.call(schema2, "const") ? [schema2.const] : Array.isArray(schema2.enum) ? schema2.enum : void 0;
|
|
25141
|
+
const av = values(a), bv = values(b);
|
|
25142
|
+
if (av && bv && av.every((value) => !bv.some((other) => canonicalContentHash(value) === canonicalContentHash(other)))) return true;
|
|
25143
|
+
if (a.type !== "object" || b.type !== "object") return false;
|
|
25144
|
+
const property = (schema2, key) => schema2.properties?.[key] ?? (schema2.patternProperties ? true : schema2.additionalProperties ?? true);
|
|
25145
|
+
return [...a.required ?? [], ...b.required ?? []].some((key) => schemasCannotOverlap(property(a, key), property(b, key)));
|
|
25146
|
+
};
|
|
24701
25147
|
var acceptsPreviousSchema = (previous, next) => {
|
|
24702
25148
|
if (canonicalContentHash(previous) === canonicalContentHash(next) || next === true) return true;
|
|
24703
25149
|
if (previous === false) return true;
|
|
@@ -24705,11 +25151,17 @@ var acceptsPreviousSchema = (previous, next) => {
|
|
|
24705
25151
|
const withoutAnnotations = (schema2) => Object.fromEntries(Object.entries(schema2).filter(([key]) => !["title", "description", "examples", "$comment"].includes(key)));
|
|
24706
25152
|
const before = withoutAnnotations(previous);
|
|
24707
25153
|
const after = withoutAnnotations(next);
|
|
25154
|
+
const branches = (schema2) => Object.keys(schema2).length === 1 ? Array.isArray(schema2.anyOf) ? schema2.anyOf : Array.isArray(schema2.oneOf) ? schema2.oneOf : void 0 : void 0;
|
|
25155
|
+
const oldBranches = branches(before);
|
|
25156
|
+
if (oldBranches) return oldBranches.every((branch) => acceptsPreviousSchema(branch, next));
|
|
25157
|
+
const newBranches = branches(after);
|
|
25158
|
+
if (newBranches) return newBranches.some((branch, index) => acceptsPreviousSchema(previous, branch) && (!after.oneOf || newBranches.every((other, otherIndex) => index === otherIndex || schemasCannotOverlap(previous, other))));
|
|
24708
25159
|
const {
|
|
24709
25160
|
properties: oldProperties,
|
|
24710
25161
|
required: oldRequired,
|
|
24711
25162
|
additionalProperties: oldAdditional,
|
|
24712
25163
|
enum: oldEnum,
|
|
25164
|
+
items: oldItems,
|
|
24713
25165
|
...oldFixed
|
|
24714
25166
|
} = before;
|
|
24715
25167
|
const {
|
|
@@ -24717,9 +25169,11 @@ var acceptsPreviousSchema = (previous, next) => {
|
|
|
24717
25169
|
required: newRequired,
|
|
24718
25170
|
additionalProperties: newAdditional,
|
|
24719
25171
|
enum: newEnum,
|
|
25172
|
+
items: newItems,
|
|
24720
25173
|
...newFixed
|
|
24721
25174
|
} = after;
|
|
24722
25175
|
if (canonicalContentHash(oldFixed) !== canonicalContentHash(newFixed)) return false;
|
|
25176
|
+
if (!acceptsPreviousSchema(oldItems ?? true, newItems ?? true)) return false;
|
|
24723
25177
|
if (newEnum && (!oldEnum || oldEnum.some((value) => !newEnum.some((candidate) => canonicalContentHash(candidate) === canonicalContentHash(value))))) return false;
|
|
24724
25178
|
if ((newRequired ?? []).some((key) => !(oldRequired ?? []).includes(key))) return false;
|
|
24725
25179
|
const oldExtra = oldAdditional ?? true;
|
|
@@ -25900,6 +26354,157 @@ function applyPageStreamEvent(state, input) {
|
|
|
25900
26354
|
error: frame.type === "error" ? frame.payload : void 0
|
|
25901
26355
|
};
|
|
25902
26356
|
}
|
|
26357
|
+
|
|
26358
|
+
// src/runtime/action-program-author.ts
|
|
26359
|
+
var import__2 = __toESM(require__());
|
|
26360
|
+
function programSchemaType(schema2, path = "$", depth = 0) {
|
|
26361
|
+
if (depth > 32 || !schema2 || typeof schema2 !== "object" || Array.isArray(schema2))
|
|
26362
|
+
throw new Error(`Unsupported schema at ${path}`);
|
|
26363
|
+
const value = schema2;
|
|
26364
|
+
const allowed = /* @__PURE__ */ new Set([
|
|
26365
|
+
"$schema",
|
|
26366
|
+
"$id",
|
|
26367
|
+
"title",
|
|
26368
|
+
"description",
|
|
26369
|
+
"type",
|
|
26370
|
+
"properties",
|
|
26371
|
+
"required",
|
|
26372
|
+
"additionalProperties",
|
|
26373
|
+
"items",
|
|
26374
|
+
"enum",
|
|
26375
|
+
"const",
|
|
26376
|
+
"anyOf",
|
|
26377
|
+
"oneOf",
|
|
26378
|
+
"minLength",
|
|
26379
|
+
"maxLength",
|
|
26380
|
+
"pattern",
|
|
26381
|
+
"format",
|
|
26382
|
+
"minimum",
|
|
26383
|
+
"maximum",
|
|
26384
|
+
"exclusiveMinimum",
|
|
26385
|
+
"exclusiveMaximum",
|
|
26386
|
+
"multipleOf",
|
|
26387
|
+
"minItems",
|
|
26388
|
+
"maxItems",
|
|
26389
|
+
"uniqueItems",
|
|
26390
|
+
"minProperties",
|
|
26391
|
+
"maxProperties",
|
|
26392
|
+
"default",
|
|
26393
|
+
"examples",
|
|
26394
|
+
"readOnly",
|
|
26395
|
+
"writeOnly"
|
|
26396
|
+
]);
|
|
26397
|
+
for (const key of Object.keys(value))
|
|
26398
|
+
if (!allowed.has(key))
|
|
26399
|
+
throw new Error(`Unsupported schema keyword ${path}.${key}`);
|
|
26400
|
+
const child = (schema3, key) => programSchemaType(schema3, `${path}.${key}`, depth + 1);
|
|
26401
|
+
const literal = (input) => {
|
|
26402
|
+
if (input !== null && !["string", "number", "boolean"].includes(typeof input))
|
|
26403
|
+
throw new Error(`Unsupported literal at ${path}`);
|
|
26404
|
+
return JSON.stringify(input);
|
|
26405
|
+
};
|
|
26406
|
+
if ("const" in value) return literal(value.const);
|
|
26407
|
+
if (Array.isArray(value.enum) && value.enum.length)
|
|
26408
|
+
return value.enum.map(literal).join(" | ");
|
|
26409
|
+
if (Array.isArray(value.anyOf) || Array.isArray(value.oneOf))
|
|
26410
|
+
return (value.anyOf ?? value.oneOf).map((schema3, i) => `(${child(schema3, String(i))})`).join(" | ") || "never";
|
|
26411
|
+
if (Array.isArray(value.type))
|
|
26412
|
+
return value.type.map((type) => child({ ...value, type }, String(type))).join(" | ");
|
|
26413
|
+
switch (value.type) {
|
|
26414
|
+
case "null":
|
|
26415
|
+
return "null";
|
|
26416
|
+
case "boolean":
|
|
26417
|
+
return "boolean";
|
|
26418
|
+
case "string":
|
|
26419
|
+
return "string";
|
|
26420
|
+
case "number":
|
|
26421
|
+
case "integer":
|
|
26422
|
+
return "number";
|
|
26423
|
+
case "array":
|
|
26424
|
+
return `Array<${child(value.items, "items")}>`;
|
|
26425
|
+
case "object": {
|
|
26426
|
+
const properties = value.properties ?? {};
|
|
26427
|
+
if (typeof properties !== "object" || !properties || Array.isArray(properties))
|
|
26428
|
+
throw new Error(`Invalid properties at ${path}`);
|
|
26429
|
+
const required = value.required ?? [];
|
|
26430
|
+
if (!Array.isArray(required) || required.some(
|
|
26431
|
+
(key) => typeof key !== "string" || !Object.prototype.hasOwnProperty.call(properties, key)
|
|
26432
|
+
))
|
|
26433
|
+
throw new Error(`Unsupported required keys at ${path}`);
|
|
26434
|
+
const fields = Object.entries(properties).map(
|
|
26435
|
+
([key, schema3]) => `${JSON.stringify(key)}${required.includes(key) ? "" : "?"}: ${child(schema3, key)};`
|
|
26436
|
+
);
|
|
26437
|
+
if (value.additionalProperties !== false) {
|
|
26438
|
+
if (value.additionalProperties !== void 0 && value.additionalProperties !== true)
|
|
26439
|
+
throw new Error(`Unsupported additionalProperties at ${path}`);
|
|
26440
|
+
fields.push("[key: string]: unknown;");
|
|
26441
|
+
}
|
|
26442
|
+
return `{ ${fields.join(" ")} }`;
|
|
26443
|
+
}
|
|
26444
|
+
default:
|
|
26445
|
+
throw new Error(`Schema needs a supported explicit type at ${path}`);
|
|
26446
|
+
}
|
|
26447
|
+
}
|
|
26448
|
+
function generateActionProgramTypes(definition, schemas) {
|
|
26449
|
+
const resolve = (ref2) => {
|
|
26450
|
+
const matches = schemas.filter(
|
|
26451
|
+
(entry) => sameRevisionRef(entry.definitionRevisionRef, ref2)
|
|
26452
|
+
);
|
|
26453
|
+
if (matches.length !== 1 || canonicalContentHash(matches[0].definition) !== ref2.contentHash)
|
|
26454
|
+
throw new Error(`Missing exact Schema ${ref2.id}`);
|
|
26455
|
+
return programSchemaType(matches[0].definition.document);
|
|
26456
|
+
};
|
|
26457
|
+
const formRefs = new Map(
|
|
26458
|
+
[
|
|
26459
|
+
definition.inputSchemaRevisionRef,
|
|
26460
|
+
definition.resultSchemaRevisionRef,
|
|
26461
|
+
...definition.dependencies.flatMap((dep) => [
|
|
26462
|
+
dep.inputSchemaRevisionRef,
|
|
26463
|
+
dep.resultSchemaRevisionRef
|
|
26464
|
+
])
|
|
26465
|
+
].map((ref2) => [ref2.id, ref2])
|
|
26466
|
+
);
|
|
26467
|
+
for (const ref2 of [
|
|
26468
|
+
definition.inputSchemaRevisionRef,
|
|
26469
|
+
definition.resultSchemaRevisionRef,
|
|
26470
|
+
...definition.dependencies.flatMap((dep) => [
|
|
26471
|
+
dep.inputSchemaRevisionRef,
|
|
26472
|
+
dep.resultSchemaRevisionRef
|
|
26473
|
+
])
|
|
26474
|
+
]) {
|
|
26475
|
+
if (!sameRevisionRef(formRefs.get(ref2.id), ref2))
|
|
26476
|
+
throw new Error("Ambiguous form Schema revision " + ref2.id);
|
|
26477
|
+
}
|
|
26478
|
+
const forms = "{" + [...formRefs].map(([id, ref2]) => JSON.stringify(id) + ": " + resolve(ref2) + ";").join(" ") + "}";
|
|
26479
|
+
const states = "{" + definition.stateAliases.map(
|
|
26480
|
+
(entry) => JSON.stringify(entry.alias) + ": " + resolve(entry.schemaRevisionRef) + ";"
|
|
26481
|
+
).join(" ") + "}";
|
|
26482
|
+
const refresh = definition.refreshAliases.map((alias) => JSON.stringify(alias)).join(" | ") || "never";
|
|
26483
|
+
const capabilityMap = (kind) => `{
|
|
26484
|
+
${definition.dependencies.filter((dep) => dep.kind === kind).map(
|
|
26485
|
+
(dep) => `${JSON.stringify(dep.revisionRef.id)}: {input: ${"Pick<" + resolve(dep.inputSchemaRevisionRef) + ", " + (dep.dynamicInputKeys.map((key) => JSON.stringify(key)).join(" | ") || "never") + ">"}; result: ${resolve(dep.resultSchemaRevisionRef)}};`
|
|
26486
|
+
).join("\n")}
|
|
26487
|
+
}`;
|
|
26488
|
+
return `// Generated from exact program/schema revisions. Do not edit.
|
|
26489
|
+
import type { ActionProgramContext } from "@inf-monkeys-tech/monkeys";
|
|
26490
|
+
export type Input = ${resolve(definition.inputSchemaRevisionRef)};
|
|
26491
|
+
export type Result = ${resolve(definition.resultSchemaRevisionRef)};
|
|
26492
|
+
export type Queries = ${capabilityMap("query")};
|
|
26493
|
+
export type Commands = ${capabilityMap("command")};
|
|
26494
|
+
export type BaseContext = ActionProgramContext<Queries, Commands, ${forms}, ${states}, ${refresh}>;
|
|
26495
|
+
export type Context = Omit<BaseContext, "ui" | "state"> & {ui: Pick<BaseContext["ui"], ${definition.effects.filter((effect) => !effect.startsWith("state.")).map((effect) => JSON.stringify(effect)).join(" | ") || "never"}>; state: Pick<BaseContext["state"], ${definition.effects.filter((effect) => effect.startsWith("state.")).map((effect) => JSON.stringify(effect.slice(6))).join(" | ") || "never"}>};
|
|
26496
|
+
export type Program = (context: Context, input: Input) => Promise<Result>;
|
|
26497
|
+
`;
|
|
26498
|
+
}
|
|
26499
|
+
function compileProgramValueValidator(schema2, documents = []) {
|
|
26500
|
+
const ajv2 = new import__2.default({ strict: false, allErrors: false, coerceTypes: false, removeAdditional: false, useDefaults: false });
|
|
26501
|
+
const ids = /* @__PURE__ */ new Set();
|
|
26502
|
+
for (const document of documents) if (typeof document.$id === "string" && document.$id !== schema2.$id && !ids.has(document.$id)) {
|
|
26503
|
+
ajv2.addSchema(document);
|
|
26504
|
+
ids.add(document.$id);
|
|
26505
|
+
}
|
|
26506
|
+
return ajv2.compile(schema2);
|
|
26507
|
+
}
|
|
25903
26508
|
export {
|
|
25904
26509
|
APPLICATION_HANDOFF_QUERY_PARAMETER,
|
|
25905
26510
|
DEFAULT_CONDUCTOR_OWNER_EMAIL,
|
|
@@ -25918,6 +26523,7 @@ export {
|
|
|
25918
26523
|
assertCompatibleCapabilityUpgrade,
|
|
25919
26524
|
assertDeclarativeCapabilityContract,
|
|
25920
26525
|
assertMonkeysThemeTokensComplete,
|
|
26526
|
+
assertProgramRegistration,
|
|
25921
26527
|
assertThemeTokensDocumentStructure,
|
|
25922
26528
|
assertViewProviderContract,
|
|
25923
26529
|
buildApplicationHandoffUrl,
|
|
@@ -25940,6 +26546,7 @@ export {
|
|
|
25940
26546
|
compileProductAccessDeclaration,
|
|
25941
26547
|
compileProductDeclaration,
|
|
25942
26548
|
compileProductRuntimeCatalog,
|
|
26549
|
+
compileProgramValueValidator,
|
|
25943
26550
|
compileRenderTree,
|
|
25944
26551
|
compileRouteClaims,
|
|
25945
26552
|
compileTargetRenderModelValidator,
|
|
@@ -25971,6 +26578,7 @@ export {
|
|
|
25971
26578
|
designCapabilityCatalogArtifactHash,
|
|
25972
26579
|
evaluatePageExpression,
|
|
25973
26580
|
extractOpenApiCapabilityManifests,
|
|
26581
|
+
generateActionProgramTypes,
|
|
25974
26582
|
isCompiledMenuItemSelected,
|
|
25975
26583
|
isDeclarativeRuntimeEnabled,
|
|
25976
26584
|
legacyRouteTakeoverAuthorizationHash,
|
|
@@ -25983,6 +26591,8 @@ export {
|
|
|
25983
26591
|
parseExactProductDeclarativeCapabilityRegistration,
|
|
25984
26592
|
parseWorkflowColumnBinding,
|
|
25985
26593
|
permissionAlternativePolicyAllows,
|
|
26594
|
+
programDependencies,
|
|
26595
|
+
programSchemaType,
|
|
25986
26596
|
projectAgentSessionEvents,
|
|
25987
26597
|
projectCurrentNavigationPages,
|
|
25988
26598
|
projectNavigationCompatibility,
|