cloudcommerce 0.0.59 → 0.0.60

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 (135) hide show
  1. package/.eslintrc.cjs +2 -0
  2. package/CHANGELOG.md +23 -0
  3. package/package.json +9 -8
  4. package/packages/api/lib/api.d.ts +5036 -0
  5. package/packages/api/lib/{index.js → api.js} +16 -10
  6. package/packages/api/lib/api.js.map +1 -0
  7. package/packages/api/lib/types.d.ts +1 -0
  8. package/packages/api/package.json +3 -3
  9. package/packages/api/src/{index.ts → api.ts} +21 -17
  10. package/packages/api/src/types.ts +1 -0
  11. package/packages/api/tests/index.test.ts +2 -2
  12. package/packages/apps/discounts/lib/discounts.js +1 -1
  13. package/packages/apps/discounts/lib/discounts.js.map +1 -1
  14. package/packages/apps/discounts/{lib-cjs/apply-discount.cjs → lib-mjs/apply-discount.mjs} +7 -9
  15. package/packages/apps/discounts/{lib-cjs/helpers.cjs → lib-mjs/helpers.mjs} +2 -2
  16. package/packages/apps/discounts/package.json +1 -1
  17. package/packages/apps/discounts/src/discounts.ts +1 -1
  18. package/packages/apps/tiny-erp/lib/event-to-tiny.js +111 -0
  19. package/packages/apps/tiny-erp/lib/event-to-tiny.js.map +1 -0
  20. package/packages/apps/tiny-erp/lib/index.js +2 -0
  21. package/packages/apps/tiny-erp/lib/index.js.map +1 -0
  22. package/packages/apps/tiny-erp/lib/integration/after-tiny-queue.js +79 -0
  23. package/packages/apps/tiny-erp/lib/integration/after-tiny-queue.js.map +1 -0
  24. package/packages/apps/tiny-erp/lib/integration/export-order-to-tiny.js +81 -0
  25. package/packages/apps/tiny-erp/lib/integration/export-order-to-tiny.js.map +1 -0
  26. package/packages/apps/tiny-erp/lib/integration/export-product-to-tiny.js +58 -0
  27. package/packages/apps/tiny-erp/lib/integration/export-product-to-tiny.js.map +1 -0
  28. package/packages/apps/tiny-erp/lib/integration/helpers/format-tiny-date.js +7 -0
  29. package/packages/apps/tiny-erp/lib/integration/helpers/format-tiny-date.js.map +1 -0
  30. package/packages/apps/tiny-erp/lib/integration/import-order-from-tiny.js +94 -0
  31. package/packages/apps/tiny-erp/lib/integration/import-order-from-tiny.js.map +1 -0
  32. package/packages/apps/tiny-erp/lib/integration/import-product-from-tiny.js +169 -0
  33. package/packages/apps/tiny-erp/lib/integration/import-product-from-tiny.js.map +1 -0
  34. package/packages/apps/tiny-erp/lib/integration/parsers/order-from-tiny.js +46 -0
  35. package/packages/apps/tiny-erp/lib/integration/parsers/order-from-tiny.js.map +1 -0
  36. package/packages/apps/tiny-erp/lib/integration/parsers/order-to-tiny.js +193 -0
  37. package/packages/apps/tiny-erp/lib/integration/parsers/order-to-tiny.js.map +1 -0
  38. package/packages/apps/tiny-erp/lib/integration/parsers/product-from-tiny.js +199 -0
  39. package/packages/apps/tiny-erp/lib/integration/parsers/product-from-tiny.js.map +1 -0
  40. package/packages/apps/tiny-erp/lib/integration/parsers/product-to-tiny.js +129 -0
  41. package/packages/apps/tiny-erp/lib/integration/parsers/product-to-tiny.js.map +1 -0
  42. package/packages/apps/tiny-erp/lib/integration/parsers/status-from-tiny.js +34 -0
  43. package/packages/apps/tiny-erp/lib/integration/parsers/status-from-tiny.js.map +1 -0
  44. package/packages/apps/tiny-erp/lib/integration/parsers/status-to-tiny.js +39 -0
  45. package/packages/apps/tiny-erp/lib/integration/parsers/status-to-tiny.js.map +1 -0
  46. package/packages/apps/tiny-erp/lib/integration/post-tiny-erp.js +47 -0
  47. package/packages/apps/tiny-erp/lib/integration/post-tiny-erp.js.map +1 -0
  48. package/packages/apps/tiny-erp/lib/tiny-erp.js +17 -0
  49. package/packages/apps/tiny-erp/lib/tiny-erp.js.map +1 -0
  50. package/packages/apps/tiny-erp/lib/tiny-webhook.js +135 -0
  51. package/packages/apps/tiny-erp/lib/tiny-webhook.js.map +1 -0
  52. package/packages/apps/tiny-erp/package.json +13 -6
  53. package/packages/apps/tiny-erp/src/event-to-tiny.ts +129 -0
  54. package/packages/apps/tiny-erp/src/index.ts +1 -0
  55. package/packages/apps/tiny-erp/src/integration/after-tiny-queue.ts +80 -0
  56. package/packages/apps/tiny-erp/src/integration/export-order-to-tiny.ts +86 -0
  57. package/packages/apps/tiny-erp/src/integration/export-product-to-tiny.ts +60 -0
  58. package/packages/apps/tiny-erp/src/integration/helpers/format-tiny-date.ts +6 -0
  59. package/packages/apps/tiny-erp/src/integration/import-order-from-tiny.ts +104 -0
  60. package/packages/apps/tiny-erp/src/integration/import-product-from-tiny.ts +174 -0
  61. package/packages/apps/tiny-erp/src/integration/parsers/order-from-tiny.ts +49 -0
  62. package/packages/apps/tiny-erp/src/integration/parsers/order-to-tiny.ts +205 -0
  63. package/packages/apps/tiny-erp/src/integration/parsers/product-from-tiny.ts +215 -0
  64. package/packages/apps/tiny-erp/src/integration/parsers/product-to-tiny.ts +138 -0
  65. package/packages/apps/tiny-erp/src/integration/parsers/status-from-tiny.ts +35 -0
  66. package/packages/apps/tiny-erp/src/integration/parsers/status-to-tiny.ts +42 -0
  67. package/packages/apps/tiny-erp/src/integration/post-tiny-erp.ts +52 -0
  68. package/packages/apps/tiny-erp/src/tiny-erp.ts +23 -0
  69. package/packages/apps/tiny-erp/src/tiny-webhook.ts +143 -0
  70. package/packages/cli/package.json +1 -1
  71. package/packages/events/lib/firebase.js +2 -26
  72. package/packages/events/lib/firebase.js.map +1 -1
  73. package/packages/events/lib/index.js +1 -1
  74. package/packages/events/lib/index.js.map +1 -1
  75. package/packages/events/package.json +1 -1
  76. package/packages/events/src/firebase.ts +2 -28
  77. package/packages/events/src/index.ts +1 -1
  78. package/packages/firebase/lib/config.d.ts +2 -2
  79. package/packages/firebase/lib/config.js +7 -5
  80. package/packages/firebase/lib/config.js.map +1 -1
  81. package/packages/firebase/lib/const.d.ts +2 -0
  82. package/packages/firebase/lib/const.js +6 -0
  83. package/packages/firebase/lib/const.js.map +1 -0
  84. package/packages/firebase/lib/handlers/check-store-events.js +50 -27
  85. package/packages/firebase/lib/handlers/check-store-events.js.map +1 -1
  86. package/packages/firebase/lib/helpers/pubsub.d.ts +9 -0
  87. package/packages/firebase/lib/helpers/pubsub.js +32 -0
  88. package/packages/firebase/lib/helpers/pubsub.js.map +1 -0
  89. package/packages/firebase/lib/helpers/update-app-data.d.ts +9 -0
  90. package/packages/firebase/lib/helpers/update-app-data.js +45 -0
  91. package/packages/firebase/lib/helpers/update-app-data.js.map +1 -0
  92. package/packages/firebase/lib/index.d.ts +1 -2
  93. package/packages/firebase/lib/index.js +1 -6
  94. package/packages/firebase/lib/index.js.map +1 -1
  95. package/packages/firebase/lib/init.d.ts +2 -0
  96. package/packages/firebase/lib/init.js +9 -0
  97. package/packages/firebase/lib/init.js.map +1 -0
  98. package/packages/firebase/package.json +5 -2
  99. package/packages/firebase/src/config.ts +9 -6
  100. package/packages/firebase/src/const.ts +5 -0
  101. package/packages/firebase/src/handlers/check-store-events.ts +56 -33
  102. package/packages/firebase/src/helpers/pubsub.ts +52 -0
  103. package/packages/firebase/src/helpers/update-app-data.ts +49 -0
  104. package/packages/firebase/src/index.ts +1 -7
  105. package/packages/firebase/src/init.ts +9 -0
  106. package/packages/modules/lib/firebase/handle-module.js +4 -5
  107. package/packages/modules/lib/firebase/handle-module.js.map +1 -1
  108. package/packages/modules/lib/firebase/serve-modules-api.js +2 -2
  109. package/packages/modules/lib/firebase/serve-modules-api.js.map +1 -1
  110. package/packages/modules/lib/firebase.js +2 -7
  111. package/packages/modules/lib/firebase.js.map +1 -1
  112. package/packages/modules/package.json +1 -1
  113. package/packages/modules/src/firebase/handle-module.ts +2 -5
  114. package/packages/modules/src/firebase/serve-modules-api.ts +2 -6
  115. package/packages/modules/src/firebase.ts +2 -7
  116. package/packages/passport/lib/firebase/handle-passport.js +12 -10
  117. package/packages/passport/lib/firebase/handle-passport.js.map +1 -1
  118. package/packages/passport/lib/firebase/serve-passport-api.js +2 -2
  119. package/packages/passport/lib/firebase/serve-passport-api.js.map +1 -1
  120. package/packages/passport/lib/firebase.js +2 -7
  121. package/packages/passport/lib/firebase.js.map +1 -1
  122. package/packages/passport/package.json +1 -1
  123. package/packages/passport/src/firebase/handle-passport.ts +10 -19
  124. package/packages/passport/src/firebase/serve-passport-api.ts +0 -2
  125. package/packages/passport/src/firebase.ts +1 -7
  126. package/packages/ssr/lib/firebase.js +1 -4
  127. package/packages/ssr/lib/firebase.js.map +1 -1
  128. package/packages/ssr/package.json +1 -1
  129. package/packages/ssr/src/firebase.ts +1 -4
  130. package/packages/storefront/package.json +4 -4
  131. package/packages/types/index.ts +18 -3
  132. package/packages/types/package.json +1 -1
  133. package/packages/api/lib/index.d.ts +0 -9974
  134. package/packages/api/lib/index.js.map +0 -1
  135. package/packages/apps/tiny-erp/src/firebase.ts +0 -0
