nsa-sheets-db-builder 0.0.1-alpha.0

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/LICENSE +21 -0
  2. package/README.md +188 -0
  3. package/bin/sheets-deployer.mjs +169 -0
  4. package/libs/alasql.js +15577 -0
  5. package/libs/common/gas_response_helper.ts +147 -0
  6. package/libs/common/gaserror.ts +101 -0
  7. package/libs/common/gaslogger.ts +172 -0
  8. package/libs/db_ddl.ts +316 -0
  9. package/libs/libraries.json +56 -0
  10. package/libs/spreadsheets_db.ts +4406 -0
  11. package/libs/triggers.ts +113 -0
  12. package/package.json +73 -0
  13. package/scripts/build.mjs +513 -0
  14. package/scripts/clean.mjs +31 -0
  15. package/scripts/create.mjs +94 -0
  16. package/scripts/ddl-handler.mjs +232 -0
  17. package/scripts/describe.mjs +38 -0
  18. package/scripts/drop.mjs +39 -0
  19. package/scripts/init.mjs +465 -0
  20. package/scripts/lib/utils.mjs +1019 -0
  21. package/scripts/login.mjs +102 -0
  22. package/scripts/provision.mjs +35 -0
  23. package/scripts/refresh-cache.mjs +34 -0
  24. package/scripts/set-key.mjs +48 -0
  25. package/scripts/setup-trigger.mjs +95 -0
  26. package/scripts/setup.mjs +677 -0
  27. package/scripts/show.mjs +37 -0
  28. package/scripts/sync.mjs +35 -0
  29. package/scripts/whoami.mjs +36 -0
  30. package/src/api/ddl-handler-entry.ts +136 -0
  31. package/src/api/ddl.ts +321 -0
  32. package/src/templates/.clasp.json.ejs +1 -0
  33. package/src/templates/appsscript.json.ejs +16 -0
  34. package/src/templates/config.ts.ejs +14 -0
  35. package/src/templates/ddl-handler-config.ts.ejs +3 -0
  36. package/src/templates/ddl-handler-main.ts.ejs +56 -0
  37. package/src/templates/main.ts.ejs +288 -0
  38. package/src/templates/rbac.ts.ejs +148 -0
  39. package/src/templates/views.ts.ejs +92 -0
  40. package/templates/blank.json +33 -0
  41. package/templates/blog-cms.json +507 -0
  42. package/templates/crm.json +360 -0
  43. package/templates/e-commerce.json +424 -0
  44. package/templates/inventory.json +307 -0
