@kizenapps/packager 0.3.0-18bea71 → 0.4.0-6ad8aed

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.ts CHANGED
@@ -1,95 +1,98 @@
1
- type FileContent = {
1
+ interface FileContent {
2
2
  path: string;
3
3
  content: string;
4
4
  base64Image?: string;
5
5
  binaryData?: Buffer;
6
- };
6
+ }
7
7
  type MinifiedFileContent = FileContent & {
8
8
  minified: string;
9
9
  };
10
10
 
11
11
  declare const minifyFiles: (files: FileContent[]) => Promise<MinifiedFileContent[]>;
12
12
 
13
- type PublishableEnvironments = "go" | "fmo" | "staging" | "integration" | "e2e-integration" | "e2e-staging" | "test1";
14
- type EnvironmentAliases = "prod" | "dev" | "testing";
15
- type Environment = PublishableEnvironments | EnvironmentAliases;
16
- type ManifestFileContent = {
13
+ declare const PUBLISHABLE_ENVIRONMENTS: readonly ["go", "fmo", "staging", "integration", "e2e-integration", "e2e-staging", "test1"];
14
+ declare const ENVIRONMENT_ALIASES: readonly ["prod", "dev", "testing"];
15
+ declare const ENVIRONMENTS: readonly ["go", "fmo", "staging", "integration", "e2e-integration", "e2e-staging", "test1", "prod", "dev", "testing"];
16
+ type PublishableEnvironments = (typeof PUBLISHABLE_ENVIRONMENTS)[number];
17
+ type EnvironmentAliases = (typeof ENVIRONMENT_ALIASES)[number];
18
+ type Environment = (typeof ENVIRONMENTS)[number];
19
+ interface ManifestFileContent {
17
20
  version: string;
18
21
  api_name: string;
19
22
  name: string;
20
23
  engine: string;
21
24
  description: string;
22
- release_branches: string[];
23
- release_environments: Array<Environment>;
25
+ release_branches?: string[];
26
+ release_environments?: Environment[];
24
27
  entry: string;
25
28
  release_notes_directory?: string;
26
29
  config_template?: Record<string, unknown>;
27
30
  base_config?: Record<string, unknown>;
28
31
  setup_assistant?: SetupAssistantConfig;
29
32
  user_setup_assistant?: SetupAssistantConfig;
30
- services?: Array<Record<string, unknown>>;
31
- published: boolean;
33
+ services?: Record<string, unknown>[];
34
+ published?: boolean;
32
35
  developer_business_id?: string | Record<PublishableEnvironments, string>;
33
36
  block_loading_for_setup?: boolean;
34
- };
35
- type SetupAssistantField = {
37
+ }
38
+ interface SetupAssistantField {
36
39
  key: string;
37
- type: "custom_object" | "description" | "container" | "field" | "text" | "number" | "select" | "boolean";
40
+ type: 'custom_object' | 'description' | 'container' | 'field' | 'text' | 'number' | 'select' | 'boolean';
38
41
  columns?: number;
39
- fields?: Array<SetupAssistantField>;
42
+ fields?: SetupAssistantField[];
40
43
  content?: string;
41
44
  label?: string;
42
45
  object_id?: string;
43
46
  default?: string;
44
- options?: Array<{
47
+ options?: {
45
48
  label: string;
46
49
  value: string;
47
- }>;
50
+ }[];
48
51
  allow_multiple?: boolean;
49
52
  placeholder?: string;
50
53
  when?: string;
51
- };
52
- type SetupAssistantConfig = {
53
- fields?: Array<SetupAssistantField>;
54
- actions?: Array<string>;
55
- };
56
- type ManifestFile = ManifestFileContent | Array<ManifestFileContent>;
54
+ }
55
+ interface SetupAssistantConfig {
56
+ fields?: SetupAssistantField[];
57
+ actions?: string[];
58
+ }
59
+ type ManifestFile = ManifestFileContent | ManifestFileContent[];
57
60
 
58
- type CalendarSource = {
61
+ interface CalendarSource {
59
62
  api_name: string;
60
63
  name: string;
61
64
  calendars_script: string;
62
65
  events_script: string;
63
66
  when: string;
64
- };
67
+ }
65
68
  type CalendarSourcesMap = Record<string, CalendarSource>;
