@hailer/app-sdk 1.0.1-beta7 → 1.0.2

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.
Files changed (44) hide show
  1. package/lib/app-sdk.js +1 -1
  2. package/lib/app-sdk.js.map +4 -4
  3. package/lib/hailer-api.d.ts +12 -2
  4. package/lib/modules/permission.d.ts +9 -0
  5. package/lib/modules/product-installed.d.ts +40 -0
  6. package/lib/modules/product-version.d.ts +38 -0
  7. package/lib/modules/product.d.ts +111 -0
  8. package/lib/modules/public/product-version.d.ts +16 -0
  9. package/lib/modules/public/product.d.ts +27 -0
  10. package/lib/modules/public/version.d.ts +16 -0
  11. package/lib/modules/public.d.ts +6 -0
  12. package/lib/modules/ui/activity.d.ts +2 -0
  13. package/lib/modules/version.d.ts +16 -0
  14. package/lib/modules/workspace.d.ts +22 -0
  15. package/lib/src/constants.d.ts +7 -0
  16. package/lib/src/hailer-api.d.ts +92 -0
  17. package/lib/src/index.d.ts +2 -0
  18. package/lib/src/modules/activity/kanban.d.ts +36 -0
  19. package/lib/src/modules/activity.d.ts +83 -0
  20. package/lib/src/modules/app.d.ts +12 -0
  21. package/lib/src/modules/insight.d.ts +36 -0
  22. package/lib/src/modules/network.d.ts +14 -0
  23. package/lib/src/modules/permission.d.ts +9 -0
  24. package/lib/src/modules/process.d.ts +38 -0
  25. package/lib/src/modules/product-installed.d.ts +40 -0
  26. package/lib/src/modules/product-version.d.ts +16 -0
  27. package/lib/src/modules/product.d.ts +104 -0
  28. package/lib/src/modules/public/app.d.ts +17 -0
  29. package/lib/src/modules/public/form.d.ts +31 -0
  30. package/lib/src/modules/public/insight.d.ts +30 -0
  31. package/lib/src/modules/public/product-version.d.ts +16 -0
  32. package/lib/src/modules/public/product.d.ts +27 -0
  33. package/lib/src/modules/public.d.ts +22 -0
  34. package/lib/src/modules/ui/activity.d.ts +30 -0
  35. package/lib/src/modules/ui/files.d.ts +18 -0
  36. package/lib/src/modules/ui/snackbar.d.ts +18 -0
  37. package/lib/src/modules/ui.d.ts +17 -0
  38. package/lib/src/modules/user.d.ts +36 -0
  39. package/lib/src/modules/workflow.d.ts +24 -0
  40. package/lib/src/types.d.ts +381 -0
  41. package/lib/tools/publish.cjs +40 -3
  42. package/lib/types.d.ts +54 -15
  43. package/lib/version.d.ts +0 -0
  44. package/package.json +4 -2