@@ -0,0 +1,360 @@
1
+ {
2
+ "name": "crm",
3
+ "description": "CRM — contacts, companies, deals, activities, notes, tags",
4
+ "tables": {
5
+ "companies": {
6
+ "spreadsheetId": "__new__",
7
+ "sheetName": "companies",
8
+ "schema": {
9
+ "id": {
10
+ "type": "string",
11
+ "primaryKey": true,
12
+ "required": true
13
+ },
14
+ "name": {
15
+ "type": "string",
16
+ "required": true
17
+ },
18
+ "domain": {
19
+ "type": "string"
20
+ },
21
+ "industry": {
22
+ "type": "string"
23
+ },
24
+ "size": {
25
+ "type": "string"
26
+ },
27
+ "phone": {
28
+ "type": "string"
29
+ },
30
+ "address": {
31
+ "type": "string"
32
+ },
33
+ "city": {
34
+ "type": "string"
35
+ },
36
+ "country": {
37
+ "type": "string"
38
+ },
39
+ "notes": {
40
+ "type": "string"
41
+ },
42
+ "__audit__": {
43
+ "type": "object"
44
+ },
45
+ "__archived__": {
46
+ "type": "boolean",
47
+ "defaultValue": false
48
+ }
49
+ },
50
+ "idGenerator": "UUID",
51
+ "deleteMode": "soft"
52
+ },
53
+ "contacts": {
54
+ "spreadsheetId": "__new__",
55
+ "sheetName": "contacts",
56
+ "schema": {
57
+ "id": {
58
+ "type": "string",
59
+ "primaryKey": true,
60
+ "required": true
61
+ },
62
+ "first_name": {
63
+ "type": "string",
64
+ "required": true
65
+ },
66
+ "last_name": {
67
+ "type": "string",
68
+ "required": true
69
+ },
70
+ "email": {
71
+ "type": "string",
72
+ "required": true
73
+ },
74
+ "phone": {
75
+ "type": "string"
76
+ },
77
+ "title": {
78
+ "type": "string"
79
+ },
80
+ "company_id": {
81
+ "type": "string",
82
+ "foreignKey": "companies.id"
83
+ },
84
+ "source": {
85
+ "type": "string"
86
+ },
87
+ "status": {
88
+ "type": "string",
89
+ "defaultValue": "active"
90
+ },
91
+ "__audit__": {
92
+ "type": "object"
93
+ },
94
+ "__archived__": {
95
+ "type": "boolean",
96
+ "defaultValue": false
97
+ }
98
+ },
99
+ "idGenerator": "UUID",
100
+ "deleteMode": "soft"
101
+ },
102
+ "deals": {
103
+ "spreadsheetId": "__new__",
104
+ "sheetName": "deals",
105
+ "schema": {
106
+ "id": {
107
+ "type": "string",
108
+ "primaryKey": true,
109
+ "required": true
110
+ },
111
+ "name": {
112
+ "type": "string",
113
+ "required": true
114
+ },
115
+ "contact_id": {
116
+ "type": "string",
117
+ "foreignKey": "contacts.id"
118
+ },
119
+ "company_id": {
120
+ "type": "string",
121
+ "foreignKey": "companies.id"
122
+ },
123
+ "stage": {
124
+ "type": "string",
125
+ "required": true,
126
+ "defaultValue": "lead"
127
+ },
128
+ "value": {
129
+ "type": "number"
130
+ },
131
+ "currency": {
132
+ "type": "string",
133
+ "defaultValue": "USD"
134
+ },
135
+ "probability": {
136
+ "type": "number"
137
+ },
138
+ "expected_close": {
139
+ "type": "datetime",
140
+ "outputFormat": "yyyy-MM-dd",
141
+ "timezone": "UTC"
142
+ },
143
+ "owner": {
144
+ "type": "string"
145
+ },
146
+ "notes": {
147
+ "type": "string"
148
+ },
149
+ "__audit__": {
150
+ "type": "object"
151
+ },
152
+ "__archived__": {
153
+ "type": "boolean",
154
+ "defaultValue": false
155
+ }
156
+ },
157
+ "idGenerator": "UUID",
158
+ "deleteMode": "soft"
159
+ },
160
+ "activities": {
161
+ "spreadsheetId": "__new__",
162
+ "sheetName": "activities",
163
+ "schema": {
164
+ "id": {
165
+ "type": "string",
166
+ "primaryKey": true,
167
+ "required": true
168
+ },
169
+ "type": {
170
+ "type": "string",
171
+ "required": true
172
+ },
173
+ "subject": {
174
+ "type": "string",
175
+ "required": true
176
+ },
177
+ "description": {
178
+ "type": "string"
179
+ },
180
+ "contact_id": {
181
+ "type": "string",
182
+ "foreignKey": "contacts.id"
183
+ },
184
+ "deal_id": {
185
+ "type": "string",
186
+ "foreignKey": "deals.id"
187
+ },
188
+ "due_date": {
189
+ "type": "datetime",
190
+ "outputFormat": "yyyy-MM-dd HH:mm:ss",
191
+ "timezone": "UTC"
192
+ },
193
+ "completed": {
194
+ "type": "boolean",
195
+ "defaultValue": false
196
+ },
197
+ "owner": {
198
+ "type": "string"
199
+ },
200
+ "__audit__": {
201
+ "type": "object"
202
+ },
203
+ "__archived__": {
204
+ "type": "boolean",
205
+ "defaultValue": false
206
+ }
207
+ },
208
+ "idGenerator": "UUID",
209
+ "deleteMode": "soft"
210
+ },
211
+ "notes": {
212
+ "spreadsheetId": "__new__",
213
+ "sheetName": "notes",
214
+ "schema": {
215
+ "id": {
216
+ "type": "string",
217
+ "primaryKey": true,
218
+ "required": true
219
+ },
220
+ "body": {
221
+ "type": "string",
222
+ "prefixed": true,
223
+ "required": true
224
+ },
225
+ "contact_id": {
226
+ "type": "string",
227
+ "foreignKey": "contacts.id"
228
+ },
229
+ "deal_id": {
230
+ "type": "string",
231
+ "foreignKey": "deals.id"
232
+ },
233
+ "company_id": {
234
+ "type": "string",
235
+ "foreignKey": "companies.id"
236
+ },
237
+ "author": {
238
+ "type": "string"
239
+ },
240
+ "__audit__": {
241
+ "type": "object"
242
+ },
243
+ "__archived__": {
244
+ "type": "boolean",
245
+ "defaultValue": false
246
+ }
247
+ },
248
+ "idGenerator": "UUID",
249
+ "deleteMode": "soft"
250
+ },
251
+ "comments": {
252
+ "spreadsheetId": "__new__",
253
+ "sheetName": "comments",
254
+ "schema": {
255
+ "id": {
256
+ "type": "string",
257
+ "primaryKey": true,
258
+ "required": true
259
+ },
260
+ "entity_type": {
261
+ "type": "string",
262
+ "required": true
263
+ },
264
+ "entity_id": {
265
+ "type": "string",
266
+ "required": true
267
+ },
268
+ "parent_id": {
269
+ "type": "string",
270
+ "foreignKey": "comments.id"
271
+ },
272
+ "author_name": {
273
+ "type": "string",
274
+ "required": true
275
+ },
276
+ "author_email": {
277
+ "type": "string"
278
+ },
279
+ "author_id": {
280
+ "type": "string"
281
+ },
282
+ "body": {
283
+ "type": "string",
284
+ "required": true
285
+ },
286
+ "status": {
287
+ "type": "string",
288
+ "required": true,
289
+ "defaultValue": "approved"
290
+ },
291
+ "__audit__": {
292
+ "type": "object"
293
+ },
294
+ "__archived__": {
295
+ "type": "boolean",
296
+ "defaultValue": false
297
+ }
298
+ },
299
+ "idGenerator": "UUID",
300
+ "deleteMode": "soft"
301
+ },
302
+ "tags": {
303
+ "spreadsheetId": "__new__",
304
+ "sheetName": "tags",
305
+ "schema": {
306
+ "id": {
307
+ "type": "string",
308
+ "primaryKey": true,
309
+ "required": true
310
+ },
311
+ "name": {
312
+ "type": "string",
313
+ "required": true
314
+ },
315
+ "color": {
316
+ "type": "string"
317
+ },
318
+ "__audit__": {
319
+ "type": "object"
320
+ },
321
+ "__archived__": {
322
+ "type": "boolean",
323
+ "defaultValue": false
324
+ }
325
+ },
326
+ "idGenerator": "UUID",
327
+ "deleteMode": "soft"
328
+ },
329
+ "contact_tags": {
330
+ "spreadsheetId": "__new__",
331
+ "sheetName": "contact_tags",
332
+ "schema": {
333
+ "id": {
334
+ "type": "string",
335
+ "primaryKey": true,
336
+ "required": true
337
+ },
338
+ "contact_id": {
339
+ "type": "string",
340
+ "required": true,
341
+ "foreignKey": "contacts.id"
342
+ },
343
+ "tag_id": {
344
+ "type": "string",
345
+ "required": true,
346
+ "foreignKey": "tags.id"
347
+ },
348
+ "__audit__": {
349
+ "type": "object"
350
+ },
351
+ "__archived__": {
352
+ "type": "boolean",
353
+ "defaultValue": false
354
+ }
355
+ },
356
+ "idGenerator": "UUID",
357
+ "deleteMode": "hard"
358
+ }
359
+ }
360
+ }