@objectstack/objectql 6.8.1 → 7.0.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/dist/index.d.mts +8 -3
- package/dist/index.d.ts +8 -3
- package/dist/index.js +102 -23
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +109 -30
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -6
package/dist/index.mjs
CHANGED
|
@@ -129,7 +129,7 @@ var SchemaRegistry = class {
|
|
|
129
129
|
if (options.multiTenant !== void 0) {
|
|
130
130
|
this.multiTenant = options.multiTenant;
|
|
131
131
|
} else {
|
|
132
|
-
this.multiTenant = String(process.env.OS_MULTI_TENANT ?? "
|
|
132
|
+
this.multiTenant = String(process.env.OS_MULTI_TENANT ?? "false").toLowerCase() !== "false";
|
|
133
133
|
}
|
|
134
134
|
}
|
|
135
135
|
get logLevel() {
|
|
@@ -1151,14 +1151,14 @@ var SysMetadataRepository = class {
|
|
|
1151
1151
|
|
|
1152
1152
|
// src/protocol.ts
|
|
1153
1153
|
import { ConflictError as ConflictError2 } from "@objectstack/metadata-core";
|
|
1154
|
-
import { parseFilterAST, isFilterAST,
|
|
1154
|
+
import { parseFilterAST, isFilterAST, ObjectSchema as ObjectSchema2, FieldSchema, HookSchema } from "@objectstack/spec/data";
|
|
1155
1155
|
import { PLURAL_TO_SINGULAR as PLURAL_TO_SINGULAR2, SINGULAR_TO_PLURAL as SINGULAR_TO_PLURAL2 } from "@objectstack/spec/shared";
|
|
1156
|
-
import { ListViewSchema, FormViewSchema, DashboardSchema, AppSchema as AppSchema2, PageSchema, ReportSchema, ActionSchema
|
|
1157
|
-
import { RoleSchema
|
|
1158
|
-
import { PermissionSetSchema
|
|
1159
|
-
import { EmailTemplateSchema,
|
|
1160
|
-
import { ToolSchema, SkillSchema, AgentSchema
|
|
1161
|
-
import { FlowSchema, WorkflowRuleSchema, ApprovalProcessSchema
|
|
1156
|
+
import { ListViewSchema, FormViewSchema, DashboardSchema, AppSchema as AppSchema2, PageSchema, ReportSchema, ActionSchema } from "@objectstack/spec/ui";
|
|
1157
|
+
import { RoleSchema } from "@objectstack/spec/identity";
|
|
1158
|
+
import { PermissionSetSchema } from "@objectstack/spec/security";
|
|
1159
|
+
import { EmailTemplateSchema, JobSchema, METADATA_FORM_REGISTRY } from "@objectstack/spec/system";
|
|
1160
|
+
import { ToolSchema, SkillSchema, AgentSchema } from "@objectstack/spec/ai";
|
|
1161
|
+
import { FlowSchema, WorkflowRuleSchema, ApprovalProcessSchema } from "@objectstack/spec/automation";
|
|
1162
1162
|
import { DEFAULT_METADATA_TYPE_REGISTRY as DEFAULT_METADATA_TYPE_REGISTRY2 } from "@objectstack/spec/kernel";
|
|
1163
1163
|
import { z } from "zod";
|
|
1164
1164
|
var TYPE_TO_SCHEMA = {
|
|
@@ -1179,29 +1179,10 @@ var TYPE_TO_SCHEMA = {
|
|
|
1179
1179
|
flow: FlowSchema,
|
|
1180
1180
|
workflow: WorkflowRuleSchema,
|
|
1181
1181
|
approval: ApprovalProcessSchema,
|
|
1182
|
+
job: JobSchema,
|
|
1182
1183
|
hook: HookSchema
|
|
1183
1184
|
};
|
|
1184
|
-
var TYPE_TO_FORM =
|
|
1185
|
-
object: objectForm,
|
|
1186
|
-
field: fieldForm,
|
|
1187
|
-
hook: hookForm,
|
|
1188
|
-
report: reportForm,
|
|
1189
|
-
view: viewForm,
|
|
1190
|
-
app: appForm,
|
|
1191
|
-
dashboard: dashboardForm,
|
|
1192
|
-
role: roleForm,
|
|
1193
|
-
action: actionForm,
|
|
1194
|
-
page: pageForm,
|
|
1195
|
-
agent: agentForm,
|
|
1196
|
-
tool: toolForm,
|
|
1197
|
-
skill: skillForm,
|
|
1198
|
-
flow: flowForm,
|
|
1199
|
-
workflow: workflowForm,
|
|
1200
|
-
approval: approvalForm,
|
|
1201
|
-
permission: permissionForm,
|
|
1202
|
-
profile: permissionForm,
|
|
1203
|
-
email_template: emailTemplateForm
|
|
1204
|
-
};
|
|
1185
|
+
var TYPE_TO_FORM = METADATA_FORM_REGISTRY;
|
|
1205
1186
|
var _jsonSchemaCache = /* @__PURE__ */ new WeakMap();
|
|
1206
1187
|
function toJsonSchemaSafe(schema) {
|
|
1207
1188
|
const cached = _jsonSchemaCache.get(schema);
|
|
@@ -1311,6 +1292,81 @@ var HAND_CRAFTED_SCHEMAS = {
|
|
|
1311
1292
|
},
|
|
1312
1293
|
required: ["name", "label", "type"],
|
|
1313
1294
|
additionalProperties: true
|
|
1295
|
+
},
|
|
1296
|
+
// Validation rules live inside `object.validations[]`. The canonical
|
|
1297
|
+
// ValidationRuleSchema is a discriminated union of 9 variants; the
|
|
1298
|
+
// generic SchemaForm renderer treats unions as opaque JSON, so we
|
|
1299
|
+
// ship a *flat* form-friendly schema covering the common base
|
|
1300
|
+
// properties plus every variant-specific field as optional. Save-time
|
|
1301
|
+
// validation is unaffected — the union schema is still authoritative
|
|
1302
|
+
// at write time.
|
|
1303
|
+
validation: {
|
|
1304
|
+
type: "object",
|
|
1305
|
+
properties: {
|
|
1306
|
+
// --- Base fields (all variants) ---
|
|
1307
|
+
name: { type: "string", description: "Unique rule name (snake_case)" },
|
|
1308
|
+
label: { type: "string" },
|
|
1309
|
+
description: { type: "string" },
|
|
1310
|
+
type: {
|
|
1311
|
+
type: "string",
|
|
1312
|
+
enum: [
|
|
1313
|
+
"script",
|
|
1314
|
+
"unique",
|
|
1315
|
+
"state_machine",
|
|
1316
|
+
"format",
|
|
1317
|
+
"cross_field",
|
|
1318
|
+
"json",
|
|
1319
|
+
"async",
|
|
1320
|
+
"custom",
|
|
1321
|
+
"conditional"
|
|
1322
|
+
],
|
|
1323
|
+
default: "script",
|
|
1324
|
+
description: "Validation variant"
|
|
1325
|
+
},
|
|
1326
|
+
active: { type: "boolean", default: true },
|
|
1327
|
+
events: {
|
|
1328
|
+
type: "array",
|
|
1329
|
+
items: { type: "string", enum: ["insert", "update", "delete"] },
|
|
1330
|
+
default: ["insert", "update"]
|
|
1331
|
+
},
|
|
1332
|
+
priority: { type: "number", default: 100, minimum: 0, maximum: 9999 },
|
|
1333
|
+
severity: {
|
|
1334
|
+
type: "string",
|
|
1335
|
+
enum: ["error", "warning", "info"],
|
|
1336
|
+
default: "error"
|
|
1337
|
+
},
|
|
1338
|
+
message: { type: "string" },
|
|
1339
|
+
tags: { type: "array", items: { type: "string" } },
|
|
1340
|
+
// --- Variant-specific (all optional, gated by `type`) ---
|
|
1341
|
+
condition: {
|
|
1342
|
+
type: "string",
|
|
1343
|
+
description: "CEL predicate (type=script). True \u21D2 validation fails."
|
|
1344
|
+
},
|
|
1345
|
+
fields: {
|
|
1346
|
+
type: "array",
|
|
1347
|
+
items: { type: "string" },
|
|
1348
|
+
description: "Fields (type=unique / cross_field)."
|
|
1349
|
+
},
|
|
1350
|
+
scope: { type: "string", description: "CEL scope predicate (type=unique)." },
|
|
1351
|
+
caseSensitive: { type: "boolean", default: true },
|
|
1352
|
+
field: { type: "string", description: "Single field (type=state_machine / format)." },
|
|
1353
|
+
transitions: {
|
|
1354
|
+
type: "object",
|
|
1355
|
+
additionalProperties: { type: "array", items: { type: "string" } },
|
|
1356
|
+
description: "Map { OldState: [AllowedNewStates] } (type=state_machine)."
|
|
1357
|
+
},
|
|
1358
|
+
regex: { type: "string", description: "Regex (type=format)." },
|
|
1359
|
+
format: {
|
|
1360
|
+
type: "string",
|
|
1361
|
+
enum: ["email", "url", "phone", "json"],
|
|
1362
|
+
description: "Built-in format (type=format)."
|
|
1363
|
+
},
|
|
1364
|
+
url: { type: "string", description: "Endpoint URL (type=async)." },
|
|
1365
|
+
handler: { type: "string", description: "Handler reference (type=custom)." },
|
|
1366
|
+
when: { type: "string", description: "Outer condition (type=conditional)." }
|
|
1367
|
+
},
|
|
1368
|
+
required: ["name", "type", "message"],
|
|
1369
|
+
additionalProperties: true
|
|
1314
1370
|
}
|
|
1315
1371
|
};
|
|
1316
1372
|
var FORM_VIEW_TYPES = /* @__PURE__ */ new Set(["simple", "tabbed", "wizard", "split", "drawer", "modal"]);
|
|
@@ -4741,6 +4797,7 @@ var _ObjectQL = class _ObjectQL {
|
|
|
4741
4797
|
"workflows",
|
|
4742
4798
|
"approvals",
|
|
4743
4799
|
"webhooks",
|
|
4800
|
+
"jobs",
|
|
4744
4801
|
// Security Protocol
|
|
4745
4802
|
"roles",
|
|
4746
4803
|
"permissions",
|
|
@@ -6100,7 +6157,29 @@ var ObjectQLPlugin = class {
|
|
|
6100
6157
|
ctx.registerService("protocol", protocolShim);
|
|
6101
6158
|
ctx.logger.info("Protocol service registered");
|
|
6102
6159
|
ctx.registerService("analytics", {
|
|
6103
|
-
|
|
6160
|
+
// HttpDispatcher passes the raw POST body (AnalyticsQuery shape:
|
|
6161
|
+
// `{ cube, measures, dimensions, where?, filters?, ... }`). The
|
|
6162
|
+
// protocol shim's `analyticsQuery` expects the wrapped envelope
|
|
6163
|
+
// `{ cube, query }` and destructures `request.query` for dims /
|
|
6164
|
+
// measures. Reshape here so the destructure resolves to the
|
|
6165
|
+
// analytics query instead of `undefined` (which caused
|
|
6166
|
+
// "Cannot read properties of undefined (reading 'dimensions')").
|
|
6167
|
+
//
|
|
6168
|
+
// `analyticsQuery` also returns its own `{ success, data: { rows,
|
|
6169
|
+
// fields } }` envelope. HttpDispatcher wraps service responses
|
|
6170
|
+
// again with `success(result)`, so without unwrapping here the
|
|
6171
|
+
// client sees `{success, data:{success, data:{rows, fields}}}` —
|
|
6172
|
+
// KPI widgets read `data.rows` and silently get nothing. Unwrap
|
|
6173
|
+
// to the inner `{ rows, fields }` payload so a single wrap from
|
|
6174
|
+
// the dispatcher yields the canonical shape.
|
|
6175
|
+
query: async (body) => {
|
|
6176
|
+
const envelope = body && typeof body === "object" && "query" in body && "cube" in body ? body : { cube: body?.cube, query: body };
|
|
6177
|
+
const result = await protocolShim.analyticsQuery(envelope);
|
|
6178
|
+
if (result && typeof result === "object" && "success" in result && "data" in result) {
|
|
6179
|
+
return result.data;
|
|
6180
|
+
}
|
|
6181
|
+
return result;
|
|
6182
|
+
},
|
|
6104
6183
|
getMeta: async () => ({
|
|
6105
6184
|
cubes: [],
|
|
6106
6185
|
message: "Analytics meta endpoint not implemented by ObjectQL adapter"
|