skedyul 1.7.12 → 1.7.14

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/.build-stamp CHANGED
@@ -1 +1 @@
1
- 1786072268866
1
+ 1786097937910
package/dist/cli/index.js CHANGED
@@ -1151,6 +1151,12 @@ function parseEnvFieldsFromBlock(envBlock) {
1151
1151
  if (descMatch) field.description = descMatch[1];
1152
1152
  const scopeMatch = varContent.match(/scope\s*:\s*['"`](provision|install)['"`]/);
1153
1153
  if (scopeMatch) field.scope = scopeMatch[1];
1154
+ const installPhaseMatch = varContent.match(
1155
+ /installPhase\s*:\s*['"`](pre_install|post_install)['"`]/
1156
+ );
1157
+ if (installPhaseMatch) {
1158
+ field.installPhase = installPhaseMatch[1];
1159
+ }
1154
1160
  envVars[varName] = field;
1155
1161
  }
1156
1162
  return envVars;
@@ -1258,11 +1264,25 @@ function buildInstallEnvForSync(legacyInstall, provisionConfig) {
1258
1264
  }
1259
1265
  }
1260
1266
  }
1261
- return Object.keys(installEnv).length > 0 ? installEnv : void 0;
1267
+ if (Object.keys(installEnv).length === 0) {
1268
+ return void 0;
1269
+ }
1270
+ const pre = {};
1271
+ const post = {};
1272
+ for (const [key, def] of Object.entries(installEnv)) {
1273
+ if (def.installPhase === "post_install") {
1274
+ post[key] = def;
1275
+ } else {
1276
+ pre[key] = def;
1277
+ }
1278
+ }
1279
+ return { pre, post };
1262
1280
  }