@@ -0,0 +1,381 @@
1
+ export interface User {
2
+ _id: string;
3
+ firstname: string;
4
+ lastname: string;
5
+ email: string;
6
+ lastSeen: number;
7
+ status?: string;
8
+ managedUser?: boolean;
9
+ removed?: number;
10
+ defaultProfilepic: string;
11
+ }
12
+ export interface Workspace {
13
+ _id: string;
14
+ name: string;
15
+ members: string[];
16
+ settings: {
17
+ isolatedTeams?: boolean;
18
+ defaultView: string;
19
+ functionFieldVersion?: 1 | 2;
20
+ color?: string;
21
+ allowPublicCopy?: boolean;
22
+ };
23
+ license: object;
24
+ invoicing?: any;
25
+ propertyFields?: {
26
+ [section: string]: {
27
+ [field: string]: any;
28
+ };
29
+ };
30
+ }
31
+ export interface Activity {
32
+ _id: string;
33
+ process: string;
34
+ teamAccount: TeamAccount;
35
+ created: number;
36
+ uid: string;
37
+ cid: string;
38
+ discussion: string;
39
+ currentPhase: string;
40
+ active?: boolean;
41
+ history?: any[];
42
+ name?: string;
43
+ followers?: string[];
44
+ completePhases?: string[];
45
+ location?: {
46
+ type: 'point' | 'area' | 'polyline';
47
+ label: string | null;
48
+ data: {
49
+ lat: number;
50
+ lng: number;
51
+ }[];
52
+ };
53
+ fields?: any;
54
+ files?: any[];
55
+ updated?: number;
56
+ updatedBy?: string;
57
+ priority?: number;
58
+ sequence?: number;
59
+ }
60
+ export interface TeamAccount {
61
+ account: string;
62
+ team: string;
63
+ }
64
+ export interface FormsData {
65
+ files: string[];
66
+ history: {
67
+ 0: {
68
+ [fieldId: string]: {
69
+ value: any;
70
+ };
71
+ };
72
+ };
73
+ name: string;
74
+ location?: boolean;
75
+ uid?: string;
76
+ }
77
+ export interface FormsResponse {
78
+ name: string;
79
+ description?: string;
80
+ enableUnlinkedMode: boolean;
81
+ enableAttachments: boolean;
82
+ enableMapLocation: boolean;
83
+ locationRequired: 1;
84
+ phases: {
85
+ _id: string;
86
+ followers: [];
87
+ name: string;
88
+ description: string;
89
+ uid: string;
90
+ created: number;
91
+ fields: string[];
92
+ announcementFields: [];
93
+ announcementRecipients: [];
94
+ announcementFieldsOrder: [];
95
+ isEndpoint: boolean;
96
+ }[];
97
+ phasesOrder: string[];
98
+ fields: {
99
+ [id: string]: {
100
+ data: [];
101
+ label: string;
102
+ required: boolean;
103
+ type: string;
104
+ inviteToDiscussionOnChange: boolean;
105
+ _id: string;
106
+ created: number;
107
+ updated: number;
108
+ uid: string;
109
+ functionEnabled: boolean;
110
+ };
111
+ };
112
+ enableMessenger: boolean;
113
+ publicForm: {
114
+ enableMessaging: boolean;
115
+ };
116
+ fieldsOrder: [];
117
+ }
118
+ export interface FormCreateResponse {
119
+ key: string;
120
+ creator: string;
121
+ followers: string;
122
+ active: boolean;
123
+ enableMessaging: boolean;
124
+ allowRead: boolean;
125
+ }
126
+ export interface InsightResponse {
127
+ insight: {
128
+ name: string;
129
+ };
130
+ data: InsightResponseData;
131
+ }
132
+ export interface InsightResponseData {
133
+ headers: string[];
134
+ rows: [];
135
+ time: number;
136
+ }
137
+ export interface HailerAppConfig {
138
+ fields?: {
139
+ [fieldName: string]: {
140
+ type: string;
141
+ value?: string | number | boolean;
142
+ };
143
+ };
144
+ }
145
+ export type HailerProcess = Workflow;
146
+ export interface Workflow {
147
+ _id: string;
148
+ cid: string;
149
+ name: string;
150
+ description?: string;
151
+ fields: {
152
+ [fieldId: string]: any;
153
+ };
154
+ phases: {
155
+ [phase_id: string]: WorkflowPhase;
156
+ };
157
+ phasesOrder: string[];
158
+ enablePredefinedName?: boolean;
159
+ nameFunctionEnabled?: boolean;
160
+ nameEditable?: boolean;
161
+ productInstalledId: string;
162
+ }
163
+ export interface WorkflowPhase {
164
+ _id: string;
165
+ name: string;
166
+ description?: string;
167
+ fields?: string[];
168
+ }
169
+ export type PermissionType = 'admin' | 'own' | 'ownteam' | 'any' | 'edit';
170
+ export interface Member {
171
+ id: string;
172
+ info: {
173
+ [key: string]: string | number | boolean | null;
174
+ };
175
+ permissions: PermissionType[];
176
+ }
177
+ export interface InsightWorkflowSource {
178
+ name: string;
179
+ workflowId: string;
180
+ fields: {
181
+ name: string;
182
+ fieldId?: string;
183
+ /** Used for phaseLastMove meta */
184
+ phaseId?: string;
185
+ /** Activity information, like _id, created, phaseId etc. */
186
+ meta?: string;
187
+ }[];
188
+ }
189
+ export interface InsightDoc {
190
+ _id: string;
191
+ name: string;
192
+ sources: InsightWorkflowSource[];
193
+ cid: string;
194
+ /** User id of creator */
195
+ uid: string;
196
+ members: Member[];
197
+ updated: number;
198
+ public: boolean;
199
+ /** Key for accessing Insight when set to public */
200
+ publicKey?: string;
201
+ /** sandboxed javascript with access to all activities in given workflows */
202
+ function?: string;
203
+ /** To be used with SQLite if we want to.... */
204
+ query?: string;
205
+ presets: {
206
+ version: 1;
207
+ name: string | 'default';
208
+ options: any;
209
+ }[];
210
+ }
211
+ export type InsightPublic = Omit<InsightDoc, '_id'>;
212
+ export interface InsightData {
213
+ headers: string[];
214
+ rows: (string | number | null)[][];
215
+ time: number;
216
+ }
217
+ export interface InsightResponseAsObjectItem {
218
+ [key: string]: any;
219
+ }
220
+ export type InsightResponseAsObjects = InsightResponseAsObjectItem[];
221
+ export interface KanbanListResponse {
222
+ map: {
223
+ [phaseId: string]: {
224
+ activities: {
225
+ _id: string;
226
+ followers: string[];
227
+ name: string;
228
+ fields: {
229
+ [key: string]: any;
230
+ };
231
+ files: string[];
232
+ primaryDateField: number;
233
+ priority: number;
234
+ }[];
235
+ meta: {
236
+ count: number;
237
+ totalPrimaryNumericValue: number;
238
+ primaryNumericFieldUnit: string | null;
239
+ };
240
+ };
241
+ };
242
+ }
243
+ export interface KanbanLoadResponse {
244
+ activity: {
245
+ _id: string;
246
+ followers: string[];
247
+ name: string;
248
+ fields: {
249
+ [key: string]: any;
250
+ };
251
+ files: string[];
252
+ primaryDateField: number | null;
253
+ priority: number;
254
+ linkedFromCount: number;
255
+ };
256
+ process: string;
257
+ phase: string;
258
+ }
259
+ export interface ActivityListOptions {
260
+ sortBy?: 'name' | 'created' | 'updated' | 'following' | 'owner' | 'team' | 'completedOn' | 'priority';
261
+ sortOrder?: 'asc' | 'desc';
262
+ limit?: number;
263
+ skip?: number;
264
+ includeUsers?: boolean;
265
+ includeTeams?: boolean;
266
+ includeHistory?: boolean;
267
+ filters?: any;
268
+ }
269
+ export interface ActivityCreateOptions {
270
+ teamId?: string;
271
+ fileIds?: string[];
272
+ followerIds?: string[];
273
+ location?: {
274
+ label?: string;
275
+ type: 'area' | 'point' | 'polyline';
276
+ data: [{
277
+ lat: number;
278
+ lng: number;
279
+ }];
280
+ };
281
+ discussionId?: string;
282
+ phaseId?: string;
283
+ returnDocument?: boolean;
284
+ }
285
+ export interface ActivityKanbanListOptions {
286
+ filter: {
287
+ user?: {
288
+ uid: string;
289
+ field: string;
290
+ };
291
+ account?: string;
292
+ team?: string;
293
+ dates?: {
294
+ field: string;
295
+ start: number;
296
+ end: number;
297
+ };
298
+ };
299
+ search?: string;
300
+ limit?: number;
301
+ skip?: number;
302
+ phase?: string;
303
+ includeUsers?: boolean;
304
+ includeTeams?: boolean;
305
+ }
306
+ export interface HailerSettings {
307
+ theme: 'light' | 'dark';
308
+ preferredLanguages: string[];
309
+ }
310
+ export interface HailerError {
311
+ code: number;
312
+ msg: string;
313
+ debug: object;
314
+ }
315
+ export interface HailerApiInfo {
316
+ /** Url of the Hailer instance hosting the API */
317
+ hostUrl?: string;
318
+ config?: HailerAppConfig;
319
+ outside: boolean | null;
320
+ workspaceId?: string;
321
+ }
322
+ export declare class HailerError extends Error {
323
+ code: number;
324
+ msg: string;
325
+ debug: object;
326
+ constructor(error: {
327
+ code: number;
328
+ msg: string;
329
+ debug: object;
330
+ });
331
+ }
332
+ export interface HailerSignal {
333
+ sig: string;
334
+ meta: any;
335
+ }
336
+ export interface Product extends ProductType {
337
+ _id: string;
338
+ versionId: string;
339
+ name: string;
340
+ header?: string;
341
+ description?: string;
342
+ icon?: string;
343
+ images?: string[];
344
+ externalUrl?: string;
345
+ publisher?: string;
346
+ /** Available or not in app store */
347
+ public?: boolean;
348
+ cid?: string;
349
+ }
350
+ export interface ProductSearchOption {
351
+ limit?: number;
352
+ skip?: number;
353
+ search?: string;
354
+ reverse?: boolean;
355
+ sortBy?: 'name' | 'created' | 'updated' | 'type';
356
+ sortOrder?: 'asc' | 'desc';
357
+ }
358
+ export interface ProductSearchFilter extends ProductType {
359
+ public?: boolean;
360
+ cid?: string;
361
+ uid?: string;
362
+ }
363
+ export interface ProductType {
364
+ type?: 'app' | 'template' | 'document-template';
365
+ }
366
+ export interface ProductVersion {
367
+ _id: string;
368
+ name: string;
369
+ versions?: {
370
+ version: string;
371
+ description: string;
372
+ packageHash: string;
373
+ }[];
374
+ cid?: string;
375
+ }
376
+ export interface ProductInstalled {
377
+ _id: string;
378
+ productId: string;
379
+ versionId: string;
380
+ version: string;
381
+ }
@@ -42,6 +42,8 @@ if (!process.env.EMAIL && !process.env.LOCAL) {
42
42
  (async () => {
43
43
  let email = process.env.EMAIL;
44
44
  let password = process.env.LOCAL || await (0, minimal_password_prompt_1.default)('enter password for ' + email + ': ');
45
+ // Market code
46
+ const market = process.env.MARKET === 'true';
45
47
  const appPackageFile = process.argv[2];
46
48
  /** Alternatives: `--development` | `--staging` | `--production` */
47
49
  const mode = process.argv[3];
@@ -79,6 +81,22 @@ if (!process.env.EMAIL && !process.env.LOCAL) {
79
81
  const manifest = JSON.parse((0, fs_1.readFileSync)('./dist/manifest.json').toString());
80
82
  const content = (0, fs_1.readFileSync)(appPackageFile);
81
83
  const info = await cli.request('v2.core.init', [['network', 'networks', 'apps']], undefined);
84
+ // Market code
85
+ if (market) {
86
+ // Check if version exist in manifest.json. If not, add empty version and let user fill it in
87
+ if (!manifest.version) {
88
+ manifest.version = '';
89
+ manifest.versionDescription = '';
90
+ // Convert the modified object back to JSON
91
+ const updatedManifestContent = JSON.stringify(manifest, null, 2);
92
+ // Write the updated JSON content back to manifest.json
93
+ (0, fs_1.writeFileSync)('./public/manifest.json', updatedManifestContent, 'utf-8');
94
+ console.log('');
95
+ console.log('Please set version & versionDescription in file public/manifest.json! You have added MARKET=true in your publish string.');
96
+ console.log('');
97
+ process.exit(10);
98
+ }
99
+ }
82
100
  const getAppById = (manifestAppId) => {
83
101
  for (const appMap of Object.values(info.apps)) {
84
102
  for (const [appId, app] of Object.entries(appMap)) {
@@ -106,6 +124,10 @@ if (!process.env.EMAIL && !process.env.LOCAL) {
106
124
  }
107
125
  console.log(' Environment:', host);
108
126
  console.log();
127
+ // Market code
128
+ if (market) {
129
+ console.log(' Note: Also publishing app to Hailer market');
130
+ }
109
131
  /** Default to publish (yes) */
110
132
  const promptOverwriteQuestion = () => {
111
133
  return new Promise(resolve => {
@@ -140,20 +162,35 @@ if (!process.env.EMAIL && !process.env.LOCAL) {
140
162
  }
141
163
  },
142
164
  appId: manifest.appId,
165
+ // Market code
166
+ publishMarket: market.toString(),
143
167
  }
144
168
  }, function (error, resp, body) {
145
169
  if (error) {
146
170
  console.log('Publish error uploading file:', error);
147
171
  process.exit(9);
148
172
  }
149
- let manifest;
173
+ let response;
174
+ let infoMarket = '';
150
175
  try {
151
- manifest = JSON.parse(body);
176
+ response = JSON.parse(body);
177
+ // Market code
178
+ if (response.manifest && response.manifest.versionId) {
179
+ infoMarket = 'Note! Use versionId in public/manifest.json file when creating the product in market!';
180
+ // Write versionId to manifest.json
181
+ manifest.versionId = response.manifest.versionId;
182
+ // Convert the modified object back to JSON
183
+ const updatedManifestContent = JSON.stringify(manifest, null, 2);
184
+ // Write the updated JSON content back to manifest.json
185
+ (0, fs_1.writeFileSync)('./public/manifest.json', updatedManifestContent, 'utf-8');
186
+ }
152
187
  }
153
188
  catch (error) {
154
189
  // ingore
155
190
  }
156
- console.log('App info:', (0, util_1.inspect)(manifest, { depth: 10, colors: true }));
191
+ console.log('App info:', (0, util_1.inspect)(response, { depth: 10, colors: true }));
192
+ console.log();
193
+ console.log(infoMarket);
157
194
  console.log();
158
195
  console.log('Published successfully!');
159
196
  resolve();
package/lib/types.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export interface User {
2
+ _id: string;
2
3
  firstname: string;
3
4
  lastname: string;
4
5
  email: string;
@@ -6,25 +7,11 @@ export interface User {
6
7
  status?: string;
7
8
  managedUser?: boolean;
8
9
  removed?: number;
10
+ defaultProfilepic: string;
9
11
  }
10
12
  export interface Workspace {
11
13
  _id: string;
12
14
  name: string;
13
- members: string[];
14
- settings: {
15
- isolatedTeams?: boolean;
16
- defaultView: string;
17
- functionFieldVersion?: 1 | 2;
18
- color?: string;
19
- allowPublicCopy?: boolean;
20
- };
21
- license: object;
22
- invoicing?: any;
23
- propertyFields?: {
24
- [section: string]: {
25
- [field: string]: any;
26
- };
27
- };
28
15
  }
29
16
  export interface Activity {
30
17
  _id: string;
@@ -153,11 +140,16 @@ export interface Workflow {
153
140
  [phase_id: string]: WorkflowPhase;
154
141
  };
155
142
  phasesOrder: string[];
143
+ enablePredefinedName?: boolean;
144
+ nameFunctionEnabled?: boolean;
145
+ nameEditable?: boolean;
146
+ productInstalledId: string;
156
147
  }
157
148
  export interface WorkflowPhase {
158
149
  _id: string;
159
150
  name: string;
160
151
  description?: string;
152
+ fields?: string[];
161
153
  }
162
154
  export type PermissionType = 'admin' | 'own' | 'ownteam' | 'any' | 'edit';
163
155
  export interface Member {
@@ -310,6 +302,7 @@ export interface HailerApiInfo {
310
302
  hostUrl?: string;
311
303
  config?: HailerAppConfig;
312
304
  outside: boolean | null;
305
+ workspaceId?: string;
313
306
  }
314
307
  export declare class HailerError extends Error {
315
308
  code: number;
@@ -325,3 +318,49 @@ export interface HailerSignal {
325
318
  sig: string;
326
319
  meta: any;
327
320
  }
321
+ export interface Product extends ProductType {
322
+ _id: string;
323
+ versionId: string;
324
+ name: string;
325
+ description?: string;
326
+ icon?: string;
327
+ images?: string[];
328
+ externalUrl?: string;
329
+ publisher?: string;
330
+ /** Available or not in app store */
331
+ public?: boolean;
332
+ cid?: string;
333
+ }
334
+ export interface ProductSearchOption {
335
+ limit?: number;
336
+ skip?: number;
337
+ search?: string;
338
+ reverse?: boolean;
339
+ sortBy?: 'name' | 'created' | 'updated' | 'type';
340
+ sortOrder?: 'asc' | 'desc';
341
+ }
342
+ export interface ProductSearchFilter extends ProductType {
343
+ public?: boolean;
344
+ cid?: string;
345
+ uid?: string;
346
+ }
347
+ export interface ProductType {
348
+ type?: 'app' | 'template' | 'document-template';
349
+ }
350
+ export interface ProductVersion {
351
+ _id: string;
352
+ name: string;
353
+ versions?: {
354
+ version: string;
355
+ description: string;
356
+ packageHash: string;
357
+ created: number;
358
+ }[];
359
+ cid?: string;
360
+ }
361
+ export interface ProductInstalled {
362
+ _id: string;
363
+ productId: string;
364
+ versionId: string;
365
+ version: string;
366
+ }
File without changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hailer/app-sdk",
3
- "version": "1.0.1-beta7",
3
+ "version": "1.0.2",
4
4
  "description": "SDK for building Hailer Apps",
5
5
  "author": "",
6
6
  "license": "ISC",
@@ -15,7 +15,7 @@
15
15
  "prepublishOnly": "npm run build",
16
16
  "watch": "concurrently --kill-others \"npm run watch-tsc\" \"npm run watch-esbuild\"",
17
17
  "watch-tsc": "tsc --watch",
18
- "watch-esbuild": "esbuild src/index.ts --bundle --format=esm --minify --sourcemap --outfile=lib/app-sdk.js --watch",
18
+ "watch-esbuild": "esbuild src/index.ts --bundle --format=esm --sourcemap --outfile=lib/app-sdk.js --watch",
19
19
  "docs": "typedoc --entryPointStrategy expand ./src && open-cli ./docs/index.html"
20
20
  },
21
21
  "dependencies": {
@@ -26,9 +26,11 @@
26
26
  },
27
27
  "devDependencies": {
28
28
  "@types/node": "^18.15.10",
29
+ "@types/request": "2.48.8",
29
30
  "@typescript-eslint/eslint-plugin": "^5.60.0",
30
31
  "@typescript-eslint/parser": "^5.60.0",
31
32
  "concurrently": "8.2.1",
33
+ "esbuild": "^0.19.9",
32
34
  "eslint": "^8.43.0",
33
35
  "open-cli": "^7.2.0",
34
36
  "typedoc": "^0.24.8",