@loomcore/api 0.2.42 → 0.2.45

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 (245) hide show
  1. package/LICENSE +201 -201
  2. package/dist/__tests__/common-test.utils.d.ts +13 -13
  3. package/dist/__tests__/common-test.utils.js +72 -72
  4. package/dist/__tests__/models/category.model.d.ts +1 -1
  5. package/dist/__tests__/models/category.model.js +2 -2
  6. package/dist/__tests__/models/product-with-category.model.d.ts +3 -3
  7. package/dist/__tests__/models/product-with-category.model.js +4 -4
  8. package/dist/__tests__/models/product.model.d.ts +2 -2
  9. package/dist/__tests__/models/product.model.js +2 -2
  10. package/dist/__tests__/models/test-entity.model.d.ts +2 -2
  11. package/dist/__tests__/models/test-entity.model.js +2 -2
  12. package/dist/__tests__/models/test-item.model.d.ts +1 -1
  13. package/dist/__tests__/models/test-item.model.js +3 -3
  14. package/dist/__tests__/mongo-db.test-database.js +1 -1
  15. package/dist/__tests__/postgres-test-migrations/postgres-test-schema.d.ts +2 -2
  16. package/dist/__tests__/postgres-test-migrations/postgres-test-schema.js +38 -38
  17. package/dist/__tests__/postgres.test-database.d.ts +2 -2
  18. package/dist/__tests__/postgres.test-database.js +25 -25
  19. package/dist/__tests__/test-database.interface.d.ts +1 -1
  20. package/dist/__tests__/test-email-client.d.ts +1 -1
  21. package/dist/__tests__/test-express-app.d.ts +3 -3
  22. package/dist/__tests__/test-express-app.js +12 -12
  23. package/dist/__tests__/test-objects.d.ts +1 -1
  24. package/dist/__tests__/test-objects.js +26 -26
  25. package/dist/config/base-api-config.d.ts +2 -2
  26. package/dist/config/base-api-config.js +17 -17
  27. package/dist/controllers/auth.controller.d.ts +4 -4
  28. package/dist/controllers/auth.controller.js +32 -32
  29. package/dist/controllers/authorizations.controller.d.ts +4 -4
  30. package/dist/controllers/authorizations.controller.js +4 -4
  31. package/dist/controllers/features.controller.d.ts +4 -4
  32. package/dist/controllers/features.controller.js +4 -4
  33. package/dist/controllers/index.d.ts +10 -10
  34. package/dist/controllers/index.js +10 -10
  35. package/dist/controllers/organizations.controller.d.ts +5 -5
  36. package/dist/controllers/organizations.controller.js +10 -10
  37. package/dist/controllers/roles.controller.d.ts +4 -4
  38. package/dist/controllers/roles.controller.js +4 -4
  39. package/dist/controllers/types.d.ts +2 -2
  40. package/dist/controllers/user-roles.controller.d.ts +4 -4
  41. package/dist/controllers/user-roles.controller.js +4 -4
  42. package/dist/controllers/users.controller.d.ts +5 -5
  43. package/dist/controllers/users.controller.js +4 -4
  44. package/dist/databases/models/database.interface.d.ts +5 -5
  45. package/dist/databases/mongo-db/commands/mongo-batch-update.command.d.ts +3 -3
  46. package/dist/databases/mongo-db/commands/mongo-batch-update.command.js +5 -5
  47. package/dist/databases/mongo-db/commands/mongo-create-many.command.d.ts +1 -1
  48. package/dist/databases/mongo-db/commands/mongo-create-many.command.js +1 -1
  49. package/dist/databases/mongo-db/commands/mongo-create.command.d.ts +1 -1
  50. package/dist/databases/mongo-db/commands/mongo-create.command.js +1 -1
  51. package/dist/databases/mongo-db/commands/mongo-delete-by-id.command.d.ts +3 -3
  52. package/dist/databases/mongo-db/commands/mongo-delete-by-id.command.js +4 -4
  53. package/dist/databases/mongo-db/commands/mongo-delete-many.command.d.ts +3 -3
  54. package/dist/databases/mongo-db/commands/mongo-delete-many.command.js +2 -2
  55. package/dist/databases/mongo-db/commands/mongo-full-updateby-id.command.d.ts +3 -3
  56. package/dist/databases/mongo-db/commands/mongo-full-updateby-id.command.js +4 -4
  57. package/dist/databases/mongo-db/commands/mongo-partial-update-by-id.command.d.ts +3 -3
  58. package/dist/databases/mongo-db/commands/mongo-partial-update-by-id.command.js +4 -4
  59. package/dist/databases/mongo-db/commands/mongo-update.command.d.ts +3 -3
  60. package/dist/databases/mongo-db/commands/mongo-update.command.js +3 -3
  61. package/dist/databases/mongo-db/migrations/mongo-initial-schema.d.ts +2 -2
  62. package/dist/databases/mongo-db/migrations/mongo-initial-schema.js +108 -108
  63. package/dist/databases/mongo-db/models/no-sql-pipeline.d.ts +4 -4
  64. package/dist/databases/mongo-db/models/no-sql-pipeline.interface.d.ts +3 -3
  65. package/dist/databases/mongo-db/models/no-sql-pipeline.js +1 -1
  66. package/dist/databases/mongo-db/mongo-db.database.d.ts +7 -7
  67. package/dist/databases/mongo-db/mongo-db.database.js +5 -5
  68. package/dist/databases/mongo-db/queries/mongo-find-one.query.d.ts +2 -2
  69. package/dist/databases/mongo-db/queries/mongo-find-one.query.js +1 -1
  70. package/dist/databases/mongo-db/queries/mongo-find.query.d.ts +2 -2
  71. package/dist/databases/mongo-db/queries/mongo-find.query.js +1 -1
  72. package/dist/databases/mongo-db/queries/mongo-get-all.query.d.ts +2 -2
  73. package/dist/databases/mongo-db/queries/mongo-get-all.query.js +1 -1
  74. package/dist/databases/mongo-db/queries/mongo-get-by-id.query.d.ts +4 -4
  75. package/dist/databases/mongo-db/queries/mongo-get-by-id.query.js +3 -3
  76. package/dist/databases/mongo-db/queries/mongo-get-count.query.d.ts +1 -1
  77. package/dist/databases/mongo-db/queries/mongo-get.query.d.ts +3 -3
  78. package/dist/databases/mongo-db/queries/mongo-get.query.js +2 -2
  79. package/dist/databases/mongo-db/utils/build-find-options.util.d.ts +2 -2
  80. package/dist/databases/mongo-db/utils/build-mongo-url.util.d.ts +1 -1
  81. package/dist/databases/mongo-db/utils/build-mongo-url.util.js +4 -4
  82. package/dist/databases/operations/__tests__/models/test-agent.model.d.ts +2 -2
  83. package/dist/databases/operations/__tests__/models/test-agent.model.js +3 -3
  84. package/dist/databases/operations/__tests__/models/test-client-report.model.d.ts +4 -4
  85. package/dist/databases/operations/__tests__/models/test-client-report.model.js +5 -5
  86. package/dist/databases/operations/__tests__/models/test-district.model.d.ts +2 -2
  87. package/dist/databases/operations/__tests__/models/test-district.model.js +2 -2
  88. package/dist/databases/operations/__tests__/models/test-email-address.model.d.ts +1 -1
  89. package/dist/databases/operations/__tests__/models/test-email-address.model.js +2 -2
  90. package/dist/databases/operations/__tests__/models/test-person.model.d.ts +4 -4
  91. package/dist/databases/operations/__tests__/models/test-person.model.js +4 -4
  92. package/dist/databases/operations/__tests__/models/test-phone-number.model.d.ts +1 -1
  93. package/dist/databases/operations/__tests__/models/test-phone-number.model.js +2 -2
  94. package/dist/databases/operations/__tests__/models/test-policy.model.d.ts +3 -3
  95. package/dist/databases/operations/__tests__/models/test-policy.model.js +4 -4
  96. package/dist/databases/operations/__tests__/models/test-premium.model.d.ts +1 -1
  97. package/dist/databases/operations/__tests__/models/test-premium.model.js +2 -2
  98. package/dist/databases/operations/__tests__/models/test-school.model.d.ts +2 -2
  99. package/dist/databases/operations/__tests__/models/test-school.model.js +2 -2
  100. package/dist/databases/operations/__tests__/models/test-state.model.d.ts +1 -1
  101. package/dist/databases/operations/__tests__/models/test-state.model.js +2 -2
  102. package/dist/databases/operations/operation.d.ts +3 -3
  103. package/dist/databases/postgres/commands/postgres-batch-update.command.d.ts +1 -1
  104. package/dist/databases/postgres/commands/postgres-batch-update.command.js +11 -11
  105. package/dist/databases/postgres/commands/postgres-create-many.command.js +5 -5
  106. package/dist/databases/postgres/commands/postgres-create.command.d.ts +3 -3
  107. package/dist/databases/postgres/commands/postgres-create.command.js +5 -5
  108. package/dist/databases/postgres/commands/postgres-delete-by-id.command.d.ts +1 -1
  109. package/dist/databases/postgres/commands/postgres-delete-by-id.command.js +1 -1
  110. package/dist/databases/postgres/commands/postgres-delete-many.command.d.ts +2 -2
  111. package/dist/databases/postgres/commands/postgres-delete-many.command.js +1 -1
  112. package/dist/databases/postgres/commands/postgres-full-update-by-id.command.d.ts +1 -1
  113. package/dist/databases/postgres/commands/postgres-full-update-by-id.command.js +4 -4
  114. package/dist/databases/postgres/commands/postgres-partial-update-by-id.command.d.ts +1 -1
  115. package/dist/databases/postgres/commands/postgres-partial-update-by-id.command.js +11 -11
  116. package/dist/databases/postgres/commands/postgres-update.command.d.ts +2 -2
  117. package/dist/databases/postgres/commands/postgres-update.command.js +11 -11
  118. package/dist/databases/postgres/migrations/postgres-initial-schema.d.ts +2 -2
  119. package/dist/databases/postgres/migrations/postgres-initial-schema.js +69 -69
  120. package/dist/databases/postgres/postgres.database.d.ts +6 -6
  121. package/dist/databases/postgres/postgres.database.js +18 -18
  122. package/dist/databases/postgres/queries/postgres-find-one.query.d.ts +1 -1
  123. package/dist/databases/postgres/queries/postgres-find-one.query.js +2 -2
  124. package/dist/databases/postgres/queries/postgres-find.query.d.ts +1 -1
  125. package/dist/databases/postgres/queries/postgres-find.query.js +2 -2
  126. package/dist/databases/postgres/queries/postgres-get-all.query.d.ts +1 -1
  127. package/dist/databases/postgres/queries/postgres-get-all.query.js +3 -3
  128. package/dist/databases/postgres/queries/postgres-get-by-id.query.d.ts +1 -1
  129. package/dist/databases/postgres/queries/postgres-get-by-id.query.js +5 -5
  130. package/dist/databases/postgres/queries/postgres-get-count.query.js +1 -1
  131. package/dist/databases/postgres/queries/postgres-get.query.d.ts +2 -2
  132. package/dist/databases/postgres/queries/postgres-get.query.js +9 -9
  133. package/dist/databases/postgres/utils/build-count-query.d.ts +1 -1
  134. package/dist/databases/postgres/utils/build-count-query.js +1 -1
  135. package/dist/databases/postgres/utils/build-join-clauses.d.ts +1 -1
  136. package/dist/databases/postgres/utils/build-join-clauses.js +7 -7
  137. package/dist/databases/postgres/utils/build-order-by-clause.d.ts +1 -1
  138. package/dist/databases/postgres/utils/build-pagination-clause.d.ts +1 -1
  139. package/dist/databases/postgres/utils/build-postgres-url.util.d.ts +1 -1
  140. package/dist/databases/postgres/utils/build-postgres-url.util.js +2 -2
  141. package/dist/databases/postgres/utils/build-select-clause.js +9 -9
  142. package/dist/databases/postgres/utils/build-where-clause.d.ts +1 -1
  143. package/dist/databases/postgres/utils/build-where-clause.js +1 -1
  144. package/dist/databases/postgres/utils/columns-and-values-from-entity.d.ts +1 -1
  145. package/dist/databases/postgres/utils/does-table-exist.util.d.ts +1 -1
  146. package/dist/databases/postgres/utils/does-table-exist.util.js +5 -5
  147. package/dist/decorators/index.d.ts +1 -0
  148. package/dist/decorators/index.js +1 -0
  149. package/dist/middleware/authorize/authenticate-request.d.ts +2 -2
  150. package/dist/middleware/authorize/authenticate-request.js +5 -5
  151. package/dist/middleware/index.d.ts +4 -4
  152. package/dist/middleware/index.js +4 -4
  153. package/dist/models/app-config.interface.d.ts +1 -1
  154. package/dist/models/base-api-config.interface.d.ts +6 -6
  155. package/dist/models/initial-database-config.interface.d.ts +3 -3
  156. package/dist/models/log-level.type.d.ts +1 -1
  157. package/dist/services/authorizations.service.d.ts +3 -3
  158. package/dist/services/authorizations.service.js +7 -7
  159. package/dist/services/email.service.js +5 -5
  160. package/dist/services/features.service.d.ts +3 -3
  161. package/dist/services/features.service.js +4 -4
  162. package/dist/services/generic-api-service/generic-api-service.interface.d.ts +6 -6
  163. package/dist/services/generic-api-service/generic-api.service.d.ts +8 -8
  164. package/dist/services/generic-api-service/generic-api.service.js +7 -7
  165. package/dist/services/index.d.ts +16 -16
  166. package/dist/services/index.js +16 -16
  167. package/dist/services/multi-tenant-api.service.d.ts +4 -4
  168. package/dist/services/multi-tenant-api.service.js +9 -9
  169. package/dist/services/organization-domain.service.d.ts +3 -3
  170. package/dist/services/organization-domain.service.js +3 -3
  171. package/dist/services/organization.service.d.ts +4 -4
  172. package/dist/services/organization.service.js +7 -7
  173. package/dist/services/password-reset-token.service.d.ts +3 -3
  174. package/dist/services/password-reset-token.service.js +5 -5
  175. package/dist/services/refresh-token.service.d.ts +3 -3
  176. package/dist/services/refresh-token.service.js +3 -3
  177. package/dist/services/roles.service.d.ts +3 -3
  178. package/dist/services/roles.service.js +4 -4
  179. package/dist/services/tenant-query-decorator.d.ts +1 -1
  180. package/dist/services/tenant-query-decorator.js +8 -8
  181. package/dist/services/user-roles.service.d.ts +3 -3
  182. package/dist/services/user-roles.service.js +4 -4
  183. package/dist/services/user.service.d.ts +4 -4
  184. package/dist/services/user.service.js +11 -11
  185. package/dist/services/utils/audit-for-create.util.d.ts +1 -1
  186. package/dist/services/utils/audit-for-create.util.js +2 -2
  187. package/dist/services/utils/audit-for-update.util.d.ts +1 -1
  188. package/dist/services/utils/audit-for-update.util.js +2 -2
  189. package/dist/services/utils/strip-sender-provided-system-properties.util.d.ts +1 -1
  190. package/dist/services/utils/strip-sender-provided-system-properties.util.js +4 -4
  191. package/dist/utils/auth/assert-admin-or-feature.util.d.ts +1 -1
  192. package/dist/utils/auth/assert-admin-or-feature.util.js +2 -2
  193. package/dist/utils/auth/assert-admin.util.d.ts +1 -1
  194. package/dist/utils/auth/assert-admin.util.js +2 -2
  195. package/dist/utils/auth/assert-owner-or-admin.util.d.ts +1 -1
  196. package/dist/utils/auth/assert-owner-or-admin.util.js +2 -2
  197. package/dist/utils/auth/assert-user-has-feature.util.d.ts +1 -1
  198. package/dist/utils/auth/assert-user-has-feature.util.js +1 -1
  199. package/dist/utils/auth/assert-user-or-admin.util.d.ts +2 -2
  200. package/dist/utils/auth/assert-user-or-admin.util.js +2 -2
  201. package/dist/utils/auth/attempt-login.util.d.ts +4 -4
  202. package/dist/utils/auth/attempt-login.util.js +8 -8
  203. package/dist/utils/auth/auth-user-specs.util.d.ts +1 -1
  204. package/dist/utils/auth/auth-user-specs.util.js +3 -3
  205. package/dist/utils/auth/change-password.util.d.ts +4 -4
  206. package/dist/utils/auth/change-password.util.js +2 -2
  207. package/dist/utils/auth/create-new-refresh-token.util.d.ts +3 -3
  208. package/dist/utils/auth/create-new-refresh-token.util.js +8 -8
  209. package/dist/utils/auth/create-new-tokens.util.d.ts +1 -1
  210. package/dist/utils/auth/create-new-tokens.util.js +3 -3
  211. package/dist/utils/auth/generate-device-id.util.js +2 -2
  212. package/dist/utils/auth/generate-refresh-token.util.js +2 -2
  213. package/dist/utils/auth/get-active-refresh-token.util.d.ts +2 -2
  214. package/dist/utils/auth/get-active-refresh-token.util.js +1 -1
  215. package/dist/utils/auth/get-and-set-device-id-cookie.util.d.ts +1 -1
  216. package/dist/utils/auth/get-and-set-device-id-cookie.util.js +4 -4
  217. package/dist/utils/auth/get-auth-config.util.d.ts +1 -1
  218. package/dist/utils/auth/get-auth-config.util.js +3 -3
  219. package/dist/utils/auth/get-device-id-from-cookie.util.d.ts +1 -1
  220. package/dist/utils/auth/index.d.ts +26 -26
  221. package/dist/utils/auth/index.js +26 -26
  222. package/dist/utils/auth/is-admin.util.d.ts +1 -1
  223. package/dist/utils/auth/is-admin.util.js +1 -1
  224. package/dist/utils/auth/log-user-in.util.d.ts +3 -3
  225. package/dist/utils/auth/log-user-in.util.js +5 -5
  226. package/dist/utils/auth/request-token-using-refresh-token.util.d.ts +4 -4
  227. package/dist/utils/auth/request-token-using-refresh-token.util.js +7 -7
  228. package/dist/utils/auth/reset-password.util.d.ts +4 -4
  229. package/dist/utils/auth/reset-password.util.js +8 -8
  230. package/dist/utils/auth/send-reset-password-email.util.d.ts +2 -2
  231. package/dist/utils/auth/send-reset-password-email.util.js +5 -5
  232. package/dist/utils/auth/update-last-logged-in.util.d.ts +3 -3
  233. package/dist/utils/auth/update-last-logged-in.util.js +3 -3
  234. package/dist/utils/create-public-spec.utils.d.ts +1 -1
  235. package/dist/utils/create-public-spec.utils.js +2 -2
  236. package/dist/utils/express.utils.d.ts +4 -4
  237. package/dist/utils/express.utils.js +5 -5
  238. package/dist/utils/index.d.ts +10 -10
  239. package/dist/utils/index.js +10 -10
  240. package/dist/utils/jwt.utils.d.ts +1 -1
  241. package/dist/utils/jwt.utils.js +3 -3
  242. package/dist/utils/logger.utils.d.ts +1 -1
  243. package/dist/utils/logger.utils.js +10 -10
  244. package/dist/utils/password.utils.js +7 -7
  245. package/package.json +2 -1