66
- type ObjectSettingsItem = {
69
+ interface ObjectSettingsItem {
67
70
  api_name: string;
68
71
  label: string;
69
72
  script: string;
70
73
  when: string;
71
- };
74
+ }
72
75
  type ObjectSettingsItemsMap = Record<string, ObjectSettingsItem>;
73
76
  type EventScripts = Record<string, string>;
74
- type JSAction = {
77
+ interface JSAction {
75
78
  name: string;
76
79
  hint_object_name: string;
77
80
  api_name: string;
78
81
  script: string;
79
- };
82
+ }
80
83
  type JSActionsMap = Record<string, JSAction>;
81
- type RouteScript = {
84
+ interface RouteScript {
82
85
  script: string;
83
86
  api_name: string;
84
87
  hint_object_name: string;
85
- routes: Array<string>;
88
+ routes: string[];
86
89
  name: string;
87
- };
90
+ }
88
91
  type RouteScriptsMap = Record<string, RouteScript>;
89
- type RoutablePage = {
92
+ interface RoutablePage {
90
93
  name: string;
91
94
  api_name: string;
92
- type: "script" | "html";
95
+ type: 'script' | 'html';
93
96
  css: string;
94
97
  event_scripts: EventScripts;
95
98
  callback: string;
@@ -99,35 +102,35 @@ type RoutablePage = {
99
102
  script: string;
100
103
  html: string;
101
104
  iframe_url: string;
102
- };
105
+ }
103
106
  type RoutablePagesMap = Record<string, RoutablePage>;
104
- type ToolbarItem = {
107
+ interface ToolbarItem {
105
108
  api_name: string;
106
109
  label: string;
107
110
  icon: string;
108
111
  color: string;
109
112
  script: string;
110
113
  when: string;
111
- };
114
+ }
112
115
  type ToolbarItemsMap = Record<string, ToolbarItem>;
113
- type DataAdornmentConfig = {
116
+ interface DataAdornmentConfig {
114
117
  icon: string;
115
118
  color: string;
116
119
  tooltip: string;
117
120
  customIcon?: string;
118
- };
119
- type DataAdornment = {
121
+ }
122
+ interface DataAdornment {
120
123
  config: DataAdornmentConfig;
121
- field_type: "phonenumber" | "date" | "datetime";
124
+ field_type: 'phonenumber' | 'date' | 'datetime';
122
125
  script: string;
123
126
  when: string;
124
- };
127
+ }
125
128
  type DataAdornmentsMap = Record<string, DataAdornment>;
126
- type FloatingFrame = {
129
+ interface FloatingFrame {
127
130
  name: string;
128
131
  api_name: string;
129
132
  title: string;
130
- type: "script";
133
+ type: 'script';
131
134
  css: string;
132
135
  event_scripts: EventScripts;
133
136
  default_position: string;
@@ -135,17 +138,17 @@ type FloatingFrame = {
135
138
  header_text_color: string;
136
139
  height: number;
137
140
  width: number;
138
- ignore: Array<string>;
139
- match: Array<string>;
141
+ ignore: string[];
142
+ match: string[];
140
143
  message_handler: string;
141
- minimized_style: "bar" | "circle" | "none";
144
+ minimized_style: 'bar' | 'circle' | 'none';
142
145
  minimized_config: Record<string, unknown>;
143
146
  script: string;
144
147
  html: string;
145
148
  when: string;
146
- };
149
+ }
147
150
  type FloatingFramesMap = Record<string, FloatingFrame>;
148
- type Block = {
151
+ interface Block {
149
152
  name: string;
150
153
  api_name: string;
151
154
  min_w: number;
@@ -156,21 +159,21 @@ type Block = {
156
159
  event_scripts: EventScripts;
157
160
  script: string;
158
161
  styles: string;
159
- types?: Array<string>;
162
+ types?: string[];
160
163
  when: string;
161
- };
164
+ }
162
165
  type BlocksMap = Record<string, Block>;
163
166
  type AutomationScriptRuntimeInput = `${string} ${number}.${number}`;
164
167
  type AutomationScriptRuntimeOutput = `${string}-${number}-${number}`;
165
- type AutomationStep = {
168
+ interface AutomationStep {
166
169
  name: string;
167
170
  action_step_api_name: string;
168
171
  overall_description: string;
169
172
  action_description: string;
170
173
  action_type: string;
171
174
  script_runtime: AutomationScriptRuntimeOutput;
172
- secrets: Array<string>;
173
- inputs: Array<{
175
+ secrets: string[];
176
+ inputs: {
174
177
  name: string;
175
178
  label: string;
176
179
  data_type: string;
@@ -179,8 +182,8 @@ type AutomationStep = {
179
182
  hint_field_name: string;
180
183
  hint_related_object_field_name: string;
181
184
  script_alias: string;
182
- }>;
183
- outputs: Array<{
185
+ }[];
186
+ outputs: {
184
187
  name: string;
185
188
  label: string;
186
189
  data_type: string;
@@ -189,14 +192,14 @@ type AutomationStep = {
189
192
  hint_field_name: string;
190
193
  hint_related_object_field_name: string;
191
194
  script_alias: string;
192
- conflict_resolution: "overwrite" | "skip" | "append";
195
+ conflict_resolution: 'overwrite' | 'skip' | 'append';
193
196
  create_field_options: boolean;
194
- }>;
197
+ }[];
195
198
  script: string;
196
199
  when: string;
197
- };
200
+ }
198
201
  type AutomationStepsMap = Record<string, AutomationStep>;
199
- type PackagedPlugin = {
202
+ interface PackagedPlugin {
200
203
  manifest: ManifestFileContent;
201
204
  floatingFrames: FloatingFramesMap;
202
205
  blocks: BlocksMap;
@@ -211,21 +214,22 @@ type PackagedPlugin = {
211
214
  releaseNotes?: string;
212
215
  kznFile: Uint8Array | null;
213
216
  calendarSources: CalendarSourcesMap;
214
- };
217
+ }
215
218
  type ProcessedPluginPackage = Record<string, PackagedPlugin>;
216
- type DeployablePlugin = ManifestFileContent & {
219
+ type DeployablePlugin = Omit<ManifestFileContent, 'setup_assistant'> & {
217
220
  api_name: string;
221
+ setup_assistant?: SetupAssistantConfig | undefined;
218
222
  artifacts: {
219
- data_adornments: Array<DataAdornment>;
220
- floating_frames: Array<FloatingFrame>;
221
- custom_blocks: Array<Block>;
222
- routable_pages: Array<RoutablePage>;
223
- toolbar_items: Array<ToolbarItem>;
224
- js_action_templates: Array<JSAction>;
225
- route_scripts: Array<RouteScript>;
226
- object_settings_menu_items: Array<ObjectSettingsItem>;
227
- automation_action_configs: Array<AutomationStep>;
228
- calendar_sources: Array<CalendarSource>;
223
+ data_adornments: DataAdornment[];
224
+ floating_frames: FloatingFrame[];
225
+ custom_blocks: Block[];
226
+ routable_pages: RoutablePage[];
227
+ toolbar_items: ToolbarItem[];
228
+ js_action_templates: JSAction[];
229
+ route_scripts: RouteScript[];
230
+ object_settings_menu_items: ObjectSettingsItem[];
231
+ automation_action_configs: AutomationStep[];
232
+ calendar_sources: CalendarSource[];
229
233
  };
230
234
  thumbnail: Uint8Array | null;
231
235
  kznFile: Uint8Array | null;
@@ -245,30 +249,63 @@ declare const parseManifestFromFiles: (files: MinifiedFileContent[]) => Manifest
245
249
 
246
250
  declare const transformDeployablePlugin: (packagedPlugin: PackagedPlugin) => DeployablePlugin;
247
251
 
252
+ /**
253
+ * Derives a fallback api_name from a directory name, targeting the alphabet of
254
+ * API_NAME_PATTERN (/^[a-z_][a-z0-9_]+$/): the result is lowercased, runs of
255
+ * hyphens and whitespace collapse to a single underscore, and any remaining
256
+ * character outside [a-z0-9_] is dropped. A leading digit or too-short result
257
+ * is left intact so validation can reject it loudly rather than silently
258
+ * padding it into something valid.
259
+ */
248
260
  declare const sanitizeToAPIName: (name: string) => string;
249
261
  declare const scriptRuntimeToApiName: (runtime: AutomationScriptRuntimeInput) => AutomationScriptRuntimeOutput;
250
262
 
263
+ type ValidationSeverity = 'error' | 'warning';
264
+ interface ValidationIssue {
265
+ /** Stable rule id, e.g. "manifest/api-name-format". */
266
+ rule: string;
267
+ severity: ValidationSeverity;
268
+ /** Canonical message, shared verbatim by every consumer. */
269
+ message: string;
270
+ /** Repo-relative path of the file (or directory) the issue was found in. */
271
+ path?: string;
272
+ /** api_name of the owning manifest entry, when known (multi-app repos). */
273
+ pluginApiName?: string;
274
+ }
275
+ declare const errorIssue: (rule: string, message: string, path?: string, pluginApiName?: string) => ValidationIssue;
276
+ /**
277
+ * Structured error carrying the same issue shape as validatePluginApp, so
278
+ * pre-flight results and packaging-stage throws render identically.
279
+ */
280
+ declare class PluginValidationError extends Error {
281
+ issues: ValidationIssue[];
282
+ constructor(issues: ValidationIssue[]);
283
+ }
284
+
285
+ declare const API_NAME_PATTERN: RegExp;
286
+ declare const validatePluginApp: (files: FileContent[]) => ValidationIssue[];
287
+
251
288
  declare const imagetoUint8Array: (base64Image: string) => Uint8Array;
252
289
  declare const zipToUint8Array: (zip: Buffer) => Uint8Array;
253
290
 
254
291
  declare const CRYPTO_VERSION: 1;
255
292
  declare const CRYPTO_ALG: "RSA-OAEP-256+A256GCM";
256
- type CryptoEnvelope = {
293
+ interface CryptoEnvelope {
257
294
  v: typeof CRYPTO_VERSION;
258
295
  alg: typeof CRYPTO_ALG;
259
296
  k: string;
260
297
  iv: string;
261
298
  tag: string;
262
299
  ct: string;
263
- };
264
- type Keypair = {
300
+ }
301
+ interface Keypair {
265
302
  publicKey: string;
266
303
  privateKey: string;
267
- };
268
- type EncryptedValue = {
304
+ }
305
+ interface EncryptedValue {
269
306
  encrypted: true;
270
307
  value: string;
271
- };
308
+ }
272
309
  declare const generateKeypair: () => Keypair;
273
310
  declare const encrypt: (plaintext: string, publicKeyPem: string) => CryptoEnvelope;
274
311
  declare const decrypt: (envelope: CryptoEnvelope, privateKeyPem: string) => string;
@@ -302,8 +339,8 @@ declare const CONFIG_FILE_NAME = "config.json";
302
339
  declare const STYLES_FILE_NAME = "styles.css";
303
340
  declare const MANIFEST_FILE_NAME = "kizen.json";
304
341
  declare const KZN_FILE_NAME = "import.kzn";
305
- declare const maybeParseConfig: (content: string | undefined, path: string) => Record<string, unknown>;
342
+ declare const maybeParseConfig: (content: string | undefined, path: string, pluginApiName?: string) => Record<string, unknown>;
306
343
  declare const getMinimizedConfig: (config: Record<string, unknown>, entry: string, splitPath: string[], consideredFiles: MinifiedFileContent[]) => Record<string, unknown>;
307
344
  declare const getAdornmentIcon: (config: Record<string, unknown>, entry: string, splitPath: string[], consideredFiles: MinifiedFileContent[]) => string;
308
345
 
309
- export { AUTOMATION_SCRIPT_FILE, AUTOMATION_STEPS_DIRECTORY_NAME, type AutomationScriptRuntimeInput, type AutomationScriptRuntimeOutput, type AutomationStep, type AutomationStepsMap, BLOCKS_DIRECTORY_NAME, BROWSER_ROUTE_SCRIPTS_DIRECTORY_NAME, type Block, type BlocksMap, CALENDAR_SOURCES_DIRECTORY_NAME, CALLBACK_SCRIPT_FILE, CONFIG_FILE_NAME, CRYPTO_ALG, CRYPTO_VERSION, type CalendarSource, type CalendarSourcesMap, type CryptoEnvelope, DATA_ADORNMENTS_DIRECTORY_NAME, type DataAdornment, type DataAdornmentConfig, type DataAdornmentsMap, type DeployablePlugin, EVENT_SCRIPTS_DIRECTORY_NAME, type EncryptedValue, type Environment, type EnvironmentAliases, type EventScripts, FLOATING_FRAMES_DIRECTORY_NAME, type FileContent, type FloatingFrame, type FloatingFramesMap, type JSAction, type JSActionsMap, JS_ACTIONS_DIRECTORY_NAME, KZN_FILE_NAME, type Keypair, MAIN_SCRIPT_FILE, MANIFEST_FILE_NAME, MESSAGE_SCRIPT_FILE, type ManifestFile, type ManifestFileContent, type MinifiedFileContent, OBJECT_SETTINGS_ITEMS_DIRECTORY_NAME, type ObjectSettingsItem, type ObjectSettingsItemsMap, type PackagedPlugin, type ProcessedPluginPackage, type PublishableEnvironments, RELEASE_NOTES_EXTENSION, ROUTABLE_PAGES_DIRECTORY_NAME, type RoutablePage, type RoutablePagesMap, type RouteScript, type RouteScriptsMap, SCRIPT_EXTENSION, SETUP_ASSISTANT_DIRECTORY_NAME, STYLES_FILE_NAME, type SetupAssistantConfig, type SetupAssistantField, THUMBNAIL_FILE_NAMES, TOOLBAR_ITEMS_DIRECTORY_NAME, type ToolbarItem, type ToolbarItemsMap, USER_SETUP_ASSISTANT_DIRECTORY_NAME, decrypt, deserializeEnvelope, encrypt, generateKeypair, getAdornmentIcon, getMinimizedConfig, imagetoUint8Array, maybeParseConfig, minifyFiles, packagePlugin, parseManifestFromFiles, roundTripVerify, sanitizeToAPIName, scriptRuntimeToApiName, serializeEnvelope, thumbnailImageExtensions, transformDeployablePlugin, triggerImageExtensions, zipToUint8Array };
346
+ export { API_NAME_PATTERN, AUTOMATION_SCRIPT_FILE, AUTOMATION_STEPS_DIRECTORY_NAME, type AutomationScriptRuntimeInput, type AutomationScriptRuntimeOutput, type AutomationStep, type AutomationStepsMap, BLOCKS_DIRECTORY_NAME, BROWSER_ROUTE_SCRIPTS_DIRECTORY_NAME, type Block, type BlocksMap, CALENDAR_SOURCES_DIRECTORY_NAME, CALLBACK_SCRIPT_FILE, CONFIG_FILE_NAME, CRYPTO_ALG, CRYPTO_VERSION, type CalendarSource, type CalendarSourcesMap, type CryptoEnvelope, DATA_ADORNMENTS_DIRECTORY_NAME, type DataAdornment, type DataAdornmentConfig, type DataAdornmentsMap, type DeployablePlugin, ENVIRONMENTS, ENVIRONMENT_ALIASES, EVENT_SCRIPTS_DIRECTORY_NAME, type EncryptedValue, type Environment, type EnvironmentAliases, type EventScripts, FLOATING_FRAMES_DIRECTORY_NAME, type FileContent, type FloatingFrame, type FloatingFramesMap, type JSAction, type JSActionsMap, JS_ACTIONS_DIRECTORY_NAME, KZN_FILE_NAME, type Keypair, MAIN_SCRIPT_FILE, MANIFEST_FILE_NAME, MESSAGE_SCRIPT_FILE, type ManifestFile, type ManifestFileContent, type MinifiedFileContent, OBJECT_SETTINGS_ITEMS_DIRECTORY_NAME, type ObjectSettingsItem, type ObjectSettingsItemsMap, PUBLISHABLE_ENVIRONMENTS, type PackagedPlugin, PluginValidationError, type ProcessedPluginPackage, type PublishableEnvironments, RELEASE_NOTES_EXTENSION, ROUTABLE_PAGES_DIRECTORY_NAME, type RoutablePage, type RoutablePagesMap, type RouteScript, type RouteScriptsMap, SCRIPT_EXTENSION, SETUP_ASSISTANT_DIRECTORY_NAME, STYLES_FILE_NAME, type SetupAssistantConfig, type SetupAssistantField, THUMBNAIL_FILE_NAMES, TOOLBAR_ITEMS_DIRECTORY_NAME, type ToolbarItem, type ToolbarItemsMap, USER_SETUP_ASSISTANT_DIRECTORY_NAME, type ValidationIssue, type ValidationSeverity, decrypt, deserializeEnvelope, encrypt, errorIssue, generateKeypair, getAdornmentIcon, getMinimizedConfig, imagetoUint8Array, maybeParseConfig, minifyFiles, packagePlugin, parseManifestFromFiles, roundTripVerify, sanitizeToAPIName, scriptRuntimeToApiName, serializeEnvelope, thumbnailImageExtensions, transformDeployablePlugin, triggerImageExtensions, validatePluginApp, zipToUint8Array };