1263
1281
  function filterEnvForInstallWorkflow(env, installConfig) {
1264
1282
  const installKeys = new Set(
1265
- Object.entries(installConfig?.env ?? {}).filter(([, def]) => def.scope === "install").map(([key]) => key)
1283
+ Object.entries(installConfig?.env ?? {}).filter(
1284
+ ([, def]) => def.scope === "install" && def.installPhase !== "post_install"
1285
+ ).map(([key]) => key)
1266
1286
  );
1267
1287
  if (installKeys.size === 0) {
1268
1288
  return {};
@@ -1321,7 +1341,7 @@ async function buildExecutableSyncConfig(registry, inputSchemaToJson, projectDir
1321
1341
  env: buildProvisionEnvFromInstallConfig(legacyInstallConfig.env)
1322
1342
  };
1323
1343
  }
1324
- const installEnv = buildInstallEnvForSync(legacyInstallConfig, provisionConfig ?? null);
1344
+ const installEnvSplit = buildInstallEnvForSync(legacyInstallConfig, provisionConfig ?? null);
1325
1345
  return {
1326
1346
  name: appConfig?.name,
1327
1347
  handle: appConfig?.handle,
@@ -1329,7 +1349,8 @@ async function buildExecutableSyncConfig(registry, inputSchemaToJson, projectDir
1329
1349
  tools,
1330
1350
  ...webhooks.length > 0 ? { webhooks } : {},
1331
1351
  ...provision ? { provision } : {},
1332
- ...installEnv ? { install: { env: installEnv } } : {},
1352
+ ...installEnvSplit && Object.keys(installEnvSplit.pre).length > 0 ? { install: { env: installEnvSplit.pre } } : {},
1353
+ ...installEnvSplit && Object.keys(installEnvSplit.post).length > 0 ? { installPost: { env: installEnvSplit.post } } : {},
1333
1354
  syncedAt: (/* @__PURE__ */ new Date()).toISOString()
1334
1355
  };
1335
1356
  }
@@ -23,6 +23,7 @@ export interface InstallEnvField {
23
23
  placeholder?: string;
24
24
  description?: string;
25
25
  scope?: 'provision' | 'install';
26
+ installPhase?: 'pre_install' | 'post_install';
26
27
  }
27
28
  export interface InstallConfigData {
28
29
  env?: Record<string, InstallEnvField>;
@@ -45,7 +46,7 @@ export declare function loadInstallHandler(projectDir?: string): Promise<((ctx:
45
46
  export declare function filterInstallScopedEnv(env: Record<string, InstallEnvField & {
46
47
  scope?: string;
47
48
  }>): Record<string, InstallEnvField>;
48
- /** Env vars passed to the install workflow (install-scoped only). */
49
+ /** Env vars passed to the install workflow (pre_install install-scoped only). */
49
50
  export declare function filterEnvForInstallWorkflow(env: Record<string, string>, installConfig: InstallConfigData | null): Record<string, string>;
50
51
  /**
51
52
  * Load provision config (env, models, pages) directly from src/provision/index.ts.
@@ -0,0 +1,13 @@
1
+ import type { EnvSchema, EnvVariable, InstallPhase } from './types/env';
2
+ export type { InstallPhase };
3
+ /** Default install collection phase when omitted on install-scoped vars. */
4
+ export declare const DEFAULT_INSTALL_PHASE: InstallPhase;
5
+ export declare function resolveInstallPhase(def: Pick<EnvVariable, 'scope' | 'installPhase' | 'required'>): InstallPhase | null;
6
+ export declare function isPreInstallEnvVar(def: Pick<EnvVariable, 'scope' | 'installPhase' | 'required'>): boolean;
7
+ export declare function isPostInstallEnvVar(def: Pick<EnvVariable, 'scope' | 'installPhase' | 'required'>): boolean;
8
+ export declare function filterEnvSchemaByInstallPhase(env: EnvSchema | undefined, phase: InstallPhase): EnvSchema;
9
+ export declare function splitProvisionEnvSchema(env: EnvSchema | undefined): {
10
+ global: EnvSchema;
11
+ preInstall: EnvSchema;
12
+ postInstall: EnvSchema;
13
+ };
@@ -15,3 +15,4 @@ export { defineModel, defineEntity, defineChannel, definePage, defineWorkflow, d
15
15
  export { SCHEMA_FILE_EXTENSIONS, loadSchema, saveSchema, serializeSchemaToJson, serializeSchemaToTypeScript, transformToBackendSchema, transformFromBackendSchema, type LoadSchemaOptions, type LoadSchemaResult, type SerializeSchemaOptions, type BackendModelDefinition, type BackendFieldDefinition, type BackendRelationshipDefinition, type BackendDesiredSchema, } from './schema-loader';
16
16
  export { loadAndResolveConfig, serializeResolvedConfig, type ResolvedConfig } from './resolver';
17
17
  export { getAllEnvKeys, getRequiredInstallEnvKeys } from './utils';
18
+ export { DEFAULT_INSTALL_PHASE, resolveInstallPhase, isPreInstallEnvVar, isPostInstallEnvVar, filterEnvSchemaByInstallPhase, splitProvisionEnvSchema, type InstallPhase, } from './env-phase';
@@ -12,6 +12,12 @@ import type { Visibility } from './base';
12
12
  * - 'install': User-configured during app installation
13
13
  */
14
14
  export type EnvScope = 'provision' | 'install';
15
+ /**
16
+ * When an install-scoped variable is collected from the user vs set by the app/platform.
17
+ * - 'pre_install': user fills on the install page before Install is clicked
18
+ * - 'post_install': set by OAuth callback, install handler, or runtime (never on pre-install form)
19
+ */
20
+ export type InstallPhase = 'pre_install' | 'post_install';
15
21
  /**
16
22
  * Environment variable definition.
17
23
  */
@@ -20,6 +26,8 @@ export interface EnvVariable {
20
26
  label: string;
21
27
  /** Scope: 'provision' (developer) or 'install' (user) */
22
28
  scope?: EnvScope;
29
+ /** When to collect install-scoped vars (default: 'pre_install') */
30
+ installPhase?: InstallPhase;
23
31
  /** Whether this variable is required */
24
32
  required?: boolean;
25
33
  /** Visibility setting: 'visible' or 'encrypted' */
@@ -1168,8 +1168,11 @@ var AgentYAMLV3Schema = z7.object({
1168
1168
 
1169
1169
  // src/schemas.ts
1170
1170
  var EnvVisibilitySchema = z8.enum(["visible", "encrypted"]);
1171
+ var InstallPhaseSchema = z8.enum(["pre_install", "post_install"]);
1171
1172
  var EnvVariableDefinitionSchema = z8.object({
1172
1173
  label: z8.string(),
1174
+ scope: z8.enum(["provision", "install"]).optional(),
1175
+ installPhase: InstallPhaseSchema.optional(),
1173
1176
  required: z8.boolean().optional(),
1174
1177
  visibility: EnvVisibilitySchema.optional(),
1175
1178
  default: z8.string().optional(),
@@ -6297,6 +6300,24 @@ import * as os from "os";
6297
6300
  import * as fs5 from "fs";
6298
6301
  import * as path5 from "path";
6299
6302
 
6303
+ // src/config/env-phase.ts
6304
+ var DEFAULT_INSTALL_PHASE = "pre_install";
6305
+ function resolveInstallPhase(def) {
6306
+ if (def.scope === "provision") {
6307
+ return null;
6308
+ }
6309
+ if (def.installPhase === "post_install" || def.installPhase === "pre_install") {
6310
+ return def.installPhase;
6311
+ }
6312
+ if (def.scope === "install") {
6313
+ return def.required ? "pre_install" : "post_install";
6314
+ }
6315
+ return DEFAULT_INSTALL_PHASE;
6316
+ }
6317
+ function isPreInstallEnvVar(def) {
6318
+ return resolveInstallPhase(def) === "pre_install";
6319
+ }
6320
+
6300
6321
  // src/config/utils.ts
6301
6322
  function getAllEnvKeys(config) {
6302
6323
  const provision = config.provision && "env" in config.provision ? config.provision : void 0;
@@ -6309,7 +6330,7 @@ function getAllEnvKeys(config) {
6309
6330
  function getRequiredInstallEnvKeys(config) {
6310
6331
  const provision = config.provision && "env" in config.provision ? config.provision : void 0;
6311
6332
  if (!provision?.env) return [];
6312
- return Object.entries(provision.env).filter(([, def]) => def.required).map(([key]) => key);
6333
+ return Object.entries(provision.env).filter(([, def]) => def.scope === "install" && isPreInstallEnvVar(def) && def.required).map(([key]) => key);
6313
6334
  }
6314
6335
 
6315
6336
  // src/ratelimit/resolve-queue-key.ts
@@ -8814,6 +8835,7 @@ export {
8814
8835
  InputMappingSchema,
8815
8836
  InstallConfigSchema,
8816
8837
  InstallError,
8838
+ InstallPhaseSchema,
8817
8839
  InvalidConfigurationError,
8818
8840
  LegacyFormBlockDefinitionSchema,
8819
8841
  ListBlockDefinitionSchema,
package/dist/index.js CHANGED
@@ -125,6 +125,7 @@ __export(index_exports, {
125
125
  InputMappingSchema: () => InputMappingSchema,
126
126
  InstallConfigSchema: () => InstallConfigSchema,
127
127
  InstallError: () => InstallError,
128
+ InstallPhaseSchema: () => InstallPhaseSchema,
128
129
  InvalidConfigurationError: () => InvalidConfigurationError,
129
130
  LegacyFormBlockDefinitionSchema: () => LegacyFormBlockDefinitionSchema,
130
131
  ListBlockDefinitionSchema: () => ListBlockDefinitionSchema,
@@ -1549,8 +1550,11 @@ var AgentYAMLV3Schema = import_v47.z.object({
1549
1550
 
1550
1551
  // src/schemas.ts
1551
1552
  var EnvVisibilitySchema = import_v48.z.enum(["visible", "encrypted"]);
1553
+ var InstallPhaseSchema = import_v48.z.enum(["pre_install", "post_install"]);
1552
1554
  var EnvVariableDefinitionSchema = import_v48.z.object({
1553
1555
  label: import_v48.z.string(),
1556
+ scope: import_v48.z.enum(["provision", "install"]).optional(),
1557
+ installPhase: InstallPhaseSchema.optional(),
1554
1558
  required: import_v48.z.boolean().optional(),
1555
1559
  visibility: EnvVisibilitySchema.optional(),
1556
1560
  default: import_v48.z.string().optional(),
@@ -6678,6 +6682,24 @@ var os = __toESM(require("os"));
6678
6682
  var fs5 = __toESM(require("fs"));
6679
6683
  var path5 = __toESM(require("path"));
6680
6684
 
6685
+ // src/config/env-phase.ts
6686
+ var DEFAULT_INSTALL_PHASE = "pre_install";
6687
+ function resolveInstallPhase(def) {
6688
+ if (def.scope === "provision") {
6689
+ return null;
6690
+ }
6691
+ if (def.installPhase === "post_install" || def.installPhase === "pre_install") {
6692
+ return def.installPhase;
6693
+ }
6694
+ if (def.scope === "install") {
6695
+ return def.required ? "pre_install" : "post_install";
6696
+ }
6697
+ return DEFAULT_INSTALL_PHASE;
6698
+ }
6699
+ function isPreInstallEnvVar(def) {
6700
+ return resolveInstallPhase(def) === "pre_install";
6701
+ }
6702
+
6681
6703
  // src/config/utils.ts
6682
6704
  function getAllEnvKeys(config) {
6683
6705
  const provision = config.provision && "env" in config.provision ? config.provision : void 0;
@@ -6690,7 +6712,7 @@ function getAllEnvKeys(config) {
6690
6712
  function getRequiredInstallEnvKeys(config) {
6691
6713
  const provision = config.provision && "env" in config.provision ? config.provision : void 0;
6692
6714
  if (!provision?.env) return [];
6693
- return Object.entries(provision.env).filter(([, def]) => def.required).map(([key]) => key);
6715
+ return Object.entries(provision.env).filter(([, def]) => def.scope === "install" && isPreInstallEnvVar(def) && def.required).map(([key]) => key);
6694
6716
  }
6695
6717
 
6696
6718
  // src/ratelimit/resolve-queue-key.ts
@@ -9196,6 +9218,7 @@ var index_default = { z: import_v414.z };
9196
9218
  InputMappingSchema,
9197
9219
  InstallConfigSchema,
9198
9220
  InstallError,
9221
+ InstallPhaseSchema,
9199
9222
  InvalidConfigurationError,
9200
9223
  LegacyFormBlockDefinitionSchema,
9201
9224
  ListBlockDefinitionSchema,
package/dist/schemas.d.ts CHANGED
@@ -3,8 +3,20 @@ export declare const EnvVisibilitySchema: z.ZodEnum<{
3
3
  visible: "visible";
4
4
  encrypted: "encrypted";
5
5
  }>;
6
+ export declare const InstallPhaseSchema: z.ZodEnum<{
7
+ pre_install: "pre_install";
8
+ post_install: "post_install";
9
+ }>;
6
10
  export declare const EnvVariableDefinitionSchema: z.ZodObject<{
7
11
  label: z.ZodString;
12
+ scope: z.ZodOptional<z.ZodEnum<{
13
+ provision: "provision";
14
+ install: "install";
15
+ }>>;
16
+ installPhase: z.ZodOptional<z.ZodEnum<{
17
+ pre_install: "pre_install";
18
+ post_install: "post_install";
19
+ }>>;
8
20
  required: z.ZodOptional<z.ZodBoolean>;
9
21
  visibility: z.ZodOptional<z.ZodEnum<{
10
22
  visible: "visible";
@@ -16,6 +28,14 @@ export declare const EnvVariableDefinitionSchema: z.ZodObject<{
16
28
  }, z.core.$strip>;
17
29
  export declare const EnvSchemaSchema: z.ZodRecord<z.ZodString, z.ZodObject<{
18
30
  label: z.ZodString;
31
+ scope: z.ZodOptional<z.ZodEnum<{
32
+ provision: "provision";
33
+ install: "install";
34
+ }>>;
35
+ installPhase: z.ZodOptional<z.ZodEnum<{
36
+ pre_install: "pre_install";
37
+ post_install: "post_install";
38
+ }>>;
19
39
  required: z.ZodOptional<z.ZodBoolean>;
20
40
  visibility: z.ZodOptional<z.ZodEnum<{
21
41
  visible: "visible";
@@ -329,6 +349,14 @@ export declare const ModelDefinitionSchema: z.ZodObject<{
329
349
  page: z.ZodOptional<z.ZodString>;
330
350
  env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
331
351
  label: z.ZodString;
352
+ scope: z.ZodOptional<z.ZodEnum<{
353
+ provision: "provision";
354
+ install: "install";
355
+ }>>;
356
+ installPhase: z.ZodOptional<z.ZodEnum<{
357
+ pre_install: "pre_install";
358
+ post_install: "post_install";
359
+ }>>;
332
360
  required: z.ZodOptional<z.ZodBoolean>;
333
361
  visibility: z.ZodOptional<z.ZodEnum<{
334
362
  visible: "visible";
@@ -3202,6 +3230,14 @@ export type AgentDefinition = z.infer<typeof AgentDefinitionSchema>;
3202
3230
  export declare const InstallConfigSchema: z.ZodObject<{
3203
3231
  env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
3204
3232
  label: z.ZodString;
3233
+ scope: z.ZodOptional<z.ZodEnum<{
3234
+ provision: "provision";
3235
+ install: "install";
3236
+ }>>;
3237
+ installPhase: z.ZodOptional<z.ZodEnum<{
3238
+ pre_install: "pre_install";
3239
+ post_install: "post_install";
3240
+ }>>;
3205
3241
  required: z.ZodOptional<z.ZodBoolean>;
3206
3242
  visibility: z.ZodOptional<z.ZodEnum<{
3207
3243
  visible: "visible";
@@ -3301,6 +3337,14 @@ export declare const InstallConfigSchema: z.ZodObject<{
3301
3337
  page: z.ZodOptional<z.ZodString>;
3302
3338
  env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
3303
3339
  label: z.ZodString;
3340
+ scope: z.ZodOptional<z.ZodEnum<{
3341
+ provision: "provision";
3342
+ install: "install";
3343
+ }>>;
3344
+ installPhase: z.ZodOptional<z.ZodEnum<{
3345
+ pre_install: "pre_install";
3346
+ post_install: "post_install";
3347
+ }>>;
3304
3348
  required: z.ZodOptional<z.ZodBoolean>;
3305
3349
  visibility: z.ZodOptional<z.ZodEnum<{
3306
3350
  visible: "visible";
@@ -3410,6 +3454,14 @@ export declare const BatchOperationDefinitionSchema: z.ZodObject<{
3410
3454
  export declare const ProvisionConfigSchema: z.ZodObject<{
3411
3455
  env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
3412
3456
  label: z.ZodString;
3457
+ scope: z.ZodOptional<z.ZodEnum<{
3458
+ provision: "provision";
3459
+ install: "install";
3460
+ }>>;
3461
+ installPhase: z.ZodOptional<z.ZodEnum<{
3462
+ pre_install: "pre_install";
3463
+ post_install: "post_install";
3464
+ }>>;
3413
3465
  required: z.ZodOptional<z.ZodBoolean>;
3414
3466
  visibility: z.ZodOptional<z.ZodEnum<{
3415
3467
  visible: "visible";
@@ -3509,6 +3561,14 @@ export declare const ProvisionConfigSchema: z.ZodObject<{
3509
3561
  page: z.ZodOptional<z.ZodString>;
3510
3562
  env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
3511
3563
  label: z.ZodString;
3564
+ scope: z.ZodOptional<z.ZodEnum<{
3565
+ provision: "provision";
3566
+ install: "install";
3567
+ }>>;
3568
+ installPhase: z.ZodOptional<z.ZodEnum<{
3569
+ pre_install: "pre_install";
3570
+ post_install: "post_install";
3571
+ }>>;
3512
3572
  required: z.ZodOptional<z.ZodBoolean>;
3513
3573
  visibility: z.ZodOptional<z.ZodEnum<{
3514
3574
  visible: "visible";
@@ -4243,6 +4303,14 @@ export declare const SkedyulConfigSchema: z.ZodObject<{
4243
4303
  provision: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
4244
4304
  env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
4245
4305
  label: z.ZodString;
4306
+ scope: z.ZodOptional<z.ZodEnum<{
4307
+ provision: "provision";
4308
+ install: "install";
4309
+ }>>;
4310
+ installPhase: z.ZodOptional<z.ZodEnum<{
4311
+ pre_install: "pre_install";
4312
+ post_install: "post_install";
4313
+ }>>;
4246
4314
  required: z.ZodOptional<z.ZodBoolean>;
4247
4315
  visibility: z.ZodOptional<z.ZodEnum<{
4248
4316
  visible: "visible";
@@ -4342,6 +4410,14 @@ export declare const SkedyulConfigSchema: z.ZodObject<{
4342
4410
  page: z.ZodOptional<z.ZodString>;
4343
4411
  env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
4344
4412
  label: z.ZodString;
4413
+ scope: z.ZodOptional<z.ZodEnum<{
4414
+ provision: "provision";
4415
+ install: "install";
4416
+ }>>;
4417
+ installPhase: z.ZodOptional<z.ZodEnum<{
4418
+ pre_install: "pre_install";
4419
+ post_install: "post_install";
4420
+ }>>;
4345
4421
  required: z.ZodOptional<z.ZodBoolean>;
4346
4422
  visibility: z.ZodOptional<z.ZodEnum<{
4347
4423
  visible: "visible";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "skedyul",
3
- "version": "1.7.12",
3
+ "version": "1.7.14",
4
4
  "description": "The Skedyul SDK for Node.js",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",