@@ -2,11 +2,7 @@ import type { Request, Response } from 'firebase-functions';
2
2
  import { schemas } from '../index';
3
3
  import handleModule from './handle-module';
4
4
 
5
- export default (
6
- req: Request,
7
- res: Response,
8
- apiAuth: { authenticationId: string, apiKey: string },
9
- ) => {
5
+ export default (req: Request, res: Response) => {
10
6
  const { method } = req;
11
7
  if (method !== 'POST' && method !== 'GET') {
12
8
  return res.sendStatus(405);
@@ -59,7 +55,7 @@ export default (
59
55
  return sendSchema(true);
60
56
  }
61
57
  if (url === `/${modName}`) {
62
- return handleModule(modName, schema, responseSchema, req, res, apiAuth);
58
+ return handleModule(modName, schema, responseSchema, req, res);
63
59
  }
64
60
  }
65
61
  return res.sendStatus(404);
@@ -1,18 +1,13 @@
1
1
  /* eslint-disable import/prefer-default-export */
2
2
 
3
- import 'source-map-support/register.js';
4
- // eslint-disable-next-line import/no-unresolved
5
- import { initializeApp } from 'firebase-admin/app';
3
+ import '@cloudcommerce/firebase/lib/init';
6
4
  // eslint-disable-next-line import/no-unresolved
7
5
  import { onRequest } from 'firebase-functions/v2/https';
8
6
  import config from '@cloudcommerce/firebase/lib/config';
9
- import getEnv from '@cloudcommerce/firebase/lib/env';
10
7
  import serveModulesApi from './firebase/serve-modules-api';
11
8
 
12
- initializeApp();
13
9
  const { httpsFunctionOptions } = config.get();
14
10
 
15
11
  export const modules = onRequest(httpsFunctionOptions, (req, res) => {
16
- const { apiAuth } = getEnv();
17
- serveModulesApi(req, res, apiAuth);
12
+ serveModulesApi(req, res);
18
13
  });
@@ -1,9 +1,10 @@
1
1
  import { logger } from 'firebase-functions';
2
2
  import api from '@cloudcommerce/api';
3
+ import getEnv from '@cloudcommerce/firebase/lib/env';
3
4
 
4
- const findCustomerByEmail = async (email, apiAuth) => {
5
+ const findCustomerByEmail = async (email) => {
5
6
  try {
6
- const { data } = await api.get(`customers?main_email=${email}`, apiAuth);
7
+ const { data } = await api.get(`customers?main_email=${email}`);
7
8
  if (data.result.length) {
8
9
  return data.result[0];
9
10
  }
@@ -25,16 +26,17 @@ const checkFirebaseAuth = async (auth, authToken) => {
25
26
  return null;
26
27
  }
27
28
  };
28
- const createCustomer = async (customer, apiAuth) => {
29
+ const createCustomer = async (customer) => {
29
30
  try {
30
- const { data } = await api.post('customers', customer, apiAuth);
31
+ const { data } = await api.post('customers', customer);
31
32
  return data._id;
32
33
  } catch (e) {
33
34
  logger.error(e);
34
35
  return null;
35
36
  }
36
37
  };
37
- const generateAccessToken = async (firestore, customerId, apiAuth) => {
38
+ const generateAccessToken = async (firestore, customerId) => {
39
+ const { apiAuth } = getEnv();
38
40
  const docRef = firestore.doc(`customerTokens/${customerId}`);
39
41
  const doc = await docRef.get();
40
42
  const expires = doc.data()?.expires;
@@ -63,12 +65,12 @@ const generateAccessToken = async (firestore, customerId, apiAuth) => {
63
65
  return null;
64
66
  }
65
67
  };
66
- const getAuthCustomerApi = async (firestore, apiAuth, authtoken, authFirebase) => {
68
+ const getAuthCustomerApi = async (firestore, authtoken, authFirebase) => {
67
69
  const customerFirebaseAuth = await checkFirebaseAuth(authFirebase, authtoken);
68
70
  if (customerFirebaseAuth !== null && customerFirebaseAuth.email) {
69
- const customer = await findCustomerByEmail(customerFirebaseAuth.email, apiAuth);
71
+ const customer = await findCustomerByEmail(customerFirebaseAuth.email);
70
72
  if (customer !== null) {
71
- return generateAccessToken(firestore, customer._id, apiAuth);
73
+ return generateAccessToken(firestore, customer._id);
72
74
  }
73
75
  const newCustomer = {
74
76
  display_name: customerFirebaseAuth.name || '',
@@ -82,9 +84,9 @@ const getAuthCustomerApi = async (firestore, apiAuth, authtoken, authFirebase) =
82
84
  user_id: customerFirebaseAuth.user_id,
83
85
  }],
84
86
  };
85
- const customerId = await createCustomer(newCustomer, apiAuth);
87
+ const customerId = await createCustomer(newCustomer);
86
88
  if (customerId) {
87
- return generateAccessToken(firestore, customerId, apiAuth);
89
+ return generateAccessToken(firestore, customerId);
88
90
  }
89
91
  }
90
92
  // TODO: Find customer by phone number, generate token if found, otherwise unauthorize
@@ -1 +1 @@
1
- {"version":3,"file":"handle-passport.js","sourceRoot":"","sources":["../../src/firebase/handle-passport.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,GAAG,MAAM,oBAAoB,CAAC;AAErC,MAAM,mBAAmB,GAAG,KAAK,EAC/B,KAAyB,EACzB,OAAqD,EACrD,EAAE;IACF,IAAI;QACF,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,GAAG,CAAC,GAAG,CAAC,wBAAwB,KAAK,EAAE,EAAE,OAAO,CAAC,CAAC;QACzE,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE;YACtB,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;SACvB;QACD,OAAO,IAAI,CAAC;KACb;IAAC,OAAO,CAAC,EAAE;QACV,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAChB,OAAO,IAAI,CAAC;KACb;AACH,CAAC,CAAC;AAEF,MAAM,iBAAiB,GAAG,KAAK,EAC7B,IAAU,EACV,SAAyC,EACzC,EAAE;IACF,IAAI,SAAS,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE;QAC1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AoB,CAAC,KAAK;YACtC,MAAM,EAAE,CAAC;oBACP,OAAO,EAAE,oBAAoB,CAAC,KAAK;oBACnC,QAAQ,EAAE,oBAAoB,CAAC,cAAc;iBAC9C,CAAC;YACF,eAAe,EAAE,CAAC;oBAChB,QAAQ,EAAE,oBAAoB,CAAC,QAAQ,CAAC,gBAAgB;oBACxD,OAAO,EAAE,oBAAoB,CAAC,OAAO;iBACtC,CAAC;SACU,CAAC;QACf,MAAM,UAAU,GAAG,MAAM,cAAc,CAAC,WAAW,CAAC,CAAC;QACrD,IAAI,UAAU,EAAE;YACd,OAAO,mBAAmB,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;SACnD;KACF;IACD,sFAAsF;IACtF,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAEF,MAAM,SAAS,GAAG,CAChB,GAAa,EACb,GAAY,EACZ,MAAM,GAAG,GAAG,EACZ,EAAE;IACF,IAAI,GAAG,EAAE;QACP,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC;YACtB,MAAM;YACN,KAAK,EAAE,GAAG;SACX,CAAC,CAAC;KACJ;SAAM;QACL,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;YACnB,MAAM,EAAE,GAAG;YACX,KAAK,EAAE,uBAAuB;SAC/B,CAAC,CAAC;KACJ;AACH,CAAC,CAAC;AAEF,OAAO,EACL,SAAS,EACT,kBAAkB,GACnB,CAAC"}
@@ -1,7 +1,7 @@
1
1
  import { logger } from 'firebase-functions';
2
2
  import { sendError, getAuthCustomerApi } from './handle-passport.js';
3
3
 
4
- export default async (req, res, apiAuth, firestore, authFirebase, storeId) => {
4
+ export default async (req, res, firestore, authFirebase, storeId) => {
5
5
  const { method } = req;
6
6
  if (method !== 'POST') {
7
7
  return res.sendStatus(405);
@@ -25,7 +25,7 @@ export default async (req, res, apiAuth, firestore, authFirebase, storeId) => {
25
25
  return sendError(res, 'Invalid store');
26
26
  }
27
27
  try {
28
- const authCustomerApi = await getAuthCustomerApi(firestore, apiAuth, authtoken, authFirebase);
28
+ const authCustomerApi = await getAuthCustomerApi(firestore, authtoken, authFirebase);
29
29
  if (authCustomerApi !== null) {
30
30
  return res.send(authCustomerApi);
31
31
  }
@@ -1 +1 @@
1
- {"version":3,"file":"serve-passport-api.js","sourceRoot":"","sources":["../../src/firebase/serve-passport-api.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EACL,SAAS,EACT,kBAAkB,GACnB,MAAM,mBAAmB,CAAC;AAE3B,eAAe,KAAK,EAClB,GAAY,EACZ,GAAa,EACb,OAAqD,EACrD,SAAoB,EACpB,YAAkB,EAClB,OAAe,EACf,EAAE;IACF,MAAM,EAAE,MAAM,EAAE,GAAG,GAAG,CAAC;IACvB,IAAI,MAAM,KAAK,MAAM,EAAE;QACrB,OAAO,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;KAC5B;IACD,IACE,MAAM,KAAK,MAAM;WACd,CAAC,CAAC,GAAG,CAAC,IAAI,IAAI,OAAO,GAAG,CAAC,IAAI,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,EACzE;QACA,OAAO,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;KAC5B;IAED,IAAI,EAAE,GAAG,EAAE,GAAG,GAAG,CAAC;IAClB,IAAI,GAAG,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE;QACzB,GAAG,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;KACxB;IACD,MAAM,QAAQ,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IACnC,kBAAkB;IAClB,IAAI,QAAQ,KAAK,OAAO,IAAI,MAAM,KAAK,MAAM,EAAE;QAC7C,MAAM,EAAE,SAAS,EAAE,GAAG,GAAG,CAAC,IAAI,CAAC;QAC/B,IAAI,CAAC,SAAS,EAAE;YACd,OAAO,SAAS,CAAC,GAAG,EAAE,qBAAqB,EAAE,GAAG,CAAC,CAAC;SACnD;QAAC,IAAI,OAAO,GAAG,GAAG,EAAE;YACnB,OAAO,SAAS,CAAC,GAAG,EAAE,eAAe,CAAC,CAAC;SACxC;QACD,IAAI;YACF,MAAM,eAAe,GAAG,MAAM,kBAAkB,CAC9C,SAAS,EACT,OAAO,EACP,SAAS,EACT,YAAY,CACb,CAAC;YACF,IAAI,eAAe,KAAK,IAAI,EAAE;gBAC5B,OAAO,GAAG,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;aAClC;YACD,OAAO,SAAS,CAAC,GAAG,EAAE,6BAA6B,EAAE,GAAG,CAAC,CAAC;SAC3D;QAAC,OAAO,CAAC,EAAE;YACV,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YAChB,OAAO,SAAS,CAAC,GAAG,CAAC,CAAC;SACvB;KACF;SAAM;QACL,OAAO,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;KAC5B;AACH,CAAC,CAAC"}
1
+ {"version":3,"file":"serve-passport-api.js","sourceRoot":"","sources":["../../src/firebase/serve-passport-api.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EACL,SAAS,EACT,kBAAkB,GACnB,MAAM,mBAAmB,CAAC;AAE3B,eAAe,KAAK,EAClB,GAAY,EACZ,GAAa,EACb,SAAoB,EACpB,YAAkB,EAClB,OAAe,EACf,EAAE;IACF,MAAM,EAAE,MAAM,EAAE,GAAG,GAAG,CAAC;IACvB,IAAI,MAAM,KAAK,MAAM,EAAE;QACrB,OAAO,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;KAC5B;IACD,IACE,MAAM,KAAK,MAAM;WACd,CAAC,CAAC,GAAG,CAAC,IAAI,IAAI,OAAO,GAAG,CAA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@@ -1,6 +1,4 @@
1
- import 'source-map-support/register.js';
2
- // eslint-disable-next-line import/no-unresolved
3
- import { initializeApp } from 'firebase-admin/app';
1
+ import '@cloudcommerce/firebase/lib/init';
4
2
  // eslint-disable-next-line import/no-unresolved
5
3
  import { getFirestore } from 'firebase-admin/firestore';
6
4
  // eslint-disable-next-line import/no-unresolved
@@ -8,7 +6,6 @@ import { getAuth } from 'firebase-admin/auth';
8
6
  // eslint-disable-next-line import/no-unresolved
9
7
  import { onRequest } from 'firebase-functions/v2/https';
10
8
  import config from '@cloudcommerce/firebase/lib/config';
11
- import getEnv from '@cloudcommerce/firebase/lib/env';
12
9
  import servePassportApi from './firebase/serve-passport-api.js';
13
10
 
14
11
  // References:
@@ -16,7 +13,6 @@ import servePassportApi from './firebase/serve-passport-api.js';
16
13
  // https://itnext.io/how-to-use-firebase-auth-with-a-custom-node-backend-99a106376c8a
17
14
  // https://www.geeksforgeeks.org/firebase-sign-in-with-google-authentication-in-node-js-using-firebase-ui-and-cookie-sessions/
18
15
  // https://firebase.google.com/docs/reference/rest/auth
19
- initializeApp();
20
16
  const authFirebase = getAuth();
21
17
  const firestore = getFirestore();
22
18
  const options = {
@@ -26,8 +22,7 @@ const options = {
26
22
 
27
23
  // eslint-disable-next-line import/prefer-default-export
28
24
  export const passport = onRequest(options, (req, res) => {
29
- const { apiAuth } = getEnv();
30
25
  const { storeId } = config.get();
31
- servePassportApi(req, res, apiAuth, firestore, authFirebase, storeId);
26
+ servePassportApi(req, res, firestore, authFirebase, storeId);
32
27
  });
33
28
  // # sourceMappingURL=firebase.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"firebase.js","sourceRoot":"","sources":["../src/firebase.ts"],"names":[],"mappings":"AAAA,OAAO,gCAAgC,CAAC;AACxC,gDAAgD;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,gDAAgD;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,gDAAgD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MAAM,+BAA+B,CAAC;AAE7D,cAAc;AACd,8DAA8D;AAC9D,qFAAqF;AACrF,8HAA8H;AAC9H,uDAAuD;AAEvD,MAAM,YAAY,GAAG,OAAO,EAAE,CAAC;AAC/B,MAAM,SAAS,GAAG,YAAY,EAAE,CAAC;AAEjC,MAAM,OAAO,GAAG;IACd,GAAG,MAAM,CAAC,GAAG,EAAE,CAAC,oBAAoB;IACpC,MAAM,EAAE,QAAQ;CACD,CAAC;AAElB,wDAAwD;AACxD,MAAM,CAAC,MAAM,QAAQ,GAAG,SAAS,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;IACtD,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,CAAC,GAAG,EAAE,CAAC;IACjC,gBAAgB,CACd,GAAG,EACH,GAAG,EACH,SAAS,EACT,YAAY,EACZ,OAAO,CACR,CAAC;AACJ,CAAC,CAAC,CAAC"}
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudcommerce/passport",
3
3
  "type": "module",
4
- "version": "0.0.59",
4
+ "version": "0.0.60",
5
5
  "description": "E-Com Plus Cloud Commerce customers authentication (passport) API",
6
6
  "main": "lib/index.js",
7
7
  "exports": {
@@ -5,13 +5,11 @@ import type { Firestore } from 'firebase-admin/firestore';
5
5
  import { Auth } from 'firebase-admin/auth';
6
6
  import { logger } from 'firebase-functions';
7
7
  import api from '@cloudcommerce/api';
8
+ import getEnv from '@cloudcommerce/firebase/lib/env';
8
9
 
9
- const findCustomerByEmail = async (
10
- email: string | undefined,
11
- apiAuth: { authenticationId: string, apiKey: string },
12
- ) => {
10
+ const findCustomerByEmail = async (email: string | undefined) => {
13
11
  try {
14
- const { data } = await api.get(`customers?main_email=${email}`, apiAuth);
12
+ const { data } = await api.get(`customers?main_email=${email}`);
15
13
  if (data.result.length) {
16
14
  return data.result[0];
17
15
  }
@@ -38,12 +36,9 @@ const checkFirebaseAuth = async (
38
36
  }
39
37
  };
40
38
 
41
- const createCustomer = async (
42
- customer: Customers,
43
- apiAuth: { authenticationId: string, apiKey: string },
44
- ) => {
39
+ const createCustomer = async (customer: Customers) => {
45
40
  try {
46
- const { data } = await api.post('customers', customer, apiAuth);
41
+ const { data } = await api.post('customers', customer);
47
42
  return data._id;
48
43
  } catch (e) {
49
44
  logger.error(e);
@@ -54,12 +49,12 @@ const createCustomer = async (
54
49
  const generateAccessToken = async (
55
50
  firestore: Firestore,
56
51
  customerId: string,
57
- apiAuth: { authenticationId: string, apiKey: string },
58
52
  ): Promise<null | {
59
53
  customer_id: string,
60
54
  access_token: string,
61
55
  expires: string,
62
56
  }> => {
57
+ const { apiAuth } = getEnv();
63
58
  const docRef = firestore.doc(`customerTokens/${customerId}`);
64
59
  const doc = await docRef.get();
65
60
  const expires: string | undefined = doc.data()?.expires;
@@ -91,18 +86,14 @@ const generateAccessToken = async (
91
86
 
92
87
  const getAuthCustomerApi = async (
93
88
  firestore: Firestore,
94
- apiAuth: { authenticationId: string, apiKey: string },
95
89
  authtoken: string | string[] | undefined,
96
90
  authFirebase: Auth,
97
91
  ) => {
98
92
  const customerFirebaseAuth = await checkFirebaseAuth(authFirebase, authtoken);
99
93
  if (customerFirebaseAuth !== null && customerFirebaseAuth.email) {
100
- const customer = await findCustomerByEmail(
101
- customerFirebaseAuth.email,
102
- apiAuth,
103
- );
94
+ const customer = await findCustomerByEmail(customerFirebaseAuth.email);
104
95
  if (customer !== null) {
105
- return generateAccessToken(firestore, customer._id, apiAuth);
96
+ return generateAccessToken(firestore, customer._id);
106
97
  }
107
98
  const newCustomer = {
108
99
  display_name: customerFirebaseAuth.name || '',
@@ -116,9 +107,9 @@ const getAuthCustomerApi = async (
116
107
  user_id: customerFirebaseAuth.user_id,
117
108
  }],
118
109
  } as Customers;
119
- const customerId = await createCustomer(newCustomer, apiAuth);
110
+ const customerId = await createCustomer(newCustomer);
120
111
  if (customerId) {
121
- return generateAccessToken(firestore, customerId, apiAuth);
112
+ return generateAccessToken(firestore, customerId);
122
113
  }
123
114
  }
124
115
  // TODO: Find customer by phone number, generate token if found, otherwise unauthorize
@@ -12,7 +12,6 @@ import {
12
12
  export default async (
13
13
  req: Request,
14
14
  res: Response,
15
- apiAuth: { authenticationId: string, apiKey: string },
16
15
  firestore: Firestore,
17
16
  authFirebase: Auth,
18
17
  storeId: number,
@@ -44,7 +43,6 @@ export default async (
44
43
  try {
45
44
  const authCustomerApi = await getAuthCustomerApi(
46
45
  firestore,
47
- apiAuth,
48
46
  authtoken,
49
47
  authFirebase,
50
48
  );
@@ -1,6 +1,4 @@
1
- import 'source-map-support/register.js';
2
- // eslint-disable-next-line import/no-unresolved
3
- import { initializeApp } from 'firebase-admin/app';
1
+ import '@cloudcommerce/firebase/lib/init';
4
2
  // eslint-disable-next-line import/no-unresolved
5
3
  import { getFirestore } from 'firebase-admin/firestore';
6
4
  // eslint-disable-next-line import/no-unresolved
@@ -8,7 +6,6 @@ import { getAuth } from 'firebase-admin/auth';
8
6
  // eslint-disable-next-line import/no-unresolved
9
7
  import { HttpsOptions, onRequest } from 'firebase-functions/v2/https';
10
8
  import config from '@cloudcommerce/firebase/lib/config';
11
- import getEnv from '@cloudcommerce/firebase/lib/env';
12
9
  import servePassportApi from './firebase/serve-passport-api';
13
10
 
14
11
  // References:
@@ -17,7 +14,6 @@ import servePassportApi from './firebase/serve-passport-api';
17
14
  // https://www.geeksforgeeks.org/firebase-sign-in-with-google-authentication-in-node-js-using-firebase-ui-and-cookie-sessions/
18
15
  // https://firebase.google.com/docs/reference/rest/auth
19
16
 
20
- initializeApp();
21
17
  const authFirebase = getAuth();
22
18
  const firestore = getFirestore();
23
19
 
@@ -28,12 +24,10 @@ const options = {
28
24
 
29
25
  // eslint-disable-next-line import/prefer-default-export
30
26
  export const passport = onRequest(options, (req, res) => {
31
- const { apiAuth } = getEnv();
32
27
  const { storeId } = config.get();
33
28
  servePassportApi(
34
29
  req,
35
30
  res,
36
- apiAuth,
37
31
  firestore,
38
32
  authFirebase,
39
33
  storeId,
@@ -1,12 +1,9 @@
1
1
  /* eslint-disable import/prefer-default-export */
2
- import 'source-map-support/register.js';
3
- // eslint-disable-next-line import/no-unresolved
4
- import { initializeApp } from 'firebase-admin/app';
2
+ import '@cloudcommerce/firebase/lib/init';
5
3
  // eslint-disable-next-line import/no-unresolved
6
4
  import { onRequest } from 'firebase-functions/v2/https';
7
5
  import config from '@cloudcommerce/firebase/lib/config';
8
6
 
9
- initializeApp();
10
7
  const options = config.get().httpsFunctionOptions;
11
8
 
12
9
  export const ssr = onRequest(options, (request, response) => {
@@ -1 +1 @@
1
- {"version":3,"file":"firebase.js","sourceRoot":"","sources":["../src/firebase.ts"],"names":[],"mappings":"AAAA,iDAAiD;AAEjD,OAAO,gCAAgC,CAAC;AACxC,gDAAgD;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,gDAAgD;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AACxD,OAAO,MAAM,MAAM,oCAAoC,CAAC;AAExD,aAAa,EAAE,CAAC;AAChB,MAAM,OAAO,GAAG,MAAM,CAAC,GAAG,EAAE,CAAC,oBAAoB,CAAC;AAElD,MAAM,CAAC,MAAM,GAAG,GAAG,SAAS,CAAC,OAAO,EAAE,CAAC,OAAO,EAAE,QAAQ,EAAE,EAAE;IAC1D,QAAQ,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;AACvC,CAAC,CAAC,CAAC"}
1
+ {"version":3,"file":"firebase.js","sourceRoot":"","sources":["../src/firebase.ts"],"names":[],"mappings":"AAAA,iDAAiD;AAEjD,OAAO,kCAAkC,CAAC;AAC1C,gDAAgD;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AACxD,OAAO,MAAM,MAAM,oCAAoC,CAAC;AAExD,MAAM,OAAO,GAAG,MAAM,CAAC,GAAG,EAAE,CAAC,oBAAoB,CAAC;AAElD,MAAM,CAAC,MAAM,GAAG,GAAG,SAAS,CAAC,OAAO,EAAE,CAAC,OAAO,EAAE,QAAQ,EAAE,EAAE;IAC1D,QAAQ,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;AACvC,CAAC,CAAC,CAAC"}
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudcommerce/ssr",
3
3
  "type": "module",
4
- "version": "0.0.59",
4
+ "version": "0.0.60",
5
5
  "description": "E-Com Plus Cloud Commerce storefront SSR",
6
6
  "main": "lib/index.js",
7
7
  "exports": {
@@ -1,13 +1,10 @@
1
1
  /* eslint-disable import/prefer-default-export */
2
2
 
3
- import 'source-map-support/register.js';
4
- // eslint-disable-next-line import/no-unresolved
5
- import { initializeApp } from 'firebase-admin/app';
3
+ import '@cloudcommerce/firebase/lib/init';
6
4
  // eslint-disable-next-line import/no-unresolved
7
5
  import { onRequest } from 'firebase-functions/v2/https';
8
6
  import config from '@cloudcommerce/firebase/lib/config';
9
7
 
10
- initializeApp();
11
8
  const options = config.get().httpsFunctionOptions;
12
9
 
13
10
  export const ssr = onRequest(options, (request, response) => {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudcommerce/storefront",
3
3
  "type": "module",
4
- "version": "0.0.59",
4
+ "version": "0.0.60",
5
5
  "description": "E-Com Plus Cloud Commerce storefront with Astro",
6
6
  "main": "src/index.js",
7
7
  "repository": {
@@ -19,7 +19,7 @@
19
19
  "build": "echo '@ecomplus/storefront'"
20
20
  },
21
21
  "dependencies": {
22
- "@astrojs/mdx": "^0.10.0",
22
+ "@astrojs/mdx": "^0.10.2",
23
23
  "@astrojs/node": "^1.0.0",
24
24
  "@astrojs/partytown": "^1.0.0",
25
25
  "@astrojs/prefetch": "^0.0.7",
@@ -27,9 +27,9 @@
27
27
  "@astrojs/vue": "^1.0.0",
28
28
  "@cloudcommerce/api": "workspace:*",
29
29
  "@picocss/pico": "^1.5.3",
30
- "astro": "^1.0.6",
30
+ "astro": "^1.1.1",
31
31
  "rollup": "^2.78.1",
32
- "unocss": "^0.45.12",
32
+ "unocss": "^0.45.13",
33
33
  "vite": "^3.0.9",
34
34
  "vue": "^3.2.37"
35
35
  }
@@ -25,7 +25,7 @@ import type { CreateTransactionParams } from './modules/create_transaction:param
25
25
  import type { CreateTransactionResponse } from './modules/create_transaction:response';
26
26
  import type { CheckoutBody } from './modules/@checkout:params';
27
27
 
28
- type AppEventsTopic = 'orders-new'
28
+ type ApiEventName = 'orders-new'
29
29
  | 'orders-anyStatusSet'
30
30
  | 'orders-paid'
31
31
  | 'orders-readyForShipping'
@@ -37,7 +37,21 @@ type AppEventsTopic = 'orders-new'
37
37
  | 'products-priceSet'
38
38
  | 'carts-new'
39
39
  | 'carts-customerSet'
40
- | 'customers-new';
40
+ | 'customers-new'
41
+ | 'applications-dataSet';
42
+
43
+ type AppEventsPayload = {
44
+ evName: ApiEventName,
45
+ apiEvent: EventsResult<'events/orders'>['result'][0],
46
+ apiDoc: Record<string, any>,
47
+ app: {
48
+ _id: Applications['_id'],
49
+ app_id: Applications['app_id'],
50
+ data: Applications['data'],
51
+ hidden_data: Applications['hidden_data'],
52
+ },
53
+ isInternal?: boolean,
54
+ };
41
55
 
42
56
  type AppModuleName = 'apply_discount'
43
57
  | 'calculate_shipping'
@@ -69,7 +83,8 @@ export type {
69
83
  ResourceId,
70
84
  ResourceListResult,
71
85
  EventsResult,
72
- AppEventsTopic,
86
+ ApiEventName,
87
+ AppEventsPayload,
73
88
  AppModuleName,
74
89
  AppModuleBody,
75
90
  ApplyDiscountParams,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudcommerce/types",
3
3
  "type": "module",
4
- "version": "0.0.59",
4
+ "version": "0.0.60",
5
5
  "description": "E-Com Plus Cloud Commerce reusable type definitions",
6
6
  "main": "index.ts",
7
7
  "repository": {