skedyul 1.6.0 → 1.7.1
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/cli/index.js +77 -0
- package/dist/config/app-config.d.ts +11 -1
- package/dist/config/define.d.ts +39 -0
- package/dist/config/index.d.ts +1 -1
- package/dist/config/types/entity.d.ts +67 -0
- package/dist/config/types/form.d.ts +1 -9
- package/dist/config/types/index.d.ts +2 -0
- package/dist/config/types/setup.d.ts +37 -0
- package/dist/core/client.d.ts +39 -0
- package/dist/dedicated/server.js +77 -0
- package/dist/esm/index.mjs +191 -9
- package/dist/index.d.ts +4 -4
- package/dist/index.js +199 -10
- package/dist/schemas.d.ts +254 -18
- package/dist/server/handlers/index.d.ts +1 -0
- package/dist/server/handlers/setup-revalidate-handler.d.ts +9 -0
- package/dist/server/handlers/types.d.ts +34 -0
- package/dist/server/route-handlers/handlers.d.ts +4 -0
- package/dist/server/route-handlers/index.d.ts +1 -1
- package/dist/server.js +77 -0
- package/dist/serverless/server.mjs +77 -0
- package/dist/types/handlers.d.ts +42 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/invocation.d.ts +2 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -82,6 +82,9 @@ __export(index_exports, {
|
|
|
82
82
|
DatePickerComponentDefinitionSchema: () => DatePickerComponentDefinitionSchema,
|
|
83
83
|
DayOfWeekSchema: () => DayOfWeekSchema,
|
|
84
84
|
EmptyFormComponentDefinitionSchema: () => EmptyFormComponentDefinitionSchema,
|
|
85
|
+
EntityDefinitionSchema: () => EntityDefinitionSchema,
|
|
86
|
+
EntityFieldDefinitionSchema: () => EntityFieldDefinitionSchema,
|
|
87
|
+
EntityRelationshipDefinitionSchema: () => EntityRelationshipDefinitionSchema,
|
|
85
88
|
EnvSchemaSchema: () => EnvSchemaSchema,
|
|
86
89
|
EnvVariableDefinitionSchema: () => EnvVariableDefinitionSchema,
|
|
87
90
|
EnvVisibilitySchema: () => EnvVisibilitySchema,
|
|
@@ -152,7 +155,6 @@ __export(index_exports, {
|
|
|
152
155
|
ModelDefinitionSchema: () => ModelDefinitionSchema,
|
|
153
156
|
ModelDependencySchema: () => ModelDependencySchema,
|
|
154
157
|
ModelFieldDefinitionSchema: () => ModelFieldDefinitionSchema,
|
|
155
|
-
ModelMapperBlockDefinitionSchema: () => ModelMapperBlockDefinitionSchema,
|
|
156
158
|
MoneyMinorRangeSchema: () => MoneyMinorRangeSchema,
|
|
157
159
|
NavigationBreadcrumbSchema: () => NavigationBreadcrumbSchema,
|
|
158
160
|
NavigationConfigSchema: () => NavigationConfigSchema,
|
|
@@ -203,6 +205,8 @@ __export(index_exports, {
|
|
|
203
205
|
SequencerContextError: () => SequencerContextError,
|
|
204
206
|
SequencerLockError: () => SequencerLockError,
|
|
205
207
|
SequencerNotFoundError: () => SequencerNotFoundError,
|
|
208
|
+
SetupStepDefinitionSchema: () => SetupStepDefinitionSchema,
|
|
209
|
+
SetupStepKindSchema: () => SetupStepKindSchema,
|
|
206
210
|
SkedyulConfigSchema: () => SkedyulConfigSchema,
|
|
207
211
|
SkillExampleSchema: () => SkillExampleSchema,
|
|
208
212
|
SkillMetadataSchema: () => SkillMetadataSchema,
|
|
@@ -292,11 +296,13 @@ __export(index_exports, {
|
|
|
292
296
|
defineAgent: () => defineAgent,
|
|
293
297
|
defineChannel: () => defineChannel,
|
|
294
298
|
defineConfig: () => defineConfig,
|
|
299
|
+
defineEntity: () => defineEntity,
|
|
295
300
|
defineEnv: () => defineEnv,
|
|
296
301
|
defineModel: () => defineModel,
|
|
297
302
|
defineNavigation: () => defineNavigation,
|
|
298
303
|
definePage: () => definePage,
|
|
299
304
|
defineSchema: () => defineSchema,
|
|
305
|
+
defineSetupStep: () => defineSetupStep,
|
|
300
306
|
defineSkill: () => defineSkill,
|
|
301
307
|
defineWorkflow: () => defineWorkflow,
|
|
302
308
|
defineWorkflowYAML: () => defineWorkflowYAML,
|
|
@@ -358,6 +364,7 @@ __export(index_exports, {
|
|
|
358
364
|
sequencerAllow: () => allow,
|
|
359
365
|
sequencerRelease: () => release,
|
|
360
366
|
server: () => server,
|
|
367
|
+
setup: () => setup,
|
|
361
368
|
toGsm7: () => toGsm7,
|
|
362
369
|
token: () => token,
|
|
363
370
|
validateCRMSchema: () => validateCRMSchema,
|
|
@@ -1657,6 +1664,45 @@ var ModelDefinitionSchema = import_v48.z.object({
|
|
|
1657
1664
|
page: import_v48.z.string().optional(),
|
|
1658
1665
|
env: EnvSchemaSchema.optional()
|
|
1659
1666
|
});
|
|
1667
|
+
var EntityFieldDefinitionSchema = import_v48.z.object({
|
|
1668
|
+
handle: import_v48.z.string(),
|
|
1669
|
+
label: import_v48.z.string(),
|
|
1670
|
+
description: import_v48.z.string().optional(),
|
|
1671
|
+
type: import_v48.z.enum([
|
|
1672
|
+
"string",
|
|
1673
|
+
"long_string",
|
|
1674
|
+
"number",
|
|
1675
|
+
"boolean",
|
|
1676
|
+
"date",
|
|
1677
|
+
"datetime",
|
|
1678
|
+
"object"
|
|
1679
|
+
]).optional(),
|
|
1680
|
+
isUnique: import_v48.z.boolean().optional(),
|
|
1681
|
+
/** @deprecated Prefer isUnique */
|
|
1682
|
+
matchCandidate: import_v48.z.boolean().optional(),
|
|
1683
|
+
required: import_v48.z.boolean().optional(),
|
|
1684
|
+
options: import_v48.z.array(
|
|
1685
|
+
import_v48.z.union([
|
|
1686
|
+
import_v48.z.string(),
|
|
1687
|
+
import_v48.z.object({ value: import_v48.z.string(), label: import_v48.z.string() })
|
|
1688
|
+
])
|
|
1689
|
+
).optional()
|
|
1690
|
+
});
|
|
1691
|
+
var EntityRelationshipDefinitionSchema = import_v48.z.object({
|
|
1692
|
+
handle: import_v48.z.string(),
|
|
1693
|
+
label: import_v48.z.string(),
|
|
1694
|
+
targetEntity: import_v48.z.string().optional(),
|
|
1695
|
+
description: import_v48.z.string().optional()
|
|
1696
|
+
});
|
|
1697
|
+
var EntityDefinitionSchema = import_v48.z.object({
|
|
1698
|
+
handle: import_v48.z.string(),
|
|
1699
|
+
label: import_v48.z.string(),
|
|
1700
|
+
labelPlural: import_v48.z.string().optional(),
|
|
1701
|
+
description: import_v48.z.string().optional(),
|
|
1702
|
+
fields: import_v48.z.array(EntityFieldDefinitionSchema),
|
|
1703
|
+
contextFields: import_v48.z.array(EntityFieldDefinitionSchema).optional(),
|
|
1704
|
+
relationships: import_v48.z.array(EntityRelationshipDefinitionSchema).optional()
|
|
1705
|
+
});
|
|
1660
1706
|
var RelationshipCardinalitySchema = import_v48.z.enum([
|
|
1661
1707
|
"ONE_TO_ONE",
|
|
1662
1708
|
"ONE_TO_MANY"
|
|
@@ -2073,16 +2119,10 @@ var ListBlockDefinitionSchema = import_v48.z.object({
|
|
|
2073
2119
|
icon: import_v48.z.string().optional(),
|
|
2074
2120
|
emptyMessage: import_v48.z.string().optional()
|
|
2075
2121
|
});
|
|
2076
|
-
var ModelMapperBlockDefinitionSchema = import_v48.z.object({
|
|
2077
|
-
type: import_v48.z.literal("model_mapper"),
|
|
2078
|
-
/** The SHARED model handle from install config (e.g., "client", "patient") */
|
|
2079
|
-
model: import_v48.z.string()
|
|
2080
|
-
});
|
|
2081
2122
|
var PageBlockDefinitionSchema = import_v48.z.union([
|
|
2082
2123
|
CardBlockDefinitionSchema,
|
|
2083
2124
|
LegacyFormBlockDefinitionSchema,
|
|
2084
|
-
ListBlockDefinitionSchema
|
|
2085
|
-
ModelMapperBlockDefinitionSchema
|
|
2125
|
+
ListBlockDefinitionSchema
|
|
2086
2126
|
]);
|
|
2087
2127
|
var PageContextModeSchema = import_v48.z.enum(["first", "many", "count", "all"]).transform((val) => val === "all" ? "many" : val);
|
|
2088
2128
|
var PageContextFiltersSchema = import_v48.z.record(
|
|
@@ -2221,17 +2261,35 @@ var InstallConfigSchema = import_v48.z.object({
|
|
|
2221
2261
|
/** Relationship definitions between SHARED models */
|
|
2222
2262
|
relationships: import_v48.z.array(RelationshipDefinitionSchema).optional()
|
|
2223
2263
|
});
|
|
2264
|
+
var SetupStepKindSchema = import_v48.z.enum(["app", "crm", "realtime", "env"]);
|
|
2265
|
+
var SetupStepDefinitionSchema = import_v48.z.object({
|
|
2266
|
+
handle: import_v48.z.string(),
|
|
2267
|
+
label: import_v48.z.string(),
|
|
2268
|
+
description: import_v48.z.string().optional(),
|
|
2269
|
+
kind: SetupStepKindSchema,
|
|
2270
|
+
requires: import_v48.z.array(import_v48.z.string()).optional(),
|
|
2271
|
+
entities: import_v48.z.array(import_v48.z.string()).optional(),
|
|
2272
|
+
workflowHandles: import_v48.z.array(import_v48.z.string()).optional(),
|
|
2273
|
+
envKeys: import_v48.z.array(import_v48.z.string()).optional(),
|
|
2274
|
+
listenToCrm: import_v48.z.boolean().optional(),
|
|
2275
|
+
listenToEnv: import_v48.z.boolean().optional(),
|
|
2276
|
+
capabilities: import_v48.z.array(import_v48.z.string()).optional()
|
|
2277
|
+
});
|
|
2224
2278
|
var ProvisionConfigSchema = import_v48.z.object({
|
|
2225
2279
|
env: EnvSchemaSchema.optional(),
|
|
2226
2280
|
/** INTERNAL model definitions (app-owned, not visible to users) */
|
|
2227
2281
|
models: import_v48.z.array(ModelDefinitionSchema).optional(),
|
|
2282
|
+
/** App entity contracts for install-time CRM maps (not shared models) */
|
|
2283
|
+
entities: import_v48.z.array(EntityDefinitionSchema).optional(),
|
|
2228
2284
|
/** Relationship definitions between INTERNAL models */
|
|
2229
2285
|
relationships: import_v48.z.array(RelationshipDefinitionSchema).optional(),
|
|
2230
2286
|
channels: import_v48.z.array(ChannelDefinitionSchema).optional(),
|
|
2231
2287
|
workflows: import_v48.z.array(WorkflowDefinitionSchema).optional(),
|
|
2232
2288
|
/** Base navigation configuration for all pages (can be overridden per page) */
|
|
2233
2289
|
navigation: NavigationConfigSchema.optional(),
|
|
2234
|
-
pages: import_v48.z.array(PageDefinitionSchema).optional()
|
|
2290
|
+
pages: import_v48.z.array(PageDefinitionSchema).optional(),
|
|
2291
|
+
/** Install setup checklist steps (opt-in) */
|
|
2292
|
+
setup: import_v48.z.array(SetupStepDefinitionSchema).optional()
|
|
2235
2293
|
});
|
|
2236
2294
|
var SkedyulConfigSchema = import_v48.z.object({
|
|
2237
2295
|
name: import_v48.z.string(),
|
|
@@ -3880,6 +3938,47 @@ var report = {
|
|
|
3880
3938
|
return data;
|
|
3881
3939
|
}
|
|
3882
3940
|
};
|
|
3941
|
+
var setup = {
|
|
3942
|
+
async list() {
|
|
3943
|
+
const { data } = await callCore("setup.list", {});
|
|
3944
|
+
return data;
|
|
3945
|
+
},
|
|
3946
|
+
async get(handle) {
|
|
3947
|
+
const { data } = await callCore("setup.get", {
|
|
3948
|
+
handle
|
|
3949
|
+
});
|
|
3950
|
+
return data;
|
|
3951
|
+
},
|
|
3952
|
+
async complete(handle, metadata) {
|
|
3953
|
+
const { data } = await callCore("setup.complete", {
|
|
3954
|
+
handle,
|
|
3955
|
+
...metadata ? { metadata } : {}
|
|
3956
|
+
});
|
|
3957
|
+
return data;
|
|
3958
|
+
},
|
|
3959
|
+
async skip(handle, metadata) {
|
|
3960
|
+
const { data } = await callCore("setup.skip", {
|
|
3961
|
+
handle,
|
|
3962
|
+
...metadata ? { metadata } : {}
|
|
3963
|
+
});
|
|
3964
|
+
return data;
|
|
3965
|
+
},
|
|
3966
|
+
async invalidate(handle, reason, metadata) {
|
|
3967
|
+
const { data } = await callCore("setup.invalidate", {
|
|
3968
|
+
handle,
|
|
3969
|
+
...reason ? { reason } : {},
|
|
3970
|
+
...metadata ? { metadata } : {}
|
|
3971
|
+
});
|
|
3972
|
+
return data;
|
|
3973
|
+
},
|
|
3974
|
+
async capabilities() {
|
|
3975
|
+
const { data } = await callCore(
|
|
3976
|
+
"setup.capabilities",
|
|
3977
|
+
{}
|
|
3978
|
+
);
|
|
3979
|
+
return data.capabilities;
|
|
3980
|
+
}
|
|
3981
|
+
};
|
|
3883
3982
|
|
|
3884
3983
|
// src/ratelimit/context.ts
|
|
3885
3984
|
var import_async_hooks2 = require("async_hooks");
|
|
@@ -4914,6 +5013,72 @@ async function handleProvision(body, hooks) {
|
|
|
4914
5013
|
}
|
|
4915
5014
|
}
|
|
4916
5015
|
|
|
5016
|
+
// src/server/handlers/setup-revalidate-handler.ts
|
|
5017
|
+
async function handleSetupRevalidate(body, hooks) {
|
|
5018
|
+
const revalidateHook = hooks?.setup?.revalidate;
|
|
5019
|
+
if (!revalidateHook) {
|
|
5020
|
+
return {
|
|
5021
|
+
status: 404,
|
|
5022
|
+
body: { error: "Setup revalidate handler not configured" }
|
|
5023
|
+
};
|
|
5024
|
+
}
|
|
5025
|
+
if (!body.context?.appInstallationId || !body.context?.workplace || !body.context?.app || !body.reason || !Array.isArray(body.steps)) {
|
|
5026
|
+
return {
|
|
5027
|
+
status: 400,
|
|
5028
|
+
body: {
|
|
5029
|
+
error: {
|
|
5030
|
+
code: -32602,
|
|
5031
|
+
message: "Missing context (appInstallationId, workplace, app, reason, and steps required)"
|
|
5032
|
+
}
|
|
5033
|
+
}
|
|
5034
|
+
};
|
|
5035
|
+
}
|
|
5036
|
+
const ctx = {
|
|
5037
|
+
env: body.env ?? {},
|
|
5038
|
+
workplace: body.context.workplace,
|
|
5039
|
+
appInstallationId: body.context.appInstallationId,
|
|
5040
|
+
app: body.context.app,
|
|
5041
|
+
reason: body.reason,
|
|
5042
|
+
steps: body.steps,
|
|
5043
|
+
crm: body.crm,
|
|
5044
|
+
envChange: body.envChange,
|
|
5045
|
+
invocation: body.invocation,
|
|
5046
|
+
log: createContextLogger()
|
|
5047
|
+
};
|
|
5048
|
+
const requestConfig = {
|
|
5049
|
+
baseUrl: body.env?.SKEDYUL_API_URL ?? process.env.SKEDYUL_API_URL ?? "",
|
|
5050
|
+
apiToken: body.env?.SKEDYUL_API_TOKEN ?? process.env.SKEDYUL_API_TOKEN ?? ""
|
|
5051
|
+
};
|
|
5052
|
+
try {
|
|
5053
|
+
const handler = typeof revalidateHook === "function" ? revalidateHook : revalidateHook.handler;
|
|
5054
|
+
const result = await runWithLogContext(
|
|
5055
|
+
{ invocation: body.invocation },
|
|
5056
|
+
async () => {
|
|
5057
|
+
return await runWithConfig(requestConfig, async () => {
|
|
5058
|
+
return await handler(ctx);
|
|
5059
|
+
});
|
|
5060
|
+
}
|
|
5061
|
+
);
|
|
5062
|
+
return {
|
|
5063
|
+
status: 200,
|
|
5064
|
+
body: {
|
|
5065
|
+
completed: result?.completed ?? [],
|
|
5066
|
+
invalidated: result?.invalidated ?? []
|
|
5067
|
+
}
|
|
5068
|
+
};
|
|
5069
|
+
} catch (err) {
|
|
5070
|
+
return {
|
|
5071
|
+
status: 500,
|
|
5072
|
+
body: {
|
|
5073
|
+
error: {
|
|
5074
|
+
code: -32603,
|
|
5075
|
+
message: err instanceof Error ? err.message : String(err ?? "")
|
|
5076
|
+
}
|
|
5077
|
+
}
|
|
5078
|
+
};
|
|
5079
|
+
}
|
|
5080
|
+
}
|
|
5081
|
+
|
|
4917
5082
|
// src/server/handler-helpers.ts
|
|
4918
5083
|
function parseHandlerEnvelope(parsedBody) {
|
|
4919
5084
|
if (typeof parsedBody !== "object" || parsedBody === null || Array.isArray(parsedBody) || !("env" in parsedBody) || !("request" in parsedBody)) {
|
|
@@ -5300,6 +5465,14 @@ async function handleProvisionRoute(req, ctx) {
|
|
|
5300
5465
|
const result = await handleProvision(parseResult.data, ctx.config.hooks);
|
|
5301
5466
|
return { status: result.status, body: result.body };
|
|
5302
5467
|
}
|
|
5468
|
+
async function handleSetupRevalidateRoute(req, ctx) {
|
|
5469
|
+
const parseResult = parseJsonBody(req);
|
|
5470
|
+
if (!parseResult.success) {
|
|
5471
|
+
return parseResult.error;
|
|
5472
|
+
}
|
|
5473
|
+
const result = await handleSetupRevalidate(parseResult.data, ctx.config.hooks);
|
|
5474
|
+
return { status: result.status, body: result.body };
|
|
5475
|
+
}
|
|
5303
5476
|
async function handleOAuthCallbackRoute(req, ctx) {
|
|
5304
5477
|
const parseResult = parseJsonBody(req);
|
|
5305
5478
|
if (!parseResult.success) {
|
|
@@ -5661,6 +5834,9 @@ async function routeRequest(req, ctx) {
|
|
|
5661
5834
|
if (req.path === "/provision" && req.method === "POST") {
|
|
5662
5835
|
return handleProvisionRoute(req, ctx);
|
|
5663
5836
|
}
|
|
5837
|
+
if (req.path === "/setup/revalidate" && req.method === "POST") {
|
|
5838
|
+
return handleSetupRevalidateRoute(req, ctx);
|
|
5839
|
+
}
|
|
5664
5840
|
if (req.path === "/oauth_callback" && req.method === "POST") {
|
|
5665
5841
|
return handleOAuthCallbackRoute(req, ctx);
|
|
5666
5842
|
}
|
|
@@ -6115,6 +6291,9 @@ function defineConfig(config) {
|
|
|
6115
6291
|
function defineModel(model) {
|
|
6116
6292
|
return model;
|
|
6117
6293
|
}
|
|
6294
|
+
function defineEntity(entity) {
|
|
6295
|
+
return entity;
|
|
6296
|
+
}
|
|
6118
6297
|
function defineChannel(channel) {
|
|
6119
6298
|
return channel;
|
|
6120
6299
|
}
|
|
@@ -6133,6 +6312,9 @@ function defineEnv(env) {
|
|
|
6133
6312
|
function defineNavigation(navigation) {
|
|
6134
6313
|
return navigation;
|
|
6135
6314
|
}
|
|
6315
|
+
function defineSetupStep(step) {
|
|
6316
|
+
return step;
|
|
6317
|
+
}
|
|
6136
6318
|
|
|
6137
6319
|
// src/config/schema-loader.ts
|
|
6138
6320
|
var fs4 = __toESM(require("fs"));
|
|
@@ -8598,6 +8780,9 @@ var index_default = { z: import_v414.z };
|
|
|
8598
8780
|
DatePickerComponentDefinitionSchema,
|
|
8599
8781
|
DayOfWeekSchema,
|
|
8600
8782
|
EmptyFormComponentDefinitionSchema,
|
|
8783
|
+
EntityDefinitionSchema,
|
|
8784
|
+
EntityFieldDefinitionSchema,
|
|
8785
|
+
EntityRelationshipDefinitionSchema,
|
|
8601
8786
|
EnvSchemaSchema,
|
|
8602
8787
|
EnvVariableDefinitionSchema,
|
|
8603
8788
|
EnvVisibilitySchema,
|
|
@@ -8668,7 +8853,6 @@ var index_default = { z: import_v414.z };
|
|
|
8668
8853
|
ModelDefinitionSchema,
|
|
8669
8854
|
ModelDependencySchema,
|
|
8670
8855
|
ModelFieldDefinitionSchema,
|
|
8671
|
-
ModelMapperBlockDefinitionSchema,
|
|
8672
8856
|
MoneyMinorRangeSchema,
|
|
8673
8857
|
NavigationBreadcrumbSchema,
|
|
8674
8858
|
NavigationConfigSchema,
|
|
@@ -8719,6 +8903,8 @@ var index_default = { z: import_v414.z };
|
|
|
8719
8903
|
SequencerContextError,
|
|
8720
8904
|
SequencerLockError,
|
|
8721
8905
|
SequencerNotFoundError,
|
|
8906
|
+
SetupStepDefinitionSchema,
|
|
8907
|
+
SetupStepKindSchema,
|
|
8722
8908
|
SkedyulConfigSchema,
|
|
8723
8909
|
SkillExampleSchema,
|
|
8724
8910
|
SkillMetadataSchema,
|
|
@@ -8807,11 +8993,13 @@ var index_default = { z: import_v414.z };
|
|
|
8807
8993
|
defineAgent,
|
|
8808
8994
|
defineChannel,
|
|
8809
8995
|
defineConfig,
|
|
8996
|
+
defineEntity,
|
|
8810
8997
|
defineEnv,
|
|
8811
8998
|
defineModel,
|
|
8812
8999
|
defineNavigation,
|
|
8813
9000
|
definePage,
|
|
8814
9001
|
defineSchema,
|
|
9002
|
+
defineSetupStep,
|
|
8815
9003
|
defineSkill,
|
|
8816
9004
|
defineWorkflow,
|
|
8817
9005
|
defineWorkflowYAML,
|
|
@@ -8873,6 +9061,7 @@ var index_default = { z: import_v414.z };
|
|
|
8873
9061
|
sequencerAllow,
|
|
8874
9062
|
sequencerRelease,
|
|
8875
9063
|
server,
|
|
9064
|
+
setup,
|
|
8876
9065
|
toGsm7,
|
|
8877
9066
|
token,
|
|
8878
9067
|
validateCRMSchema,
|