@@ -2,9 +2,9 @@ export const getPostgresTestSchema = (config) => {
2
2
  const migrations = [];
3
3
  const isMultiTenant = config.app.isMultiTenant === true;
4
4
  migrations.push({
5
- name: "00000000000100_schema-test-entities",
5
+ name: '00000000000100_schema-test-entities',
6
6
  up: async ({ context: pool }) => {
7
- const orgColumnDef = isMultiTenant ? '"_orgId" INTEGER,' : "";
7
+ const orgColumnDef = isMultiTenant ? '"_orgId" INTEGER,' : '';
8
8
  await pool.query(`
9
9
  CREATE TABLE IF NOT EXISTS "test_entities" (
10
10
  "_id" INTEGER GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
@@ -28,9 +28,9 @@ export const getPostgresTestSchema = (config) => {
28
28
  },
29
29
  });
30
30
  migrations.push({
31
- name: "00000000000101_schema-categories",
31
+ name: '00000000000101_schema-categories',
32
32
  up: async ({ context: pool }) => {
33
- const orgColumnDef = isMultiTenant ? '"_orgId" INTEGER,' : "";
33
+ const orgColumnDef = isMultiTenant ? '"_orgId" INTEGER,' : '';
34
34
  await pool.query(`
35
35
  CREATE TABLE IF NOT EXISTS "categories" (
36
36
  "_id" INTEGER GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
@@ -44,9 +44,9 @@ export const getPostgresTestSchema = (config) => {
44
44
  },
45
45
  });
46
46
  migrations.push({
47
- name: "00000000000102_schema-products",
47
+ name: '00000000000102_schema-products',
48
48
  up: async ({ context: pool }) => {
49
- const orgColumnDef = isMultiTenant ? '"_orgId" INTEGER,' : "";
49
+ const orgColumnDef = isMultiTenant ? '"_orgId" INTEGER,' : '';
50
50
  await pool.query(`
51
51
  CREATE TABLE IF NOT EXISTS "products" (
52
52
  "_id" INTEGER GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
@@ -70,9 +70,9 @@ export const getPostgresTestSchema = (config) => {
70
70
  },
71
71
  });
72
72
  migrations.push({
73
- name: "00000000000103_schema-test-items",
73
+ name: '00000000000103_schema-test-items',
74
74
  up: async ({ context: pool }) => {
75
- const orgColumnDef = isMultiTenant ? '"_orgId" INTEGER,' : "";
75
+ const orgColumnDef = isMultiTenant ? '"_orgId" INTEGER,' : '';
76
76
  await pool.query(`
77
77
  CREATE TABLE IF NOT EXISTS "test_items" (
78
78
  "_id" INTEGER GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
@@ -94,9 +94,9 @@ export const getPostgresTestSchema = (config) => {
94
94
  },
95
95
  });
96
96
  migrations.push({
97
- name: "00000000000104_schema-persons",
97
+ name: '00000000000104_schema-persons',
98
98
  up: async ({ context: pool }) => {
99
- const orgColumnDef = isMultiTenant ? '"_orgId" INTEGER NOT NULL,' : "";
99
+ const orgColumnDef = isMultiTenant ? '"_orgId" INTEGER NOT NULL,' : '';
100
100
  const personsUniqueConstraints = isMultiTenant
101
101
  ? `CONSTRAINT "uk_persons_org_external_id" UNIQUE ("_orgId", "external_id"),
102
102
  CONSTRAINT "uk_persons_org_ssn" UNIQUE ("_orgId", "ssn")`
@@ -135,9 +135,9 @@ export const getPostgresTestSchema = (config) => {
135
135
  },
136
136
  });
137
137
  migrations.push({
138
- name: "00000000000105_5_schema-agents",
138
+ name: '00000000000105_5_schema-agents',
139
139
  up: async ({ context: pool }) => {
140
- const orgColumnDef = isMultiTenant ? '"_orgId" INTEGER,' : "";
140
+ const orgColumnDef = isMultiTenant ? '"_orgId" INTEGER,' : '';
141
141
  await pool.query(`
142
142
  CREATE TABLE IF NOT EXISTS "agents" (
143
143
  "_id" INTEGER GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
@@ -158,9 +158,9 @@ export const getPostgresTestSchema = (config) => {
158
158
  },
159
159
  });
160
160
  migrations.push({
161
- name: "00000000000105_6_schema-clients",
161
+ name: '00000000000105_6_schema-clients',
162
162
  up: async ({ context: pool }) => {
163
- const orgColumnDef = isMultiTenant ? '"_orgId" INTEGER,' : "";
163
+ const orgColumnDef = isMultiTenant ? '"_orgId" INTEGER,' : '';
164
164
  await pool.query(`
165
165
  CREATE TABLE IF NOT EXISTS "clients" (
166
166
  "_id" INTEGER GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
@@ -184,9 +184,9 @@ export const getPostgresTestSchema = (config) => {
184
184
  },
185
185
  });
186
186
  migrations.push({
187
- name: "00000000000105_7_schema-policies",
187
+ name: '00000000000105_7_schema-policies',
188
188
  up: async ({ context: pool }) => {
189
- const orgColumnDef = isMultiTenant ? '"_orgId" INTEGER,' : "";
189
+ const orgColumnDef = isMultiTenant ? '"_orgId" INTEGER,' : '';
190
190
  await pool.query(`
191
191
  CREATE TABLE IF NOT EXISTS "policies" (
192
192
  "_id" INTEGER GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
@@ -209,9 +209,9 @@ export const getPostgresTestSchema = (config) => {
209
209
  },
210
210
  });
211
211
  migrations.push({
212
- name: "00000000000105_8_schema-agents-policies",
212
+ name: '00000000000105_8_schema-agents-policies',
213
213
  up: async ({ context: pool }) => {
214
- const orgColumnDef = isMultiTenant ? '"_orgId" INTEGER,' : "";
214
+ const orgColumnDef = isMultiTenant ? '"_orgId" INTEGER,' : '';
215
215
  await pool.query(`
216
216
  CREATE TABLE IF NOT EXISTS agents_policies (
217
217
  "_id" INTEGER GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
@@ -235,9 +235,9 @@ export const getPostgresTestSchema = (config) => {
235
235
  },
236
236
  });
237
237
  migrations.push({
238
- name: "00000000000105_9_schema-premiums",
238
+ name: '00000000000105_9_schema-premiums',
239
239
  up: async ({ context: pool }) => {
240
- const orgColumnDef = isMultiTenant ? '"_orgId" INTEGER,' : "";
240
+ const orgColumnDef = isMultiTenant ? '"_orgId" INTEGER,' : '';
241
241
  await pool.query(`
242
242
  CREATE TABLE IF NOT EXISTS "premiums" (
243
243
  "_id" INTEGER GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
@@ -260,9 +260,9 @@ export const getPostgresTestSchema = (config) => {
260
260
  },
261
261
  });
262
262
  migrations.push({
263
- name: "00000000000106_schema-email-addresses",
263
+ name: '00000000000106_schema-email-addresses',
264
264
  up: async ({ context: pool }) => {
265
- const orgColumnDef = isMultiTenant ? '"_orgId" INTEGER,' : "";
265
+ const orgColumnDef = isMultiTenant ? '"_orgId" INTEGER,' : '';
266
266
  await pool.query(`
267
267
  CREATE TABLE IF NOT EXISTS email_addresses (
268
268
  "_id" INTEGER GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
@@ -287,9 +287,9 @@ export const getPostgresTestSchema = (config) => {
287
287
  },
288
288
  });
289
289
  migrations.push({
290
- name: "00000000000107_schema-phone-numbers",
290
+ name: '00000000000107_schema-phone-numbers',
291
291
  up: async ({ context: pool }) => {
292
- const orgColumnDef = isMultiTenant ? '"_orgId" INTEGER,' : "";
292
+ const orgColumnDef = isMultiTenant ? '"_orgId" INTEGER,' : '';
293
293
  await pool.query(`
294
294
  CREATE TABLE IF NOT EXISTS phone_numbers (
295
295
  "_id" INTEGER GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
@@ -312,9 +312,9 @@ export const getPostgresTestSchema = (config) => {
312
312
  },
313
313
  });
314
314
  migrations.push({
315
- name: "00000000000108_schema-addresses",
315
+ name: '00000000000108_schema-addresses',
316
316
  up: async ({ context: pool }) => {
317
- const orgColumnDef = isMultiTenant ? '"_orgId" INTEGER,' : "";
317
+ const orgColumnDef = isMultiTenant ? '"_orgId" INTEGER,' : '';
318
318
  await pool.query(`
319
319
  CREATE TABLE IF NOT EXISTS addresses (
320
320
  "_id" INTEGER GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
@@ -341,9 +341,9 @@ export const getPostgresTestSchema = (config) => {
341
341
  },
342
342
  });
343
343
  migrations.push({
344
- name: "00000000000109_schema-person-addresses",
344
+ name: '00000000000109_schema-person-addresses',
345
345
  up: async ({ context: pool }) => {
346
- const orgColumnDef = isMultiTenant ? '"_orgId" INTEGER,' : "";
346
+ const orgColumnDef = isMultiTenant ? '"_orgId" INTEGER,' : '';
347
347
  await pool.query(`
348
348
  CREATE TABLE IF NOT EXISTS persons_addresses (
349
349
  "_id" INTEGER GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
@@ -367,9 +367,9 @@ export const getPostgresTestSchema = (config) => {
367
367
  },
368
368
  });
369
369
  migrations.push({
370
- name: "00000000000110_schema-person-phone-numbers",
370
+ name: '00000000000110_schema-person-phone-numbers',
371
371
  up: async ({ context: pool }) => {
372
- const orgColumnDef = isMultiTenant ? '"_orgId" INTEGER,' : "";
372
+ const orgColumnDef = isMultiTenant ? '"_orgId" INTEGER,' : '';
373
373
  await pool.query(`
374
374
  CREATE TABLE IF NOT EXISTS persons_phone_numbers (
375
375
  "_id" INTEGER GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
@@ -393,9 +393,9 @@ export const getPostgresTestSchema = (config) => {
393
393
  },
394
394
  });
395
395
  migrations.push({
396
- name: "00000000000111_schema-states",
396
+ name: '00000000000111_schema-states',
397
397
  up: async ({ context: pool }) => {
398
- const orgColumnDef = isMultiTenant ? '"_orgId" INTEGER,' : "";
398
+ const orgColumnDef = isMultiTenant ? '"_orgId" INTEGER,' : '';
399
399
  await pool.query(`
400
400
  CREATE TABLE IF NOT EXISTS states (
401
401
  "_id" INTEGER GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
@@ -415,9 +415,9 @@ export const getPostgresTestSchema = (config) => {
415
415
  },
416
416
  });
417
417
  migrations.push({
418
- name: "00000000000112_schema-districts",
418
+ name: '00000000000112_schema-districts',
419
419
  up: async ({ context: pool }) => {
420
- const orgColumnDef = isMultiTenant ? '"_orgId" INTEGER,' : "";
420
+ const orgColumnDef = isMultiTenant ? '"_orgId" INTEGER,' : '';
421
421
  await pool.query(`
422
422
  CREATE TABLE IF NOT EXISTS districts (
423
423
  "_id" INTEGER GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
@@ -439,9 +439,9 @@ export const getPostgresTestSchema = (config) => {
439
439
  },
440
440
  });
441
441
  migrations.push({
442
- name: "00000000000113_schema-schools",
442
+ name: '00000000000113_schema-schools',
443
443
  up: async ({ context: pool }) => {
444
- const orgColumnDef = isMultiTenant ? '"_orgId" INTEGER,' : "";
444
+ const orgColumnDef = isMultiTenant ? '"_orgId" INTEGER,' : '';
445
445
  await pool.query(`
446
446
  CREATE TABLE IF NOT EXISTS schools (
447
447
  "_id" INTEGER GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
@@ -463,9 +463,9 @@ export const getPostgresTestSchema = (config) => {
463
463
  },
464
464
  });
465
465
  migrations.push({
466
- name: "00000000000114_schema-person-schools",
466
+ name: '00000000000114_schema-person-schools',
467
467
  up: async ({ context: pool }) => {
468
- const orgColumnDef = isMultiTenant ? '"_orgId" INTEGER,' : "";
468
+ const orgColumnDef = isMultiTenant ? '"_orgId" INTEGER,' : '';
469
469
  await pool.query(`
470
470
  CREATE TABLE IF NOT EXISTS persons_schools (
471
471
  "_id" INTEGER GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
@@ -1,5 +1,5 @@
1
- import type { IDatabase } from "../databases/models/index.js";
2
- import type { ITestDatabase } from "./test-database.interface.js";
1
+ import type { IDatabase } from '../databases/models/index.js';
2
+ import type { ITestDatabase } from './test-database.interface.js';
3
3
  export declare class TestPostgresDatabase implements ITestDatabase {
4
4
  private database;
5
5
  private postgresClient;
@@ -1,10 +1,10 @@
1
- import { Pool } from "pg";
2
- import { newDb } from "pg-mem";
3
- import { config } from "../config/base-api-config.js";
4
- import { runInitialSchemaMigrations, runTestSchemaMigrations, } from "../databases/postgres/migrations/__tests__/test-migration-helper.js";
5
- import { PostgresDatabase } from "../databases/postgres/postgres.database.js";
6
- import testUtils from "./common-test.utils.js";
7
- const USE_REAL_POSTGRES = process.env.USE_REAL_POSTGRES === "true";
1
+ import { Pool } from 'pg';
2
+ import { newDb } from 'pg-mem';
3
+ import { config } from '../config/base-api-config.js';
4
+ import { runInitialSchemaMigrations, runTestSchemaMigrations, } from '../databases/postgres/migrations/__tests__/test-migration-helper.js';
5
+ import { PostgresDatabase } from '../databases/postgres/postgres.database.js';
6
+ import testUtils from './common-test.utils.js';
7
+ const USE_REAL_POSTGRES = process.env.USE_REAL_POSTGRES === 'true';
8
8
  export class TestPostgresDatabase {
9
9
  database = null;
10
10
  postgresClient = null;
@@ -18,7 +18,7 @@ export class TestPostgresDatabase {
18
18
  return this.initPromise;
19
19
  }
20
20
  getRandomId() {
21
- throw new Error("getRandomId() should not be used for PostgreSQL _id fields. PostgreSQL uses auto-generated integer IDs. Remove _id from entities and let the database generate it.");
21
+ throw new Error('getRandomId() should not be used for PostgreSQL _id fields. PostgreSQL uses auto-generated integer IDs. Remove _id from entities and let the database generate it.');
22
22
  }
23
23
  async _performInit() {
24
24
  if (!this.database) {
@@ -32,14 +32,14 @@ export class TestPostgresDatabase {
32
32
  });
33
33
  this.migrationPool = pool;
34
34
  try {
35
- await pool.query("SELECT now(), current_database()");
35
+ await pool.query('SELECT now(), current_database()');
36
36
  }
37
37
  catch (error) {
38
38
  await pool.end();
39
39
  this.migrationPool = null;
40
40
  const errorMessage = error.message || String(error);
41
- const isPermissionError = errorMessage.includes("permission denied") ||
42
- errorMessage.includes("operation not permitted");
41
+ const isPermissionError = errorMessage.includes('permission denied') ||
42
+ errorMessage.includes('operation not permitted');
43
43
  if (isPermissionError) {
44
44
  throw new Error(`Docker permission error. Please ensure:\n` +
45
45
  `1. Docker Desktop is running\n` +
@@ -65,9 +65,9 @@ export class TestPostgresDatabase {
65
65
  }
66
66
  this.database = new PostgresDatabase(connection);
67
67
  this.postgresClient = connection;
68
- const { initializeSystemUserContext, isSystemUserContextInitialized } = await import("@loomcore/common/models");
68
+ const { initializeSystemUserContext, isSystemUserContextInitialized } = await import('@loomcore/common/models');
69
69
  if (!isSystemUserContextInitialized()) {
70
- initializeSystemUserContext(config.email?.systemEmailAddress || "system@test.com", undefined);
70
+ initializeSystemUserContext(config.email?.systemEmailAddress || 'system@test.com', undefined);
71
71
  }
72
72
  await runInitialSchemaMigrations(pool, config);
73
73
  await runTestSchemaMigrations(pool, config);
@@ -80,26 +80,26 @@ export class TestPostgresDatabase {
80
80
  async createIndexes(connection) {
81
81
  try {
82
82
  await connection.query(`
83
- CREATE INDEX IF NOT EXISTS email_index ON users (LOWER(email));
84
- CREATE UNIQUE INDEX IF NOT EXISTS email_unique_index ON users (LOWER(email));
85
- `);
83
+ CREATE INDEX IF NOT EXISTS email_index ON users (LOWER(email));
84
+ CREATE UNIQUE INDEX IF NOT EXISTS email_unique_index ON users (LOWER(email));
85
+ `);
86
86
  }
87
87
  catch (error) {
88
- console.log("Note: Indexes may be created later when tables are initialized:", error.message);
88
+ console.log('Note: Indexes may be created later when tables are initialized:', error.message);
89
89
  }
90
90
  }
91
91
  async clearCollections() {
92
92
  if (!this.postgresClient) {
93
- throw new Error("Database not initialized");
93
+ throw new Error('Database not initialized');
94
94
  }
95
95
  const result = await this.postgresClient.query(`
96
- SELECT "table_name"
97
- FROM information_schema.tables
98
- WHERE "table_schema" = 'public'
99
- AND "table_type" = 'BASE TABLE'
100
- `);
96
+ SELECT "table_name"
97
+ FROM information_schema.tables
98
+ WHERE "table_schema" = 'public'
99
+ AND "table_type" = 'BASE TABLE'
100
+ `);
101
101
  if (USE_REAL_POSTGRES) {
102
- await this.postgresClient.query(`TRUNCATE TABLE ${result.rows.map((row) => `"${row.table_name}"`).join(", ")} RESTART IDENTITY CASCADE`);
102
+ await this.postgresClient.query(`TRUNCATE TABLE ${result.rows.map((row) => `"${row.table_name}"`).join(', ')} RESTART IDENTITY CASCADE`);
103
103
  }
104
104
  else {
105
105
  result.rows.forEach(async (row) => {
@@ -121,7 +121,7 @@ export class TestPostgresDatabase {
121
121
  }
122
122
  }
123
123
  catch (error) {
124
- console.warn("Error closing PostgreSQL connection:", error);
124
+ console.warn('Error closing PostgreSQL connection:', error);
125
125
  }
126
126
  }
127
127
  this.migrationPool = null;
@@ -1,4 +1,4 @@
1
- import { IDatabase } from "../databases/models/index.js";
1
+ import { IDatabase } from '../databases/models/index.js';
2
2
  export type ITestDatabase = {
3
3
  init(): Promise<IDatabase>;
4
4
  getRandomId(): string;
@@ -1,4 +1,4 @@
1
- import { IEmailClient } from "../models/email-client.interface.js";
1
+ import { IEmailClient } from '../models/email-client.interface.js';
2
2
  export declare class TestEmailClient implements IEmailClient {
3
3
  sendResetPasswordEmail(toEmailAddress: string, resetPasswordLink: string): Promise<void>;
4
4
  }
@@ -1,6 +1,6 @@
1
- import { type Application } from "express";
2
- import type { IDatabase } from "../databases/models/database.interface.js";
3
- import type { ITestDatabase } from "./test-database.interface.js";
1
+ import { type Application } from 'express';
2
+ import type { IDatabase } from '../databases/models/database.interface.js';
3
+ import type { ITestDatabase } from './test-database.interface.js';
4
4
  type TestExpressAppInitResult = {
5
5
  app: Application;
6
6
  database: IDatabase;
@@ -1,13 +1,13 @@
1
- import { initializeTypeBox } from "@loomcore/common/validation";
2
- import bodyParser from "body-parser";
3
- import cookieParser from "cookie-parser";
4
- import express from "express";
5
- import supertest from "supertest";
6
- import { ensureUserContext } from "../middleware/ensure-user-context.js";
7
- import { errorHandler } from "../middleware/error-handler.js";
8
- import { setupTestConfig } from "./common-test.utils.js";
9
- import { TestMongoDatabase } from "./mongo-db.test-database.js";
10
- import { TestPostgresDatabase } from "./postgres.test-database.js";
1
+ import { initializeTypeBox } from '@loomcore/common/validation';
2
+ import bodyParser from 'body-parser';
3
+ import cookieParser from 'cookie-parser';
4
+ import express from 'express';
5
+ import supertest from 'supertest';
6
+ import { ensureUserContext } from '../middleware/ensure-user-context.js';
7
+ import { errorHandler } from '../middleware/error-handler.js';
8
+ import { setupTestConfig } from './common-test.utils.js';
9
+ import { TestMongoDatabase } from './mongo-db.test-database.js';
10
+ import { TestPostgresDatabase } from './postgres.test-database.js';
11
11
  let app;
12
12
  let database;
13
13
  let testDatabase;
@@ -15,7 +15,7 @@ let initPromise = null;
15
15
  async function init(useMongoDb) {
16
16
  if (useMongoDb === undefined) {
17
17
  const testDb = process.env.TEST_DATABASE;
18
- useMongoDb = testDb === "mongodb";
18
+ useMongoDb = testDb === 'mongodb';
19
19
  }
20
20
  if (initPromise) {
21
21
  return initPromise;
@@ -24,7 +24,7 @@ async function init(useMongoDb) {
24
24
  return initPromise;
25
25
  }
26
26
  async function performInit(useMongoDb) {
27
- setupTestConfig(true, useMongoDb ? "mongodb" : "postgres");
27
+ setupTestConfig(true, useMongoDb ? 'mongodb' : 'postgres');
28
28
  initializeTypeBox();
29
29
  if (!database) {
30
30
  if (useMongoDb) {
@@ -1,4 +1,4 @@
1
- import type { IOrganization, IOrganizationDomain, IUser, IUserContext } from "@loomcore/common/models";
1
+ import type { IOrganization, IOrganizationDomain, IUser, IUserContext } from '@loomcore/common/models';
2
2
  export declare let TEST_META_ORG_ID: string | number;
3
3
  export declare let TEST_META_ORG_USER_ID: string | number;
4
4
  export declare function setTestMetaOrgId(metaOrgId: string | number): void;
@@ -1,17 +1,17 @@
1
- export let TEST_META_ORG_ID = "69261691f936c45f85da24d0";
2
- export let TEST_META_ORG_USER_ID = "69261672f48fb7bf76e54dfb";
1
+ export let TEST_META_ORG_ID = '69261691f936c45f85da24d0';
2
+ export let TEST_META_ORG_USER_ID = '69261672f48fb7bf76e54dfb';
3
3
  export function setTestMetaOrgId(metaOrgId) {
4
4
  TEST_META_ORG_ID = metaOrgId;
5
5
  }
6
6
  export function setTestMetaOrgUserId(userId) {
7
7
  TEST_META_ORG_USER_ID = userId;
8
8
  }
9
- export const TEST_META_ORG_USER_PASSWORD = "test-meta-org-user-password";
10
- export const TEST_META_ORG_DOMAIN = "test-meta-org.example.com";
11
- export const TEST_ORG_DOMAIN = "test-org.example.com";
9
+ export const TEST_META_ORG_USER_PASSWORD = 'test-meta-org-user-password';
10
+ export const TEST_META_ORG_DOMAIN = 'test-meta-org.example.com';
11
+ export const TEST_ORG_DOMAIN = 'test-org.example.com';
12
12
  export function getRefererUrlForOrg(domain) {
13
13
  if (!domain) {
14
- throw new Error("Organization domain is required for auth referer URL");
14
+ throw new Error('Organization domain is required for auth referer URL');
15
15
  }
16
16
  return `https://${domain}`;
17
17
  }
@@ -24,12 +24,12 @@ export function getTestOrgRefererUrl() {
24
24
  export function getTestMetaOrg() {
25
25
  return {
26
26
  _id: TEST_META_ORG_ID,
27
- name: "Test Meta Organization",
28
- code: "test-meta-org",
27
+ name: 'Test Meta Organization',
28
+ code: 'test-meta-org',
29
29
  status: 1,
30
30
  isMetaOrg: true,
31
31
  _created: new Date(),
32
- _createdBy: "system",
32
+ _createdBy: 'system',
33
33
  };
34
34
  }
35
35
  export function getTestMetaOrgDomain(organizationId = TEST_META_ORG_ID) {
@@ -42,28 +42,28 @@ export function getTestMetaOrgUser() {
42
42
  return {
43
43
  _id: TEST_META_ORG_USER_ID,
44
44
  _orgId: getTestMetaOrg()._id,
45
- externalId: "test-meta-org-user-external-id",
46
- email: "test@example.com",
47
- displayName: "Test User",
45
+ externalId: 'test-meta-org-user-external-id',
46
+ email: 'test@example.com',
47
+ displayName: 'Test User',
48
48
  password: TEST_META_ORG_USER_PASSWORD,
49
49
  _created: new Date(),
50
- _createdBy: "system",
50
+ _createdBy: 'system',
51
51
  };
52
52
  }
53
53
  export function getTestMetaOrgUserContext() {
54
54
  return {
55
55
  user: getTestMetaOrgUser(),
56
- features: ["metaorgUser"],
56
+ features: ['metaorgUser'],
57
57
  };
58
58
  }
59
59
  export function getTestMetaOrgAdminUserContext() {
60
60
  return {
61
61
  user: getTestMetaOrgUser(),
62
- features: ["admin"],
62
+ features: ['admin'],
63
63
  };
64
64
  }
65
- let TEST_ORG_ID = "6926167d06c0073a778a124f";
66
- let TEST_ORG_USER_ID = "6926167d06c0073a778a1250";
65
+ let TEST_ORG_ID = '6926167d06c0073a778a124f';
66
+ let TEST_ORG_USER_ID = '6926167d06c0073a778a1250';
67
67
  export function setTestOrgId(orgId) {
68
68
  TEST_ORG_ID = orgId;
69
69
  }
@@ -73,12 +73,12 @@ export function setTestOrgUserId(userId) {
73
73
  export function getTestOrg() {
74
74
  return {
75
75
  _id: TEST_ORG_ID,
76
- name: "Test Organization",
77
- code: "test-org",
76
+ name: 'Test Organization',
77
+ code: 'test-org',
78
78
  status: 1,
79
79
  isMetaOrg: false,
80
80
  _created: new Date(),
81
- _createdBy: "system",
81
+ _createdBy: 'system',
82
82
  };
83
83
  }
84
84
  export function getTestOrgDomain(organizationId = TEST_ORG_ID) {
@@ -87,22 +87,22 @@ export function getTestOrgDomain(organizationId = TEST_ORG_ID) {
87
87
  domain: TEST_ORG_DOMAIN,
88
88
  };
89
89
  }
90
- export const TEST_ORG_USER_PASSWORD = "test-org-user-password";
90
+ export const TEST_ORG_USER_PASSWORD = 'test-org-user-password';
91
91
  export function getTestOrgUser() {
92
92
  return {
93
93
  _id: TEST_ORG_USER_ID,
94
94
  _orgId: getTestOrg()._id,
95
- externalId: "test-org-user-external-id",
96
- email: "test-org-user@example.com",
97
- displayName: "Test User",
95
+ externalId: 'test-org-user-external-id',
96
+ email: 'test-org-user@example.com',
97
+ displayName: 'Test User',
98
98
  password: TEST_ORG_USER_PASSWORD,
99
99
  _created: new Date(),
100
- _createdBy: "system",
100
+ _createdBy: 'system',
101
101
  };
102
102
  }
103
103
  export function getTestOrgUserContext() {
104
104
  return {
105
105
  user: getTestOrgUser(),
106
- features: ["testOrgUser"],
106
+ features: ['testOrgUser'],
107
107
  };
108
108
  }
@@ -1,5 +1,5 @@
1
- import type { IDatabase } from "../databases/models/index.js";
2
- import type { IBaseApiConfig } from "../models/index.js";
1
+ import type { IDatabase } from '../databases/models/index.js';
2
+ import type { IBaseApiConfig } from '../models/index.js';
3
3
  export declare let config: IBaseApiConfig;
4
4
  export declare function setBaseApiConfig(theConfig: IBaseApiConfig): void;
5
5
  export declare function initSystemUserContext(database: IDatabase): Promise<void>;
@@ -1,16 +1,16 @@
1
- import { EmptyUserContext, initializeSystemUserContext, } from "@loomcore/common/models";
1
+ import { EmptyUserContext, initializeSystemUserContext, } from '@loomcore/common/models';
2
2
  export let config;
3
3
  let isConfigSet = false;
4
4
  let isSystemUserContextSet = false;
5
5
  const BASE_API_CONFIG_KEYS = [
6
- "app",
7
- "auth",
8
- "database",
9
- "debug",
10
- "email",
11
- "env",
12
- "network",
13
- "thirdPartyClients",
6
+ 'app',
7
+ 'auth',
8
+ 'database',
9
+ 'debug',
10
+ 'email',
11
+ 'env',
12
+ 'network',
13
+ 'thirdPartyClients',
14
14
  ];
15
15
  function copyOnlySpecifiedConfigProperties(obj, allowedKeys) {
16
16
  const result = {};
@@ -26,29 +26,29 @@ export function setBaseApiConfig(theConfig) {
26
26
  config = copyOnlySpecifiedConfigProperties(theConfig, BASE_API_CONFIG_KEYS);
27
27
  isConfigSet = true;
28
28
  }
29
- else if (config.env !== "test") {
30
- console.warn("BaseApiConfig data has already been set. Ignoring subsequent calls to setBaseApiConfig.");
29
+ else if (config.env !== 'test') {
30
+ console.warn('BaseApiConfig data has already been set. Ignoring subsequent calls to setBaseApiConfig.');
31
31
  }
32
32
  }
33
33
  export async function initSystemUserContext(database) {
34
34
  if (!isConfigSet) {
35
- throw new Error("BaseApiConfig has not been set. Call setBaseApiConfig first.");
35
+ throw new Error('BaseApiConfig has not been set. Call setBaseApiConfig first.');
36
36
  }
37
37
  if (!isSystemUserContextSet) {
38
- const systemEmail = config.email?.systemEmailAddress || "system@example.com";
38
+ const systemEmail = config.email?.systemEmailAddress || 'system@example.com';
39
39
  let metaOrg = null;
40
40
  if (config.app.isMultiTenant) {
41
- const { OrganizationService } = await import("../services/organization.service.js");
41
+ const { OrganizationService } = await import('../services/organization.service.js');
42
42
  const organizationService = new OrganizationService(database);
43
43
  metaOrg = await organizationService.getMetaOrg(EmptyUserContext);
44
44
  if (!metaOrg) {
45
- throw new Error("Meta organization not found. Please create an organization with isMetaOrg=true before starting the API.");
45
+ throw new Error('Meta organization not found. Please create an organization with isMetaOrg=true before starting the API.');
46
46
  }
47
47
  }
48
48
  initializeSystemUserContext(systemEmail, metaOrg ?? undefined);
49
49
  isSystemUserContextSet = true;
50
50
  }
51
- else if (config.env !== "test") {
52
- console.warn("SystemUserContext has already been set. Ignoring subsequent calls to initSystemUserContext.");
51
+ else if (config.env !== 'test') {
52
+ console.warn('SystemUserContext has already been set. Ignoring subsequent calls to initSystemUserContext.');
53
53
  }
54
54
  }
@@ -1,7 +1,7 @@
1
- import { type ILoginResponse, type IModelSpec } from "@loomcore/common/models";
2
- import type { Application, Request, Response } from "express";
3
- import type { IDatabase } from "../databases/models/index.js";
4
- import { OrganizationService, UserService } from "../services/index.js";
1
+ import { type ILoginResponse, type IModelSpec } from '@loomcore/common/models';
2
+ import type { Application, Request, Response } from 'express';
3
+ import type { IDatabase } from '../databases/models/index.js';
4
+ import { OrganizationService, UserService } from '../services/index.js';
5
5
  export interface AuthControllerOptions {
6
6
  userService: UserService;
7
7
  userSpec: IModelSpec;