heim 0.0.1 → 0.1.0-alpha.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/gen/heim.d.ts ADDED
@@ -0,0 +1,310 @@
1
+ /* eslint-disable */
2
+ /**
3
+ * This file was automatically generated by json-schema-to-typescript.
4
+ * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
5
+ * and run json-schema-to-typescript to regenerate this file.
6
+ */
7
+
8
+ /**
9
+ * Part of the id of the app. It needs to be unique within one namespace.
10
+ */
11
+ export type AppName = string;
12
+ /**
13
+ * The version of the app, must be a valid semver version.
14
+ */
15
+ export type AppVersion = string;
16
+ /**
17
+ * Display name shown in the UI.
18
+ */
19
+ export type Title = LocalizedString | string;
20
+ /**
21
+ * A short description of the app.
22
+ */
23
+ export type Tagline = LocalizedString1 | string;
24
+ /**
25
+ * The description of the app. It needs to be a markdown file.
26
+ */
27
+ export type Readme = LocalizedString2 | string;
28
+ /**
29
+ * The category of the app.
30
+ */
31
+ export type Category =
32
+ | "books"
33
+ | "medical"
34
+ | "business"
35
+ | "music"
36
+ | "developer-tools"
37
+ | "navigation"
38
+ | "education"
39
+ | "news"
40
+ | "entertainment"
41
+ | "photo-and-video"
42
+ | "finance"
43
+ | "productivity"
44
+ | "food-and-drink"
45
+ | "reference"
46
+ | "games"
47
+ | "graphics-and-design"
48
+ | "shopping"
49
+ | "health-and-fitness"
50
+ | "social-networking"
51
+ | "lifestyle"
52
+ | "sports"
53
+ | "kids"
54
+ | "travel"
55
+ | "magazines-and-newspapers"
56
+ | "utilities"
57
+ | "weather";
58
+ /**
59
+ * The developer (individual person or company) of the app. This is either you or the original developer of the software.
60
+ */
61
+ export type Developer = string;
62
+ /**
63
+ * The icon of the app. It needs to be an SVG file.
64
+ */
65
+ export type Icon = string;
66
+ /**
67
+ * A list of images that showcase the app.
68
+ */
69
+ export type GalleryImages = string[] | LocalizedString3;
70
+ /**
71
+ * The website of the app.
72
+ */
73
+ export type Website = string;
74
+ /**
75
+ * The version control repository of the app (e.g. GitHub).
76
+ */
77
+ export type Repository = string;
78
+ /**
79
+ * The support website of the app.
80
+ */
81
+ export type Support = string;
82
+ /**
83
+ * The license file of the app.
84
+ */
85
+ export type License = LocalizedString4 | string;
86
+ /**
87
+ * The name of the compose service that provides the user interface.
88
+ */
89
+ export type Service = string;
90
+ /**
91
+ * The port of the compose service that provides the user interface. Note that this port does NOT need to be exposed by the container runtime.
92
+ */
93
+ export type Port = number;
94
+ /**
95
+ * The url path of the compose service that provides the user interface.
96
+ */
97
+ export type Path = string;
98
+ /**
99
+ * Whether the user interface of this app has an auth in front of it. Can be 'true' if the app itself provides an authentication mechanism or is intended to be public.
100
+ */
101
+ export type HasAuth = boolean;
102
+ /**
103
+ * The name of the compose service to run the command in.
104
+ */
105
+ export type Service1 = string;
106
+ /**
107
+ * The command to run before backing up the app.
108
+ */
109
+ export type Command = string;
110
+ /**
111
+ * The name of the compose service to run the command in.
112
+ */
113
+ export type Service2 = string;
114
+ /**
115
+ * The command to run after backing up the app.
116
+ */
117
+ export type Command1 = string;
118
+ /**
119
+ * The name of the compose service to run the command in.
120
+ */
121
+ export type Service3 = string;
122
+ /**
123
+ * The command to run before restoring the app.
124
+ */
125
+ export type Command2 = string;
126
+ /**
127
+ * The name of the compose service to run the command in.
128
+ */
129
+ export type Service4 = string;
130
+ /**
131
+ * The command to run after restoring the app.
132
+ */
133
+ export type Command3 = string;
134
+ /**
135
+ * The command to run before installing the app.
136
+ */
137
+ export type PreInstall = string;
138
+ /**
139
+ * The command to run after installing the app.
140
+ */
141
+ export type PostInstall = string;
142
+ /**
143
+ * The command to run before updating the app.
144
+ */
145
+ export type PreUpdate = string;
146
+ /**
147
+ * The command to run after updating the app.
148
+ */
149
+ export type PostUpdate = string;
150
+ /**
151
+ * The command to run before uninstalling the app.
152
+ */
153
+ export type PreUninstall = string;
154
+ /**
155
+ * The command to run after uninstalling the app.
156
+ */
157
+ export type PostUninstall = string;
158
+ /**
159
+ * The command to run before backing up the app.
160
+ */
161
+ export type PreBackup = string;
162
+ /**
163
+ * The command to run after backing up the app.
164
+ */
165
+ export type PostBackup = string;
166
+ /**
167
+ * The command to run before restoring the app.
168
+ */
169
+ export type PreRestore = string;
170
+ /**
171
+ * The command to run after restoring the app.
172
+ */
173
+ export type PostRestore = string;
174
+
175
+ /**
176
+ * This json schema defines common types used in the Go CLI and the TypeScript library.
177
+ */
178
+ export interface HeimTypes {
179
+ /**
180
+ * The manifest of the heim app.
181
+ */
182
+ manifest?: {
183
+ name: AppName;
184
+ version: AppVersion;
185
+ title: Title;
186
+ tagline: Tagline;
187
+ readme?: Readme;
188
+ category: Category;
189
+ developer: Developer;
190
+ icon?: Icon;
191
+ galleryImages?: GalleryImages;
192
+ website?: Website;
193
+ repository?: Repository;
194
+ support?: Support;
195
+ license?: License;
196
+ };
197
+ ui?: UserInterface;
198
+ backup?: Backup;
199
+ hooks?: Hooks;
200
+ }
201
+ /**
202
+ * A string that is translated in different languages.
203
+ */
204
+ export interface LocalizedString {
205
+ en: string[] | string;
206
+ [k: string]: string;
207
+ }
208
+ /**
209
+ * A string that is translated in different languages.
210
+ */
211
+ export interface LocalizedString1 {
212
+ en: string[] | string;
213
+ [k: string]: string;
214
+ }
215
+ /**
216
+ * A string that is translated in different languages.
217
+ */
218
+ export interface LocalizedString2 {
219
+ en: string[] | string;
220
+ [k: string]: string;
221
+ }
222
+ /**
223
+ * A string that is translated in different languages.
224
+ */
225
+ export interface LocalizedString3 {
226
+ en: string[] | string;
227
+ /**
228
+ * @maxItems 10
229
+ */
230
+ [k: string]: string[];
231
+ }
232
+ /**
233
+ * A string that is translated in different languages.
234
+ */
235
+ export interface LocalizedString4 {
236
+ en: string[] | string;
237
+ [k: string]: string;
238
+ }
239
+ /**
240
+ * The http(s) configuration of the user interface for the app.
241
+ */
242
+ export interface UserInterface {
243
+ service: Service;
244
+ port: Port;
245
+ path?: Path;
246
+ hasAuth?: HasAuth;
247
+ }
248
+ /**
249
+ * The backup configuration of the app.
250
+ */
251
+ export interface Backup {
252
+ volumes?: Volumes;
253
+ beforeBackup?: BeforeBackup;
254
+ afterBackup?: AfterBackup;
255
+ beforeRestore?: BeforeRestore;
256
+ afterRestore?: AfterRestore;
257
+ }
258
+ export interface Volumes {
259
+ /**
260
+ * A list of volume names to include in the backup. If neither this list nor the exclude list is set, all volumes will be included. If both lists are set, only the volumes in the include list that are not in the exclude list will be included.
261
+ */
262
+ include?: string[];
263
+ /**
264
+ * A list of volume names to exclude from the backup. If neither this list nor the include list is set, all volumes will be included. If both lists are set, only the volumes in the include list that are not in the exclude list will be included.
265
+ */
266
+ exclude?: string[];
267
+ }
268
+ /**
269
+ * The command to run before backing up the app.
270
+ */
271
+ export interface BeforeBackup {
272
+ service?: Service1;
273
+ command?: Command;
274
+ }
275
+ /**
276
+ * The command to run after backing up the app.
277
+ */
278
+ export interface AfterBackup {
279
+ service?: Service2;
280
+ command?: Command1;
281
+ }
282
+ /**
283
+ * The command to run before restoring the app.
284
+ */
285
+ export interface BeforeRestore {
286
+ service?: Service3;
287
+ command?: Command2;
288
+ }
289
+ /**
290
+ * The command to run after restoring the app.
291
+ */
292
+ export interface AfterRestore {
293
+ service?: Service4;
294
+ command?: Command3;
295
+ }
296
+ /**
297
+ * The hooks configuration of the app.
298
+ */
299
+ export interface Hooks {
300
+ preInstall?: PreInstall;
301
+ postInstall?: PostInstall;
302
+ preUpdate?: PreUpdate;
303
+ postUpdate?: PostUpdate;
304
+ preUninstall?: PreUninstall;
305
+ postUninstall?: PostUninstall;
306
+ preBackup?: PreBackup;
307
+ postBackup?: PostBackup;
308
+ preRestore?: PreRestore;
309
+ postRestore?: PostRestore;
310
+ }
package/main.ts ADDED
@@ -0,0 +1,121 @@
1
+ import type { HeimTypes } from "./gen/heim";
2
+ import type { ComposeSpecification } from "./gen/compose";
3
+
4
+ // Main function (mock implementation as it is being executed in the go CLI)
5
+ export function defineApp(config: AppConfig): AppConfig {
6
+ return config;
7
+ }
8
+
9
+ // Types
10
+ export type AppConfig = {
11
+ manifest: Manifest | ((ctx: ManifestContext) => Manifest);
12
+ ui?: UserInterface | ((ctx: UserInterfaceContext) => UserInterface);
13
+ compose: Compose | ((ctx: ComposeContext) => Compose);
14
+ backup?: Backup | ((ctx: BackupContext) => Backup);
15
+ hooks?: Hooks | ((ctx: HooksContext) => Hooks);
16
+ };
17
+ export type Manifest = HeimTypes["manifest"];
18
+ export type ManifestContext = {};
19
+ export type UserInterface = HeimTypes["ui"];
20
+ export type UserInterfaceContext = {};
21
+ export type Compose = ComposeSpecification;
22
+ export type ComposeContext = {
23
+ data: {
24
+ // Filepaths
25
+ getSharedStorageDir(): string;
26
+ };
27
+
28
+ system: {
29
+ /**
30
+ * Returns a list of common IANA timezones, e.g. ["Europe/Berlin", "America/New_York", ...].
31
+ */
32
+ timezones(): string[];
33
+ /**
34
+ * Returns the system's current timezone in IANA format, e.g. "Europe/Berlin".
35
+ * This is determined by the host environment and may not be accurate if the user
36
+ * has recently changed their timezone or if the host environment does not provide this information.
37
+ */
38
+ timezone(): string;
39
+ };
40
+
41
+ input: {
42
+ /**
43
+ * Prompts the user for input and returns the entered value.
44
+ * The input is stored under the provided storageKey and can be edited by the user later.
45
+ * @param storageKey A unique key to store the input value, e.g. "db-username"
46
+ * @param opts Options for the input prompt
47
+ */
48
+ text(
49
+ storageKey: string,
50
+ opts: {
51
+ /**
52
+ * The message to display to the user when prompting for input, e.g. "Enter your database username".
53
+ */
54
+ message: string;
55
+ /**
56
+ * An optional default value to pre-fill the input field, e.g. "admin".
57
+ */
58
+ defaultValue?: string;
59
+ /**
60
+ * If true, the input will allow multiple lines to be entered. Default is false.
61
+ */
62
+ multiLine?: boolean;
63
+ /**
64
+ * If true, the input will be masked (e.g. for passwords). Default is false.
65
+ */
66
+ mask?: string;
67
+ validate?: (value: string | undefined) => string | undefined;
68
+ },
69
+ ): string;
70
+ confirm(
71
+ storageKey: string,
72
+ opts: {
73
+ message: string;
74
+ defaultValue?: boolean;
75
+ confirmText?: string;
76
+ rejectText?: string;
77
+ },
78
+ ): boolean;
79
+ select<V extends string>(
80
+ storageKey: string,
81
+ opts: {
82
+ message: string;
83
+ options: { value: V; label: string }[];
84
+ defaultValue?: V;
85
+ },
86
+ ): V;
87
+ multiselect<V extends string>(
88
+ storageKey: string,
89
+ opts: {
90
+ message: string;
91
+ options: { value: V; label: string }[];
92
+ defaultValue?: V[];
93
+ },
94
+ ): V[];
95
+ };
96
+
97
+ crypto: {
98
+ /**
99
+ * Generates a random password with the specified options.
100
+ * @param opts Options for password generation
101
+ */
102
+ password(opts?: {
103
+ /**
104
+ * The length of the generated password. Default is 16.
105
+ */
106
+ length?: number;
107
+ /**
108
+ * Exclude numbers from the generated password. Default is false.
109
+ */
110
+ excludeNumbers?: boolean;
111
+ /**
112
+ * Exclude special characters from the generated password. Default is false.
113
+ */
114
+ excludeSpecial?: boolean;
115
+ }): string;
116
+ };
117
+ };
118
+ export type Backup = HeimTypes["backup"];
119
+ export type BackupContext = {};
120
+ export type Hooks = HeimTypes["hooks"];
121
+ export type HooksContext = {};
package/package.json CHANGED
@@ -1,6 +1,18 @@
1
1
  {
2
2
  "name": "heim",
3
- "version": "0.0.1",
4
- "main": "index.js",
5
- "license": "MIT"
3
+ "version": "0.1.0-alpha.1",
4
+ "description": "The library to create heim.ts files for heim apps.",
5
+ "license": "Apache-2.0",
6
+ "author": {
7
+ "name": "Josua Frank",
8
+ "email": "frank.josua@gmail.com"
9
+ },
10
+ "type": "module",
11
+ "main": "main.ts",
12
+ "scripts": {
13
+ "gen-types": "json2ts -i ../../types.schema.json -o heim.d.ts --maxItems -1"
14
+ },
15
+ "devDependencies": {
16
+ "json-schema-to-typescript": "^15.0.4"
17
+ }
6
18
  }
package/tsconfig.json ADDED
@@ -0,0 +1,28 @@
1
+ {
2
+ "compilerOptions": {
3
+ // Environment setup & latest features
4
+ "lib": [
5
+ "ESNext"
6
+ ],
7
+ "target": "ESNext",
8
+ "module": "Preserve",
9
+ "moduleDetection": "force",
10
+ "jsx": "react-jsx",
11
+ "allowJs": true,
12
+ // Bundler mode
13
+ "moduleResolution": "bundler",
14
+ "allowImportingTsExtensions": true,
15
+ "verbatimModuleSyntax": true,
16
+ "noEmit": true,
17
+ // Best practices
18
+ "strict": true,
19
+ "skipLibCheck": true,
20
+ "noFallthroughCasesInSwitch": true,
21
+ "noUncheckedIndexedAccess": true,
22
+ "noImplicitOverride": true,
23
+ // Some stricter flags (disabled by default)
24
+ "noUnusedLocals": true,
25
+ "noUnusedParameters": true,
26
+ "noPropertyAccessFromIndexSignature": true
27
+ }
28
+ }