@placeshakr/config 10.20.0 → 10.20.2-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.
@@ -157,25 +157,23 @@ const productionEnvironment: Environment = {
157
157
  systemVersion: 'systemVersions/{systemVersionId}',
158
158
  },
159
159
  indexes: {
160
- // tslint:disable-next-line: object-literal-sort-keys
161
- clients: 'clients',
162
- pros: 'pros',
160
+ // users
161
+ admins: 'admins',
163
162
  agents: 'agents',
163
+ pros: 'pros',
164
164
  sellers: 'sellers',
165
+ clients: 'clients',
166
+ // projects
165
167
  projects: 'projects',
166
168
  medias: 'projects-medias',
167
169
  events: 'projects-events',
168
170
  devis: 'projects-devis',
169
- admins: 'admins',
171
+ // configuration
170
172
  providers: 'providers',
171
173
  materials: 'materials',
172
174
  operations: 'operations',
173
175
  operationsMaterials: 'operations-materials',
174
- materialsProvider: 'materials-provider',
175
- devisTemplates: 'devis-templates',
176
176
  estimations: 'estimations',
177
- categories: 'categories',
178
- operationsCatalogs: 'operations-catalogs',
179
177
  nomenclatures: 'nomenclatures',
180
178
  operationsGroups: 'operations-groups',
181
179
  // used only for managment
@@ -461,19 +459,6 @@ const productionEnvironment: Environment = {
461
459
  maxValuesPerFacet: 1000,
462
460
  maxFacetHits: 100,
463
461
  },
464
- materialsProvider: {
465
- searchableAttributes: ['name', 'status', 'identifier'],
466
- attributesForFaceting: [
467
- 'searchable(scope)',
468
- 'searchable(status)',
469
- 'searchable(identifier)',
470
- 'searchable(addMaterials)',
471
- 'searchable(editable)',
472
- ],
473
- ranking: ['desc(status)', 'desc(updatedAt)'],
474
- maxValuesPerFacet: 1000,
475
- maxFacetHits: 100,
476
- },
477
462
  systemMaterials: {
478
463
  searchableAttributes: ['name', 'unitPrice'],
479
464
  attributesForFaceting: [
@@ -529,17 +514,6 @@ const productionEnvironment: Environment = {
529
514
  maxValuesPerFacet: 1000,
530
515
  maxFacetHits: 100,
531
516
  },
532
- devisTemplates: {
533
- searchableAttributes: ['name'],
534
- attributesForFaceting: [
535
- 'searchable(scope)',
536
- 'materialsProvider',
537
- 'searchable(category)',
538
- ],
539
- ranking: ['desc(updatedAt)'],
540
- maxValuesPerFacet: 1000,
541
- maxFacetHits: 100,
542
- },
543
517
  estimations: {
544
518
  searchableAttributes: [
545
519
  'name',
@@ -565,18 +539,6 @@ const productionEnvironment: Environment = {
565
539
  maxValuesPerFacet: 1000,
566
540
  maxFacetHits: 100,
567
541
  },
568
- categories: {
569
- searchableAttributes: ['name'],
570
- attributesForFaceting: [
571
- 'searchable(entity)',
572
- 'searchable(parent)',
573
- 'searchable(scope)',
574
- 'searchable(provider)',
575
- ],
576
- ranking: ['asc(name)'],
577
- maxValuesPerFacet: 1000,
578
- maxFacetHits: 100,
579
- },
580
542
  systemCategories: {
581
543
  searchableAttributes: ['name'],
582
544
  attributesForFaceting: [
@@ -588,13 +550,6 @@ const productionEnvironment: Environment = {
588
550
  maxValuesPerFacet: 1000,
589
551
  maxFacetHits: 100,
590
552
  },
591
- operationsCatalogs: {
592
- searchableAttributes: ['name'],
593
- attributesForFaceting: ['searchable(scope)', 'searchable(status)'],
594
- ranking: ['asc(name)'],
595
- maxValuesPerFacet: 1000,
596
- maxFacetHits: 100,
597
- },
598
553
  nomenclatures: {
599
554
  searchableAttributes: ['value'],
600
555
  attributesForFaceting: [
@@ -32,27 +32,26 @@ export interface Environment {
32
32
  */
33
33
  schema: {
34
34
  indexes: {
35
- clients: string;
36
- pros: string;
35
+ // users - 5
36
+ admins: string;
37
37
  agents: string;
38
+ pros: string;
38
39
  sellers: string;
40
+ clients: string;
41
+ // projects - 4
39
42
  projects: string;
40
43
  medias: string;
41
44
  events: string;
42
45
  devis: string;
43
- admins: string;
46
+ // configuration - 7
44
47
  providers: string;
45
48
  materials: string;
46
49
  operations: string;
47
50
  operationsMaterials: string;
48
- materialsProvider: string;
49
- devisTemplates: string;
50
51
  estimations: string;
51
- categories: string;
52
- operationsCatalogs: string;
53
52
  nomenclatures: string;
54
53
  operationsGroups: string;
55
- // used only for management
54
+ // used only for management - 7
56
55
  systemMaterials: string;
57
56
  systemOperations: string;
58
57
  systemOperationsMaterials: string;
package/src/index.ts CHANGED
@@ -4,7 +4,10 @@ import { Environment, Environments, getEnv } from './environment';
4
4
  import helpers, { Helpers, FactoryCreate } from './helpers';
5
5
  import { uid } from './helpers/uid';
6
6
  import path, { reversePathName } from './path';
7
- import getPlatformConfiguration, { SubscriptionSettings, Product } from './plans';
7
+ import getPlatformConfiguration, {
8
+ SubscriptionSettings,
9
+ Product,
10
+ } from './plans';
8
11
  import {
9
12
  ProductReference,
10
13
  DeploymentEnvironment,
@@ -13,6 +16,7 @@ import {
13
16
  import * as articho from './types';
14
17
  import { flatten } from './utils/flatten';
15
18
  import { AppEvent, EventMetadata, createEvent } from './events';
19
+ import * as WhatsApp from './whatsapp';
16
20
 
17
21
  export {
18
22
  DeploymentEnvironment,
@@ -43,4 +47,6 @@ export {
43
47
  flatten,
44
48
  Policy,
45
49
  acls,
50
+ //whatsapp
51
+ WhatsApp,
46
52
  };
package/src/types.ts CHANGED
@@ -437,6 +437,7 @@ export interface Enterprise extends Resource {
437
437
  quoteBasicCreation?: boolean;
438
438
  quoteAdvancedWithNewDesign?: boolean;
439
439
  exportLogs?: boolean;
440
+ whatsapp?: boolean;
440
441
  };
441
442
 
442
443
  /**
@@ -0,0 +1,4 @@
1
+ import * as Requests from './requests';
2
+ import type * as Responses from './responses';
3
+
4
+ export { Requests, Responses };
@@ -0,0 +1,113 @@
1
+ type NotifyQuoteStatusApprovedMessage = {
2
+ name: 'notify_quote_status_approved';
3
+ variables: {
4
+ header?: string[];
5
+ // 1. quoteTitle; 2. project address;
6
+ body: string[];
7
+ buttons?: ButtonArgs[];
8
+ };
9
+ };
10
+
11
+ type SendQuotePro = {
12
+ name: 'send_quote_pro';
13
+ variables: {
14
+ header?: string[];
15
+ // 1. quote name; 2. project address;
16
+ body: string[];
17
+ buttons?: ButtonArgs[];
18
+ };
19
+ };
20
+
21
+ type SendMediaRequest = {
22
+ name: 'send_media_request';
23
+ variables: {
24
+ header?: string[];
25
+ // 1. sender name; 2. project name; 3. project address;
26
+ body: string[];
27
+ buttons: ButtonArgs[];
28
+ };
29
+ };
30
+
31
+ type SendPlanRequest = {
32
+ name: 'send_plan_request';
33
+ variables: {
34
+ header?: string[];
35
+ // 1. sender name; 2. project name; 3. project address;
36
+ body: string[];
37
+ buttons: ButtonArgs[];
38
+ };
39
+ };
40
+
41
+ type QuoteReady = {
42
+ name: 'quote_ready';
43
+ variables: {
44
+ header?: string[];
45
+ // 1. sender name; 2. quote name; 3. project address
46
+ body: string[];
47
+ buttons: ButtonArgs[];
48
+ };
49
+ };
50
+
51
+ type WelcomeClient = {
52
+ name: 'welcome_client';
53
+ variables: {
54
+ header?: string[];
55
+ body?: string[];
56
+ buttons?: ButtonArgs[];
57
+ };
58
+ };
59
+
60
+ type ButtonArgs = {
61
+ type: 'button';
62
+ sub_type: 'quick_reply' | 'url';
63
+ index?: number;
64
+ parameters: { type: 'payload' | 'text'; value: string }[];
65
+ };
66
+
67
+ export type WhatsAppTemplate =
68
+ | NotifyQuoteStatusApprovedMessage
69
+ | SendQuotePro
70
+ | SendMediaRequest
71
+ | SendPlanRequest
72
+ | WelcomeClient
73
+ | QuoteReady;
74
+
75
+ type TemplatePayloadArgs = {
76
+ type: 'template';
77
+ recipientPhone: string;
78
+ template: WhatsAppTemplate;
79
+ };
80
+
81
+ export type WhatsAppRequestPayloadType =
82
+ | 'audio'
83
+ | 'document'
84
+ | 'image'
85
+ | 'sticker'
86
+ | 'video'
87
+ | 'template'
88
+ | 'text';
89
+
90
+ type CommonMultimediaPayload<T extends WhatsAppRequestPayloadType> = {
91
+ [key in T]: {
92
+ link: string;
93
+ filename: string;
94
+ };
95
+ };
96
+
97
+ type TextPayloadArgs = {
98
+ type: 'text';
99
+ recipientPhone: string;
100
+ message: string;
101
+ };
102
+
103
+ type MultimediaPayloadArgs<T extends WhatsAppRequestPayloadType> = {
104
+ type: T;
105
+ recipientPhone: string;
106
+ } & CommonMultimediaPayload<T>;
107
+
108
+ export type WABuildPayloadType<Type extends WhatsAppRequestPayloadType> =
109
+ Type extends 'text'
110
+ ? TextPayloadArgs
111
+ : Type extends 'template'
112
+ ? TemplatePayloadArgs
113
+ : MultimediaPayloadArgs<Type>;
@@ -0,0 +1,198 @@
1
+ export type WhatsAppNotificationPayload = {
2
+ object: 'whatsapp_business_account';
3
+ entry: [
4
+ {
5
+ id: string;
6
+ changes: WhatAppNotificationValue[];
7
+ }
8
+ ];
9
+ };
10
+
11
+ export type WhatAppNotificationValue = {
12
+ value: {
13
+ contacts: WhatsAppContact[];
14
+ errors?: WhatsAppResponseError[];
15
+ messaging_product: 'whatsapp';
16
+ metadata: WhatsAppMetadata;
17
+ messages?: WhatsAppMessage[];
18
+ statuses?: WhatsAppStatus[];
19
+ };
20
+ field: 'messages';
21
+ };
22
+
23
+ type WhatsAppContact = {
24
+ wa_id: string;
25
+ profile: {
26
+ name: string;
27
+ };
28
+ };
29
+
30
+ type WhatsAppResponseError = {
31
+ code: number;
32
+ title: string;
33
+ message: string;
34
+ error_data: {
35
+ details: string;
36
+ };
37
+ };
38
+
39
+ type WhatsAppMetadata = {
40
+ display_phone_number: string;
41
+ phone_number_id: string;
42
+ };
43
+
44
+ export type WhatsAppMessage = {
45
+ audio?: {
46
+ id: string;
47
+ mime_type: string;
48
+ };
49
+ button?: {
50
+ payload: string;
51
+ text: string;
52
+ };
53
+ context?: {
54
+ forwarded: boolean;
55
+ frequently_forwarded: boolean;
56
+ from: string;
57
+ id: string;
58
+ referred_product: {
59
+ catalog_id: string;
60
+ product_retailer_id: string;
61
+ };
62
+ };
63
+ document?: {
64
+ caption?: string;
65
+ filename: string;
66
+ sha256: string;
67
+ mime_type: string;
68
+ id: string;
69
+ };
70
+ errors: {
71
+ code: number;
72
+ title: string;
73
+ message: string;
74
+ error_data: {
75
+ details: string;
76
+ };
77
+ };
78
+ from: string;
79
+ id: string;
80
+ image?: {
81
+ caption?: string;
82
+ sha256: string;
83
+ id: string;
84
+ mime_type: string;
85
+ };
86
+ interactive?: {
87
+ type: string;
88
+ button_reply: {
89
+ id: string;
90
+ title: string;
91
+ };
92
+ list_reply: {
93
+ id: string;
94
+ title: string;
95
+ description: string;
96
+ };
97
+ };
98
+ order?: {
99
+ catalog_id: string;
100
+ text: string;
101
+ product_items: {
102
+ product_retailer_id: string;
103
+ quantity: string;
104
+ item_price: string;
105
+ currency: string;
106
+ }[];
107
+ };
108
+ referral?: {
109
+ source_url: string;
110
+ source_type: 'ad' | 'post';
111
+ source_id: string;
112
+ headline: string;
113
+ body: string;
114
+ media_type: 'image' | 'video';
115
+ image_url?: string;
116
+ video_url?: string;
117
+ thumbnail_url?: string;
118
+ ctwa_clid: string;
119
+ };
120
+ sticker?: {
121
+ mime_type: string;
122
+ sha256: string;
123
+ id: string;
124
+ animated: boolean;
125
+ };
126
+ system?: {
127
+ body: string;
128
+ identity: string;
129
+ new_wa_id: string;
130
+ wa_id: string;
131
+ type: 'customer_changed_number' | 'customer_identity_changed';
132
+ customer: string;
133
+ };
134
+ text?: {
135
+ body: string;
136
+ };
137
+ timestamp: string;
138
+ type: WhatsAppMessageType;
139
+ video?: {
140
+ caption: string;
141
+ filename: string;
142
+ sha256: string;
143
+ id: string;
144
+ mime_type: string;
145
+ };
146
+ };
147
+
148
+ type WhatsAppStatus = {
149
+ biz_opaque_callback_data: string;
150
+ conversation: {
151
+ id: string;
152
+ origin: {
153
+ type:
154
+ | 'authentication'
155
+ | 'marketing'
156
+ | 'utility'
157
+ | 'service'
158
+ | 'referral_conversion';
159
+ };
160
+ expiration_timestamp?: string;
161
+ };
162
+ errors: {
163
+ code: number;
164
+ title: string;
165
+ message: string;
166
+ error_data: {
167
+ details: string;
168
+ };
169
+ }[];
170
+ id: string;
171
+ pricing: {
172
+ category:
173
+ | 'authentication'
174
+ | 'marketing'
175
+ | 'utility'
176
+ | 'service'
177
+ | 'referral_conversion';
178
+ pricing_model: 'CBP';
179
+ };
180
+ recipient_id: string;
181
+ status: 'delivered' | 'read' | 'sent';
182
+ timestamp: string;
183
+ };
184
+
185
+ export enum WhatsAppMessageType {
186
+ audio = 'audio',
187
+ button = 'button',
188
+ document = 'document',
189
+ text = 'text',
190
+ image = 'image',
191
+ interactive = 'interactive',
192
+ order = 'order',
193
+ sticker = 'sticker',
194
+ system = 'system',
195
+ unknown = 'unknown',
196
+ video = 'video',
197
+ location = 'location',
198
+ }